The class url
enables
parsing and accessing the components of URLs.
class url
Types
Name |
Description |
---|---|
Components of the URL, used with from_string. |
Member Functions
Name |
Description |
---|---|
Gets the fragment component of the URL. |
|
Converts a string representation of a URL into an object of class url. |
|
Gets the host component of the URL. |
|
Gets the path component of the URL. |
|
Gets the port component of the URL. |
|
Gets the protocol component of the URL. |
|
Gets the query component of the URL. |
|
Converts an object of class url to a string representation. |
|
Constructs an object of class url. |
|
Gets the user info component of the URL. |
Friends
Name |
Description |
---|---|
Compares two url objects for inequality. |
|
Compares two url objects for ordering. |
|
Compares two url objects for equality. |
Example
To extract the components of a URL:
urdl::url url("http://user:pass@host:1234/dir/page?param=0#anchor"); std::cout << "Protocol: " << url.protocol() << std::endl; std::cout << "User Info: " << url.user_info() << std::endl; std::cout << "Host: " << url.host() << std::endl; std::cout << "Port: " << url.port() << std::endl; std::cout << "Path: " << url.path() << std::endl; std::cout << "Query: " << url.query() << std::endl; std::cout << "Fragment: " << url.fragment() << std::endl;
The above code will print:
Protocol: http User Info: user:pass Host: host Port: 1234 Path: /dir/page Query: param=0 Fragment: anchor
Requirements
Header: <urdl/url.hpp>
Namespace: urdl