URL builder utility using libcurl's URL API. More...
#include <url.hpp>
Public Member Functions | |
| UrlBuilder () | |
| Construct an empty URL builder. More... | |
| UrlBuilder (std::string const &url, std::optional< unsigned int > bitmask_url_flags=std::nullopt) | |
| Construct a URL builder from an existing URL string. More... | |
| UrlBuilder (UrlParser::UrlComponents const &components, std::optional< unsigned int > bitmask_url_flags=std::nullopt) | |
| Construct a URL builder from parsed URL components. More... | |
| UrlBuilder & | set_scheme (std::optional< std::string > const &scheme) |
| Set the URL scheme (e.g., "http", "https", "ftp") More... | |
| UrlBuilder & | set_host (std::optional< std::string > const &host) |
| Set the hostname or IP address. More... | |
| UrlBuilder & | set_port (std::optional< std::string > const &port) |
| Set the port number. More... | |
| UrlBuilder & | set_path (std::optional< std::string > const &path) |
| Set the path component. More... | |
| UrlBuilder & | set_query (std::optional< std::string > const &query) |
| Set the entire query string. More... | |
| UrlBuilder & | set_fragment (std::optional< std::string > const &fragment) |
| Set the fragment identifier. More... | |
| std::string | build (std::optional< unsigned int > bitmask_component_flags=std::nullopt) const |
| Build the final URL string. More... | |
Static Public Member Functions | |
| static std::string | build_manually (UrlParser::UrlComponents const &components) |
URL builder utility using libcurl's URL API.
This class provides methods for constructing and modifying URLs by setting individual components (scheme, host, port, path, query, fragment).
Example:
|
explicit |
Construct an empty URL builder.
| std::runtime_error | if initialization fails |
|
explicit |
Construct a URL builder from an existing URL string.
| url | The URL string to start with |
| bitmask_url_flags | Optional flags for URL parsing. Common flags include:
|
| std::runtime_error | if the URL cannot be parsed |
|
explicit |
Construct a URL builder from parsed URL components.
| components | The parsed URL components to start with |
| bitmask_url_flags | Optional flags for URL handling |
| std::runtime_error | if the components cannot be set |
| std::string kvikio::detail::UrlBuilder::build | ( | std::optional< unsigned int > | bitmask_component_flags = std::nullopt | ) | const |
Build the final URL string.
| bitmask_component_flags | Optional flags for URL formatting. Common flags:
|
| std::runtime_error | if the URL cannot be built |
Example:
| UrlBuilder& kvikio::detail::UrlBuilder::set_fragment | ( | std::optional< std::string > const & | fragment | ) |
Set the fragment identifier.
| fragment | The fragment (without leading "#"). Use std::nullopt to clear |
| std::runtime_error | if the fragment is invalid |
Example:
| UrlBuilder& kvikio::detail::UrlBuilder::set_host | ( | std::optional< std::string > const & | host | ) |
Set the hostname or IP address.
| host | The host to set. Use std::nullopt to clear |
| std::runtime_error | if the host is invalid |
Example:
| UrlBuilder& kvikio::detail::UrlBuilder::set_path | ( | std::optional< std::string > const & | path | ) |
Set the path component.
| path | The path to set (should start with "/" for absolute paths). Use std::nullopt to clear |
| std::runtime_error | if the path is invalid |
Example:
| UrlBuilder& kvikio::detail::UrlBuilder::set_port | ( | std::optional< std::string > const & | port | ) |
Set the port number.
| port | The port to set as string. Use std::nullopt to clear |
| std::runtime_error | if the port is invalid |
Example:
| UrlBuilder& kvikio::detail::UrlBuilder::set_query | ( | std::optional< std::string > const & | query | ) |
Set the entire query string.
| query | The query string (without leading "?"). Use std::nullopt to clear |
| std::runtime_error | if the query is invalid |
Example:
| UrlBuilder& kvikio::detail::UrlBuilder::set_scheme | ( | std::optional< std::string > const & | scheme | ) |
Set the URL scheme (e.g., "http", "https", "ftp")
| scheme | The scheme to set. Use std::nullopt to clear |
| std::runtime_error | if the scheme is invalid |
Example: