Ada 3.1.0
Fast spec-compliant URL parser
Loading...
Searching...
No Matches
ada Namespace Reference

Namespaces

namespace  character_sets
 Includes the definitions for unicode character sets.
 
namespace  checkers
 Includes the definitions for validation functions.
 
namespace  helpers
 Includes the definitions for helper functions.
 
namespace  idna
 
namespace  parser
 Includes the definitions for supported parsers.
 
namespace  scheme
 Includes the scheme declarations.
 
namespace  serializers
 Includes the definitions for URL serializers.
 
namespace  unicode
 Includes the declarations for unicode operations.
 
namespace  url_pattern_helpers
 
namespace  url_pattern_regex
 

Classes

struct  url
 Generic URL struct reliant on std::string instantiation. More...
 
struct  url_aggregator
 Lightweight URL struct. More...
 
struct  url_base
 Base class of URL implementations. More...
 
struct  url_components
 URL Component representations using offsets. More...
 
class  url_pattern
 
struct  url_pattern_compile_component_options
 
class  url_pattern_component
 
struct  url_pattern_component_result
 
struct  url_pattern_init
 
struct  url_pattern_options
 
class  url_pattern_part
 
struct  url_pattern_result
 
struct  url_search_params
 
struct  url_search_params_iter
 

Concepts

concept  url_pattern_encoding_callback
 

Typedefs

template<class result_type = ada::url_aggregator>
using result = tl::expected<result_type, ada::errors>
 
using url_pattern_input = std::variant<std::string_view, url_pattern_init>
 
typedef std::pair< std::string_view, std::string_view > key_value_view_pair
 
using url_search_params_keys_iter
 
using url_search_params_values_iter
 
using url_search_params_entries_iter
 

Enumerations

enum  { ADA_VERSION_MAJOR = 3 , ADA_VERSION_MINOR = 1 , ADA_VERSION_REVISION = 0 }
 
enum class  encoding_type { UTF8 , UTF_16LE , UTF_16BE }
 
enum class  errors : uint8_t { type_error }
 
enum class  state {
  AUTHORITY , SCHEME_START , SCHEME , HOST ,
  NO_SCHEME , FRAGMENT , RELATIVE_SCHEME , RELATIVE_SLASH ,
  FILE , FILE_HOST , FILE_SLASH , PATH_OR_AUTHORITY ,
  SPECIAL_AUTHORITY_IGNORE_SLASHES , SPECIAL_AUTHORITY_SLASHES , SPECIAL_RELATIVE_OR_AUTHORITY , QUERY ,
  PATH , PATH_START , OPAQUE_PATH , PORT
}
 
enum  url_host_type : uint8_t { DEFAULT = 0 , IPV4 = 1 , IPV6 = 2 }
 
enum class  url_pattern_part_type : uint8_t { FIXED_TEXT , REGEXP , SEGMENT_WILDCARD , FULL_WILDCARD }
 
enum class  url_pattern_part_modifier : uint8_t { none , optional , zero_or_more , one_or_more }
 
enum class  url_search_params_iter_type { KEYS , VALUES , ENTRIES }
 

Functions

void unreachable ()
 
ada_warn_unused std::string to_string (encoding_type type)
 
template<url_pattern_regex::regex_concept regex_provider>
ada_warn_unused tl::expected< url_pattern< regex_provider >, errorsparse_url_pattern (std::variant< std::string_view, url_pattern_init > input, const std::string_view *base_url, const url_pattern_options *options)
 
template<class result_type = ada::url_aggregator>
ada_warn_unused ada::result< result_type > parse (std::string_view input, const result_type *base_url=nullptr)
 
template ada::result< urlparse< url > (std::string_view input, const url *base_url)
 
template ada::result< url_aggregatorparse< url_aggregator > (std::string_view input, const url_aggregator *base_url)
 
bool can_parse (std::string_view input, const std::string_view *base_input=nullptr)
 
std::string href_from_file (std::string_view path)
 
ada_warn_unused std::string to_string (ada::state s)
 
std::ostream & operator<< (std::ostream &out, const ada::url &u)
 
std::ostream & operator<< (std::ostream &out, const ada::url_aggregator &u)
 
template<class result_type>
ada_warn_unused tl::expected< result_type, errorsparse (std::string_view input, const result_type *base_url)
 

Variables

template<typename T, ada::url_search_params_iter_type Type>
url_search_params url_search_params_iter< T, Type >::EMPTY
 

Typedef Documentation

◆ key_value_view_pair

typedef std::pair<std::string_view, std::string_view> ada::key_value_view_pair

Definition at line 24 of file url_search_params.h.

◆ result

template<class result_type = ada::url_aggregator>
using ada::result = tl::expected<result_type, ada::errors>

Definition at line 21 of file implementation.h.

◆ url_pattern_input

using ada::url_pattern_input = std::variant<std::string_view, url_pattern_init>

Definition at line 196 of file url_pattern.h.

◆ url_search_params_entries_iter

◆ url_search_params_keys_iter

◆ url_search_params_values_iter

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
ADA_VERSION_MAJOR 
ADA_VERSION_MINOR 
ADA_VERSION_REVISION 

Definition at line 12 of file ada_version.h.

◆ encoding_type

enum class ada::encoding_type
strong

This specification defines three encodings with the same names as encoding schemes defined in the Unicode standard: UTF-8, UTF-16LE, and UTF-16BE.

See also
https://encoding.spec.whatwg.org/#encodings
Enumerator
UTF8 
UTF_16LE 
UTF_16BE 

Definition at line 19 of file encoding_type.h.

◆ errors

enum class ada::errors : uint8_t
strong
Enumerator
type_error 

Definition at line 10 of file errors.h.

◆ state

enum class ada::state
strong

◆ url_host_type

enum ada::url_host_type : uint8_t

Type of URL host as an enum.

Enumerator
DEFAULT 

Represents common URLs such as "https://www.google.com"

IPV4 

Represents ipv4 addresses such as "http://127.0.0.1"

IPV6 

Represents ipv6 addresses such as "http://[2001:db8:3333:4444:5555:6666:7777:8888]"

Definition at line 19 of file url_base.h.

◆ url_pattern_part_modifier

enum class ada::url_pattern_part_modifier : uint8_t
strong
Enumerator
none 
optional 
zero_or_more 
one_or_more 

Definition at line 40 of file url_pattern.h.

◆ url_pattern_part_type

enum class ada::url_pattern_part_type : uint8_t
strong
Enumerator
FIXED_TEXT 
REGEXP 
SEGMENT_WILDCARD 
FULL_WILDCARD 

Definition at line 26 of file url_pattern.h.

◆ url_search_params_iter_type

Enumerator
KEYS 
VALUES 
ENTRIES 

Definition at line 15 of file url_search_params.h.

Function Documentation

◆ can_parse()

bool ada::can_parse ( std::string_view input,
const std::string_view * base_input = nullptr )

Verifies whether the URL strings can be parsed. The function assumes that the inputs are valid ASCII or UTF-8 strings.

See also
https://url.spec.whatwg.org/#dom-url-canparse
Returns
If URL can be parsed or not.

Definition at line 51 of file implementation.cpp.

References ada::url_base::is_valid, and ada::parser::parse_url_impl().

Referenced by ada_can_parse(), ada_can_parse_with_base(), and LLVMFuzzerTestOneInput().

◆ href_from_file()

std::string ada::href_from_file ( std::string_view path)

Computes a href string from a file path. The function assumes that the input is a valid ASCII or UTF-8 string.

Returns
a href string (starts with file:://)

Definition at line 28 of file implementation.cpp.

References ada::scheme::FILE.

Referenced by LLVMFuzzerTestOneInput().

◆ operator<<() [1/2]

std::ostream & ada::operator<< ( std::ostream & out,
const ada::url & u )
inline

Definition at line 38 of file url-inl.h.

References ada::url::to_string().

◆ operator<<() [2/2]

std::ostream & ada::operator<< ( std::ostream & out,
const ada::url_aggregator & u )
inline

Definition at line 1103 of file url_aggregator-inl.h.

References ada::url_aggregator::to_string().

◆ parse() [1/2]

template<class result_type>
ada_warn_unused tl::expected< result_type, errors > ada::parse ( std::string_view input,
const result_type * base_url = nullptr )

The URL parser takes a scalar value string input, with an optional null or base URL base (default null). The parser assumes the input is a valid ASCII or UTF-8 string.

Parameters
inputthe string input to analyze (must be valid ASCII or UTF-8)
base_urlthe optional URL input to use as a base url.
Returns
a parsed URL.

Definition at line 13 of file implementation.cpp.

References ada_warn_unused, ada::parser::parse_url_impl(), and type_error.

Referenced by ada_parse(), ada_parse_with_base(), ada::url_pattern_helpers::canonicalize_opaque_pathname(), ada::url_pattern_helpers::canonicalize_pathname(), ada::url_pattern_helpers::canonicalize_protocol(), ada::url::get_origin(), ada::url_aggregator::get_origin(), LLVMFuzzerTestOneInput(), and ada::url::set_href().

◆ parse() [2/2]

template<class result_type = ada::url_aggregator>
ada_warn_unused ada::result< result_type > ada::parse ( std::string_view input,
const result_type * base_url = nullptr )

The URL parser takes a scalar value string input, with an optional null or base URL base (default null). The parser assumes the input is a valid ASCII or UTF-8 string.

Parameters
inputthe string input to analyze (must be valid ASCII or UTF-8)
base_urlthe optional URL input to use as a base url.
Returns
a parsed URL.

Definition at line 13 of file implementation.cpp.

References ada_warn_unused, ada::parser::parse_url_impl(), and type_error.

Referenced by ada_parse(), ada_parse_with_base(), ada::url_pattern_helpers::canonicalize_opaque_pathname(), ada::url_pattern_helpers::canonicalize_pathname(), ada::url_pattern_helpers::canonicalize_protocol(), ada::url::get_origin(), ada::url_aggregator::get_origin(), LLVMFuzzerTestOneInput(), and ada::url::set_href().

◆ parse< url >()

template ada::result< url > ada::parse< url > ( std::string_view input,
const url * base_url )
extern

◆ parse< url_aggregator >()

◆ parse_url_pattern()

template<url_pattern_regex::regex_concept regex_provider>
ada_warn_unused tl::expected< url_pattern< regex_provider >, errors > ada::parse_url_pattern ( std::variant< std::string_view, url_pattern_init > input,
const std::string_view * base_url = nullptr,
const url_pattern_options * options = nullptr )

Implementation of the URL pattern parsing algorithm.

See also
https://urlpattern.spec.whatwg.org
Parameters
inputvalid UTF-8 string or URLPatternInit struct
base_urlan optional valid UTF-8 string
optionsan optional url_pattern_options struct
Returns
url_pattern instance

Definition at line 18 of file implementation-inl.h.

References ada::parser::parse_url_pattern_impl().

Referenced by LLVMFuzzerTestOneInput().

◆ to_string() [1/2]

ada_warn_unused std::string ada::to_string ( ada::state s)

Stringify a URL state machine state.

Definition at line 780 of file helpers.cpp.

References ada_warn_unused, and ada::helpers::get_state().

◆ to_string() [2/2]

◆ unreachable()

Variable Documentation

◆ url_search_params_iter< T, Type >::EMPTY

Definition at line 23 of file url_search_params-inl.h.