Ada 2.9.2
Fast spec-compliant URL parser
Loading...
Searching...
No Matches
ada::url_components Struct Reference

URL Component representations using offsets. More...

#include <url_components.h>

Public Member Functions

 url_components ()=default
 url_components (const url_components &u)=default
 url_components (url_components &&u) noexcept=default
url_componentsoperator= (url_components &&u) noexcept=default
url_componentsoperator= (const url_components &u)=default
 ~url_components ()=default
bool check_offset_consistency () const noexcept
std::string to_string () const
 url_components ()=default
 url_components (const url_components &u)=default
 url_components (url_components &&u) noexcept=default
url_componentsoperator= (url_components &&u) noexcept=default
url_componentsoperator= (const url_components &u)=default
 ~url_components ()=default
bool check_offset_consistency () const noexcept
std::string to_string () const

Public Attributes

uint32_t protocol_end {0}
uint32_t username_end {0}
uint32_t host_start {0}
uint32_t host_end {0}
uint32_t port {omitted}
uint32_t pathname_start {0}
uint32_t search_start {omitted}
uint32_t hash_start {omitted}

Static Public Attributes

static constexpr uint32_t omitted = uint32_t(-1)

Detailed Description

URL Component representations using offsets.

We design the url_components struct so that it is as small and simple as possible. This version uses 32 bytes.

This struct is used to extract components from a single 'href'.

Definition at line 23 of file url_components.h.

Constructor & Destructor Documentation

◆ url_components() [1/6]

ada::url_components::url_components ( )
default

◆ url_components() [2/6]

ada::url_components::url_components ( const url_components & u)
default

References url_components().

◆ url_components() [3/6]

ada::url_components::url_components ( url_components && u)
defaultnoexcept

References url_components().

◆ ~url_components() [1/2]

ada::url_components::~url_components ( )
default

◆ url_components() [4/6]

ada::url_components::url_components ( )
default

◆ url_components() [5/6]

ada::url_components::url_components ( const url_components & u)
default

References url_components().

◆ url_components() [6/6]

ada::url_components::url_components ( url_components && u)
defaultnoexcept

References url_components().

◆ ~url_components() [2/2]

ada::url_components::~url_components ( )
default

References protocol_end.

Member Function Documentation

◆ check_offset_consistency() [1/2]

bool ada::url_components::check_offset_consistency ( ) const
nodiscardnoexcept

Check the following conditions: protocol_end < username_end < ... < hash_start, expect when a value is omitted. It also computes a lower bound on the possible string length that may match these offsets.

Returns
true if the offset values are consistent with a possible URL string

https://user:pass@example.com:1234/foo/bar?baz#quux | | | | ^^^^| | | | | | | | | | ----- hash_start | | | | | | ------— search_start | | | | | ----------------- pathname_start | | | | ------------------— port | | | ----------------------- host_end | | -------------------------------— host_start | --------------------------------------- username_end ------------------------------------------— protocol_end

Definition at line 13075 of file ada.cpp.

References check_offset_consistency(), hash_start, host_start, omitted, pathname_start, port, protocol_end, search_start, and username_end.

Referenced by check_offset_consistency().

◆ check_offset_consistency() [2/2]

bool ada::url_components::check_offset_consistency ( ) const
nodiscardnoexcept

Check the following conditions: protocol_end < username_end < ... < hash_start, expect when a value is omitted. It also computes a lower bound on the possible string length that may match these offsets.

Returns
true if the offset values are consistent with a possible URL string

◆ operator=() [1/4]

url_components & ada::url_components::operator= ( const url_components & u)
default

References url_components().

◆ operator=() [2/4]

url_components & ada::url_components::operator= ( const url_components & u)
default

References url_components().

◆ operator=() [3/4]

url_components & ada::url_components::operator= ( url_components && u)
defaultnoexcept

References url_components().

◆ operator=() [4/4]

url_components & ada::url_components::operator= ( url_components && u)
defaultnoexcept

References url_components().

◆ to_string() [1/2]

std::string ada::url_components::to_string ( ) const
nodiscard

Converts a url_components to JSON stringified version.

Definition at line 13150 of file ada.cpp.

References hash_start, host_end, host_start, pathname_start, port, protocol_end, search_start, to_string(), and username_end.

Referenced by to_string().

◆ to_string() [2/2]

std::string ada::url_components::to_string ( ) const
nodiscard

Converts a url_components to JSON stringified version.

References to_string().

Member Data Documentation

◆ hash_start

uint32_t ada::url_components::hash_start {omitted}

Definition at line 59 of file url_components.h.

Referenced by check_offset_consistency(), ada::url::get_components(), and to_string().

◆ host_end

uint32_t ada::url_components::host_end {0}

Definition at line 55 of file url_components.h.

Referenced by ada::url::get_components(), and to_string().

◆ host_start

uint32_t ada::url_components::host_start {0}

Definition at line 54 of file url_components.h.

Referenced by check_offset_consistency(), ada::url::get_components(), and to_string().

◆ omitted

◆ pathname_start

uint32_t ada::url_components::pathname_start {0}

Definition at line 57 of file url_components.h.

Referenced by check_offset_consistency(), ada::url::get_components(), and to_string().

◆ port

uint32_t ada::url_components::port {omitted}

Definition at line 56 of file url_components.h.

Referenced by check_offset_consistency(), ada::url::get_components(), and to_string().

◆ protocol_end

uint32_t ada::url_components::protocol_end {0}

◆ search_start

uint32_t ada::url_components::search_start {omitted}

Definition at line 58 of file url_components.h.

Referenced by check_offset_consistency(), ada::url::get_components(), and to_string().

◆ username_end

uint32_t ada::url_components::username_end {0}

Username end is not omitted by default to make username and password getters less costly to implement.

Definition at line 53 of file url_components.h.

Referenced by check_offset_consistency(), ada::url::get_components(), and to_string().


The documentation for this struct was generated from the following files: