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

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

Namespaces

namespace  known_schemes
 Contains known URI scheme types and objects.

Classes

struct  ghassanpl::decomposed_uri
 Holds the constituents of a URI. More...
struct  ghassanpl::known_uri_scheme
 An base class for classes that can validate (and potentially parse more info from) a known URI scheme (e.g. http, file, ftp, etc.). More...
struct  ghassanpl::known_schemes::file_scheme
 The "file:" known scheme. More...
struct  ghassanpl::uri_builder
 [Unimplemented] More...

Typedefs

using ghassanpl::uri
 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
template<typename T>
using ghassanpl::uri_expected
using ghassanpl::uri_error

Enumerations

enum class  ghassanpl::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
}
 Error codes relating to URI decomposing, composing, and other operations. More...
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 , query_known_scheme , validate_known_scheme
}
 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< std::string_view > ghassanpl::extract_scheme (uri_view uri) noexcept
uri_expected< std::string_view > ghassanpl::extract_authority (uri_view uri) noexcept
 [Unimplemented]
uri_expected< std::string_view > ghassanpl::extract_path (uri_view uri) noexcept
 [Unimplemented]
template<typename FUNC>
uri_expected< void > ghassanpl::extract_path_elements (uri_view uri, FUNC &&func) noexcept
 [Unimplemented]
uri_expected< std::string_view > ghassanpl::extract_query (uri_view uri) noexcept
 [Unimplemented]
uri_expected< std::string_view > ghassanpl::extract_fragment (uri_view uri) noexcept
 [Unimplemented]
template<typename FUNC>
uri_expected< void > ghassanpl::extract_query_elements (uri_view uri, FUNC &&func) noexcept
 [Unimplemented]
uri_expected< uri > ghassanpl::make_uri_safe_for_display (uri_view uri)
 [Unimplemented] Removes data that should not be displayed to an untrusted user (user-info after the first ':', perhaps other things)
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.
uri_expected< uri > ghassanpl::compose_uri (decomposed_uri const &decomposed, enum_flags< uri_compose_flags > flags=enum_flags< uri_compose_flags >::all())
 [Unimplemented]
uri_expected< uri > ghassanpl::normalize_uri (uri_view uri)
 [Unimplemented] Converts a URI to a normalized form
known_uri_scheme const * ghassanpl::query_uri_scheme (std::string_view scheme)
 Looks up the scheme in the internal URI scheme database.

Detailed Description

Basic functionality for URI encoding and decoding.

Unfortunately a lot of the functionality here, except basic URI parsing, is unimplemented.

Typedef Documentation

◆ uri

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

Definition at line 87 of file uri.h.

◆ uri_expected

template<typename T>
using ghassanpl::uri_expected

Definition at line 86 of file uri.h.

◆ uri_view

using ghassanpl::uri_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 172 of file uri.h.

◆ uri_decompose_flags

enum class ghassanpl::uri_decompose_flags
strong

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 90 of file uri.h.

◆ uri_error_code

enum class ghassanpl::uri_error_code
strong

Error codes relating to URI decomposing, composing, and other operations.

Definition at line 35 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 257 of file uri_impl.h.

◆ extract_scheme()

uri_expected< std::string_view > ghassanpl::extract_scheme ( uri_view uri)
noexcept

Definition at line 246 of file uri_impl.h.

◆ query_uri_scheme()

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

Looks up the scheme in the internal URI scheme database.

Definition at line 395 of file uri_impl.h.