header_utils
Loading...
Searching...
No Matches
URI

Basic functionality for URI encoding and decoding. More...

Classes

struct  ghassanpl::decomposed_uri
 Holds the constituents of a URI. More...
 

Typedefs

using ghassanpl::uri = std::string
 URIs are stored in a UTF-8 encoding where both non-ASCII code unit bytes as well as URI-reserved characters (delimiters, etc) are %-encoded.
 
using ghassanpl::uri_view = std::string_view
 
template<typename T >
using ghassanpl::uri_expected = expected< T, uri_error_code >
 
using ghassanpl::uri_error = expected< void, uri_error_code >
 

Enumerations

enum class  uri_error_code {
  no_error , unknown_uri_scheme , scheme_malformed , scheme_invalid ,
  scheme_empty , authority_malformed , authority_empty , authority_not_allowed_in_scheme ,
  authority_invalid_for_scheme , authority_required_in_scheme , user_info_malformed , user_info_not_allowed_in_scheme ,
  user_info_invalid_for_scheme , user_info_required_in_scheme , host_malformed , host_not_allowed_in_scheme ,
  host_invalid_for_scheme , host_required_in_scheme , port_malformed , port_not_allowed_in_scheme ,
  port_invalid_for_scheme , port_required_in_scheme , path_malformed , path_element_malformed ,
  query_malformed , query_not_allowed_in_scheme , query_invalid_for_scheme , query_required_in_scheme ,
  fragment_malformed , fragment_not_allowed_in_scheme , fragment_invalid_for_scheme , fragment_required_in_scheme ,
  invalid_percent_encoding , no_scheme_specific_elements , scheme_specific_element_malformed
}
 
enum class  ghassanpl::uri_decompose_flags {
  split_query_elements , split_path_elements , ghassanpl::uri_decompose_flags::use_well_known_port_numbers , lowercase_when_appropriate ,
  normalize_path
}
 Flags that modify how a URI string is decomposed into ghassanpl::decomposed_uri. More...
 
enum class  uri_compose_flags {
  path_leading_slash , path_trailing_slash , lowercase_when_appropriate , normalize_path ,
  use_known_scheme
}
 

Functions

uri_expected< urighassanpl::make_uri_safe_for_display (uri_view uri)
 Removes data that should not be displayed to an untrusted user (user-info after the first ':', perhaps other things)
 
uri_expected< decomposed_urighassanpl::decompose_uri (uri_view uri, enum_flags< uri_decompose_flags > flags=enum_flags< uri_decompose_flags >::all())
 This function will decompose URI into its composite elements, which includes percent-decoding all the elements.
 
uri_expected< urighassanpl::compose_uri (decomposed_uri const &decomposed, enum_flags< uri_compose_flags > flags=enum_flags< uri_compose_flags >::all())
 
uri_expected< urighassanpl::normalize_uri (uri_view uri)
 
known_uri_scheme constghassanpl::query_uri_scheme (std::string_view scheme)
 

Detailed Description

Basic functionality for URI encoding and decoding.

Typedef Documentation

◆ uri

using ghassanpl::uri = typedef std::string

URIs are stored in a UTF-8 encoding where both non-ASCII code unit bytes as well as URI-reserved characters (delimiters, etc) are %-encoded.

Definition at line 28 of file uri.h.

◆ uri_error

using ghassanpl::uri_error = typedef expected<void, uri_error_code>

Definition at line 112 of file uri.h.

◆ uri_expected

template<typename T >
using ghassanpl::uri_expected = typedef expected<T, uri_error_code>

Definition at line 111 of file uri.h.

◆ uri_view

using ghassanpl::uri_view = typedef std::string_view

Definition at line 29 of file uri.h.

Enumeration Type Documentation

◆ uri_compose_flags

enum class ghassanpl::uri_compose_flags
strong

Definition at line 133 of file uri.h.

◆ uri_decompose_flags

Flags that modify how a URI string is decomposed into ghassanpl::decomposed_uri.

Enumerator
use_well_known_port_numbers 

if a port is not specified in the uri, the result will guess the port based on the scheme

Definition at line 118 of file uri.h.

◆ uri_error_code

enum class ghassanpl::uri_error_code
strong

Definition at line 31 of file uri.h.

Function Documentation

◆ decompose_uri()

uri_expected< decomposed_uri > ghassanpl::decompose_uri ( uri_view  uri,
enum_flags< uri_decompose_flags flags = enum_flags<uri_decompose_flags>::all() 
)

This function will decompose URI into its composite elements, which includes percent-decoding all the elements.

Definition at line 243 of file uri_impl.h.

◆ query_uri_scheme()

known_uri_scheme const * ghassanpl::query_uri_scheme ( std::string_view  scheme)

Definition at line 371 of file uri_impl.h.