| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This library provides:
This library has been modernized to use C++23 exclusively, leveraging the latest standard library features:
This project requires:
skyr::url is available on vcpkg. It can be installed by executing the following steps:
> cd ${VCPKG_ROOT}
> git init
> git remote add origin https://github.com/Microsoft/vcpkg.git
> git fetch origin master
> git checkout -b master origin/master
> ./bootstrap-vcpkg.sh
> ./vcpkg install skyr-urlOn Windows - for example, using Powershell - replace the call to bootstrap-vcpkg.sh with bootstrap-vcpkg.bat.
Using vcpkg, install the optional test dependencies:
> cd ${VCPKG_ROOT}
> git init
> git remote add origin https://github.com/Microsoft/vcpkg.git
> git fetch origin master
> git checkout -b master origin/master
> ./bootstrap-vcpkg.sh
> ./vcpkg install catch2 nlohmann-jsonNote: The library has zero dependencies. catch2 and nlohmann-json are only needed for tests and optional JSON functionality.
From a terminal, execute the following sequence of commands:
> mkdir _build
> cmake \
-B _build \
-G "Ninja" \
-DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/vcpkg/scripts/buildsystems/vcpkg.cmake \
.
> cmake --build _buildTo run the tests:
> cmake --build _build --target testOn Windows, replace the target with RUN_TESTS:
> cmake --build _build --target RUN_TESTSTo install the library (optional):
> cmake --build _build --target installOr with a custom install prefix:
> cmake \
-B _build \
-G "Ninja" \
-DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/vcpkg/scripts/buildsystems/vcpkg.cmake \
-DCMAKE_INSTALL_PREFIX=/your/install/path \
.
> cmake --build _build --target installNote: Depending on the install location, you may need administrator privileges (e.g., sudo on Linux).
Here is an example of how to use the skyr::url class to parse a URL string and to process the components:
// url_parts.cpp
#include <print>
#include <skyr/url.hpp>
#include <skyr/url_format.hpp>
int main() {
using namespace skyr::literals;
auto url =
"http://sub.example.إختبار:8090/\xcf\x80?a=1&c=2&b=\xe2\x80\x8d\xf0\x9f\x8c\x88"_url;
std::println("Origin: {:o}", url);
std::println("Protocol: {:s}", url);
std::println("Domain? {}", url.is_domain());
std::println("Domain: {:h}", url); // Encoded (punycode)
std::println("Domain: {:hd}", url); // Decoded (unicode)
std::println("Port: {:p}", url);
std::println("Pathname: {:Pd}", url); // Decoded pathname
std::println("Search parameters:");
const auto &search = url.search_parameters();
for (const auto &[key, value] : search) {
std::println(" key: {}, value = {}", key, value);
}
}Here is the CMake script to build the example:
# CMakeLists.txt
cmake_minimum_required(VERSION 3.16)
project(my_project)
find_package(skyr-url CONFIG REQUIRED)
set(CMAKE_CXX_STANDARD 23)
add_executable(url_parts url_parts.cpp)
target_link_libraries(url_parts PRIVATE skyr::skyr-url)The output of this program is:
Origin: http://sub.example.xn--kgbechtv:8090
Protocol: http
Domain? true
Domain: sub.example.xn--kgbechtv
Domain: sub.example.إختبار
Port: 8090
Pathname: /π
Search parameters:
key: a, value = 1
key: c, value = 2
key: b, value = 🌈This library leverages C++23 standard library features:
Core library: Zero external dependencies!
Test dependencies (optional):
Look at the GitHub Actions Status for all of the configurations for which this library is tested.
This library is released under the Boost Software License (please see http://boost.org/LICENSE_1_0.txt or the accompanying LICENSE_1_0.txt file for the full text).
This name was chosen by a random project name generator, which itself was randomly chosen.
Any questions about this library can be addressed to the cpp-netlib developers mailing list. Issues can be filed on our GitHub page.
You can also contact me via Twitter @glynos.
| Back | FazBrowse Home | New Git URL |