|
VLink
2.0.0
A high-performance communication middleware
|
Immutable URL decomposition used by the VLink transport router. 更多...
#include <url_parser.h>
Public 类型 | |
| enum class | Category : uint8_t { kHierarchical = 0 , kNonHierarchical = 1 } |
| Distinguishes hierarchical and non-hierarchical URI forms. 更多... | |
| enum class | Component : uint8_t { kTransport = 0 , kContent = 1 , kUsername = 2 , kPassword = 3 , kHost = 4 , kPort = 5 , kPath = 6 , kQuery = 7 , kFragment = 8 } |
| Component identifiers accepted by the explicit-components constructor. 更多... | |
| enum class | Separator : uint8_t { kAmpersand = 0 , kSemicolon = 1 } |
| Selectable separator used to break the query string into key/value pairs. 更多... | |
Public 成员函数 | |
| UrlParser (const char *str, Category category=Category::kHierarchical, Separator separator=Separator::kAmpersand) | |
Parses str as a null-terminated URL string. 更多... | |
| UrlParser (const std::string &str, Category category=Category::kHierarchical, Separator separator=Separator::kAmpersand) | |
Parses str as an std::string URL. 更多... | |
| UrlParser (const std::map< Component, std::string > &components, Category category, bool rooted, Separator separator=Separator::kAmpersand) | |
| Builds a parser directly from an explicit component map. 更多... | |
| UrlParser (const UrlParser &other, const std::map< Component, std::string > &replacements) | |
Builds a parser by copying other and overriding selected components. 更多... | |
| const std::string & | get_transport () const |
Returns the parsed transport string (e.g. "dds" or "intra"). 更多... | |
| Category | get_category () const |
| Returns the URL category supplied at construction time. 更多... | |
| const std::string & | get_content () const |
| Returns the full content portion of a non-hierarchical URL. 更多... | |
| 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 when 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 ?). 更多... | |
| 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 (without the leading #). 更多... | |
| std::string | to_string () const |
| Reconstructs the URL string from the parsed components. 更多... | |
Immutable URL decomposition used by the VLink transport router.
Parses the input URL once at construction and exposes each component through const accessors. For hierarchical URLs the stored path drops the leading / marker; the rootedness flag is preserved separately so to_string() can reconstruct an equivalent representation.
|
strong |
|
strong |
Component identifiers accepted by the explicit-components constructor.
|
strong |
|
explicit |
Parses str as a null-terminated URL string.
| str | URL string to parse. |
| category | Hierarchical or non-hierarchical layout; default hierarchical. |
| separator | Query-pair separator; default &. |
|
explicit |
Parses str as an std::string URL.
| str | URL string to parse. |
| category | Hierarchical or non-hierarchical layout; default hierarchical. |
| separator | Query-pair separator; default &. |
|
explicit |
Builds a parser directly from an explicit component map.
Useful for constructing a URL from a previously decomposed set of fields instead of parsing a raw string.
| components | Map of Component to value for every present component. |
| category | Hierarchical or non-hierarchical layout. |
| rooted | true when the path starts with / (hierarchical URLs). |
| separator | Query-pair separator; default &. |
| Exception::RuntimeError | when category is Category::kHierarchical and Component::kPath is missing, or when category is Category::kNonHierarchical and Component::kContent is missing. |
|
explicit |
Builds a parser by copying other and overriding selected components.
Equivalent to producing a modified copy of an existing URL.
| other | Source parser. |
| replacements | Components that override the corresponding entries in other. |
| Category vlink::UrlParser::get_category | ( | ) | const |
Returns the URL category supplied at construction time.
Category::kHierarchical or Category::kNonHierarchical. | const std::string& vlink::UrlParser::get_content | ( | ) | const |
Returns the full content portion of a non-hierarchical URL.
Calling this method on a hierarchical URL throws Exception::RuntimeError.
| const std::string& vlink::UrlParser::get_fragment | ( | ) | const |
Returns the fragment identifier (without the leading #).
| const std::string& vlink::UrlParser::get_host | ( | ) | const |
Returns the host component (hostname or IP address).
Valid only for hierarchical URLs; otherwise throws Exception::RuntimeError.
| const std::string& vlink::UrlParser::get_password | ( | ) | const |
Returns the authentication password component.
Valid only for hierarchical URLs; otherwise throws Exception::RuntimeError.
| const std::string& vlink::UrlParser::get_path | ( | ) | const |
Returns the path component of the URL.
Valid only for hierarchical URLs; otherwise throws Exception::RuntimeError. The returned string omits the leading / for rooted hierarchical URLs; the rootedness flag is retained internally and emitted again by to_string().
| int64_t vlink::UrlParser::get_port | ( | ) | const |
Returns the port number, or 0 when no port was specified.
Valid only for hierarchical URLs; otherwise throws Exception::RuntimeError.
int64_t; 0 when absent. | const std::string& vlink::UrlParser::get_query | ( | ) | const |
Returns the raw query string (without the leading ?).
| const std::map<std::string, std::string>& vlink::UrlParser::get_query_dictionary | ( | ) | const |
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 value appear with an empty string.
| const std::string& vlink::UrlParser::get_transport | ( | ) | const |
Returns the parsed transport string (e.g. "dds" or "intra").
| const std::string& vlink::UrlParser::get_username | ( | ) | const |
Returns the authentication username component.
Valid only for hierarchical URLs; otherwise throws Exception::RuntimeError.
| std::string vlink::UrlParser::to_string | ( | ) | const |
Reconstructs the URL string from the parsed components.
Hierarchical URLs are reassembled as scheme://authority/path?query::fragment when an authority is present; non-hierarchical URLs as scheme:content?query::fragment. The output may differ from the original input when equivalent components were originally written differently.