|
VLink 2.0.0
A high-performance communication middleware
|
Immutable RFC-3986 URL parser. 更多...
#include <url_parser.h>
Public 类型 | |
| enum class | Category : uint8_t { kHierarchical = 0 , kNonHierarchical = 1 } |
| Distinguishes hierarchical and non-hierarchical URL forms. 更多... | |
| enum class | Component : uint8_t { kTransport = 0 , kContent = 1 , kUsername = 2 , kPassword = 3 , kHost = 4 , kPort = 5 , kPath = 6 , kQuery = 7 , kFragment = 8 } |
| Identifies individual URL components for the components-map constructor. 更多... | |
| enum class | Separator : uint8_t { kAmpersand = 0 , kSemicolon = 1 } |
| Query-string key-value pair delimiter. 更多... | |
Public 成员函数 | |
| UrlParser (const char *str, Category category=Category::kHierarchical, Separator separator=Separator::kAmpersand) | |
| Constructs a parser by parsing the given C-string URL. | |
| UrlParser (const std::string &str, Category category=Category::kHierarchical, Separator separator=Separator::kAmpersand) | |
Constructs a parser by parsing the given std::string URL. | |
| UrlParser (const std::map< Component, std::string > &components, Category category, bool rooted, Separator separator=Separator::kAmpersand) | |
| Constructs a URL from an explicit component map. | |
| UrlParser (const UrlParser &other, const std::map< Component, std::string > &replacements) | |
Constructs a parser by copying other and overriding specific components. | |
| const std::string & | get_transport () const |
Returns the transport string parsed from the URL (e.g. "dds", "intra"). | |
| Category | get_category () const |
| Returns the URL category (hierarchical or non-hierarchical). | |
| const std::string & | get_content () const |
| Returns the full content portion of the URL (after the scheme separator). | |
| const std::string & | get_username () const |
| Returns the authentication username component. | |
| const std::string & | get_password () const |
| Returns the authentication password component. | |
| const std::string & | get_host () const |
| Returns the host component (hostname or IP address). | |
| int64_t | get_port () const |
Returns the port number, or 0 if no port was specified. | |
| const std::string & | get_path () const |
| Returns the path component of the URL. | |
| const std::string & | get_query () const |
Returns the raw query string (without the leading ? character). | |
| const std::map< std::string, std::string > & | get_query_dictionary () const |
| Returns the parsed query string as a key-value dictionary. | |
| const std::string & | get_fragment () const |
Returns the fragment identifier component (without the leading #). | |
| std::string | to_string () const |
| Reconstructs the URL as a canonical string from parsed components. | |
Immutable RFC-3986 URL parser.
Parses the input URL string once at construction time. All accessor methods are const and return references to internally stored strings; the lifetime of the returned references is tied to the lifetime of the UrlParser object.
|
strong |
|
strong |
Identifies individual URL components for the components-map constructor.
|
strong |
|
explicit |
Constructs a parser by parsing the given C-string URL.
| str | Null-terminated URL string to parse. |
| category | Hierarchical or non-hierarchical form; default hierarchical. |
| separator | Query key-value delimiter; default ampersand (&). |
|
explicit |
Constructs a parser by parsing the given std::string URL.
| str | URL string to parse. |
| category | Hierarchical or non-hierarchical form; default hierarchical. |
| separator | Query key-value delimiter; default ampersand (&). |
|
explicit |
Constructs a URL from an explicit component map.
Builds the internal state from a pre-decomposed set of components rather than parsing a raw URL string. Useful when constructing a modified URL from an existing UrlParser instance.
| components | Map of Component to string value for each component present. |
| category | Hierarchical or non-hierarchical form. |
| rooted | true if the path begins with / (hierarchical URLs only). |
| separator | Query key-value delimiter; default ampersand. |
|
explicit |
Constructs a parser by copying other and overriding specific components.
Copies all components from other, then replaces those present in replacements. Equivalent to creating a modified copy of an existing URL.
| other | Source UrlParser to copy from. |
| replacements | Components to override in the copy. |
|
nodiscard |
Returns the URL category (hierarchical or non-hierarchical).
Category value supplied at construction.
|
nodiscard |
Returns the full content portion of the URL (after the scheme separator).
|
nodiscard |
Returns the fragment identifier component (without the leading #).
|
nodiscard |
Returns the host component (hostname or IP address).
|
nodiscard |
Returns the authentication password component.
|
nodiscard |
Returns the path component of the URL.
|
nodiscard |
Returns the port number, or 0 if no port was specified.
int64_t; 0 if absent.
|
nodiscard |
Returns the raw query string (without the leading ? character).
|
nodiscard |
Returns the parsed query string as a key-value dictionary.
Built by splitting the raw query on the configured Separator and then splitting each token on the first = character. Keys without a = are stored with an empty-string value.
std::map<string,string> query dictionary.
|
nodiscard |
Returns the transport string parsed from the URL (e.g. "dds", "intra").
|
nodiscard |
Returns the authentication username component.
|
nodiscard |
Reconstructs the URL as a canonical string from parsed components.
Re-assembles the parsed URI into a canonical string. Hierarchical URLs are emitted as scheme://authority/path?query#fragment, while non-hierarchical URLs are emitted as scheme:content?query#fragment. The output may differ slightly from the original input if the input had unusual whitespace or encoding.