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
 
constexpr 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/3]

ada::url_components::url_components ( )
default

◆ url_components() [2/3]

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

◆ url_components() [3/3]

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

◆ ~url_components()

ada::url_components::~url_components ( )
default

Member Function Documentation

◆ check_offset_consistency()

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

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:[email protected]:1234/foo/bar?baz#quux | | | | ^^^^| | | | | | | | | | ----- hash_start | | | | | |------— search_start | | | | | ----------------- pathname_start | | | |------------------— port | | | ----------------------- host_end | |-------------------------------— host_start | --------------------------------------- username_end ------------------------------------------— protocol_end

Definition at line 12 of file url_components-inl.h.

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

Referenced by ada::url_aggregator::validate().

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ to_string()

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

Converts a url_components to JSON stringified version.

Definition at line 10 of file url_components.cpp.

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

Referenced by ada::url_aggregator::clear_hash(), and ada::url_aggregator::clear_search().

Member Data Documentation

◆ hash_start

◆ host_end

◆ host_start

◆ omitted

◆ pathname_start

◆ port

◆ protocol_end

◆ search_start

◆ username_end


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