Struct url

Inheritance Relationships

Base Type

Struct Documentation

struct url : public liberate::cpp::comparison_operators<url>

The URL class provides minimal URL parsing; this is no way specs conforming.

That is, more advanced features of proper URLs are ignored - such as using URL escaping, or quoting, etc. The main goal is to split a URL into:

  • scheme

  • authority (host)

  • path

  • query parameters

  • fragment

The logic is simple enough that, for example, the first # found is assumed to be the fragment delimiter, etc. It also does not deal with duplicate parameters; the last found always wins.

One thing that it does, however, is lower-case the scheme, all query parameters and their values, and convert all values indicating boolean values to simple “0” and “1” (e.g. “true”, “yes”, etc.).

Public Functions

std::string str() const

Convert back to string.

Returns

string representation of this object.

void swap(url &other)

Swap values with another url.

Parameters

other[inout] The other object to swap values with.

size_t hash() const
Returns

a hash value for the object for use in unordered maps.

Public Members

std::string scheme

Scheme.

std::string authority

Authority.

std::string path

Path.

std::map<std::string, std::string> query

Key-value map of query parameters - note that this deduplicates parameters.

std::string fragment

fragment

Public Static Functions

static url parse(char const *url_string)

Parse string and return url object.

Parameters

url_string[in] The string to parse.

Returns

a parsed url.

static url parse(std::string const &url_string)

Parse string and return url object.

Parameters

url_string[in] The string to parse.

Returns

a parsed url.

Friends

friend struct liberate::cpp::comparison_operators< url >