Urdl C++ Library

PrevUpHomeNext

url

The class url enables parsing and accessing the components of URLs.

class url

Types

Name

Description

components_type

Components of the URL, used with from_string.

Member Functions

Name

Description

fragment

Gets the fragment component of the URL.

from_string

Converts a string representation of a URL into an object of class url.

host

Gets the host component of the URL.

path

Gets the path component of the URL.

port

Gets the port component of the URL.

protocol

Gets the protocol component of the URL.

query

Gets the query component of the URL.

to_string

Converts an object of class url to a string representation.

url

Constructs an object of class url.

user_info

Gets the user info component of the URL.

Friends

Name

Description

operator!=

Compares two url objects for inequality.

operator<

Compares two url objects for ordering.

operator==

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


PrevUpHomeNext