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

Includes the scheme declarations. More...

Namespaces

namespace  details
 Includes the definitions for scheme specific entities.
 

Enumerations

enum  type : uint8_t {
  HTTP = 0 , NOT_SPECIAL = 1 , HTTPS = 2 , WS = 3 ,
  FTP = 4 , WSS = 5 , FILE = 6
}
 

Functions

constexpr uint16_t get_special_port (std::string_view scheme) noexcept
 
constexpr uint16_t get_special_port (ada::scheme::type type) noexcept
 
constexpr ada::scheme::type get_scheme_type (std::string_view scheme) noexcept
 

Detailed Description

Includes the scheme declarations.

Enumeration Type Documentation

◆ type

enum ada::scheme::type : uint8_t

Type of the scheme as an enum. Using strings to represent a scheme type is not ideal because checking for types involves string comparisons. It is faster to use a simple integer. In C++11, we are allowed to specify the underlying type of the enum. We pick an 8-bit integer (which allows up to 256 types). Specifying the type of the enum may help integration with other systems if the type variable is exposed (since its value will not depend on the compiler).

Enumerator
HTTP 
NOT_SPECIAL 
HTTPS 
WS 
FTP 
WSS 
FILE 

Definition at line 29 of file scheme.h.

Function Documentation

◆ get_scheme_type()

ada::scheme::type ada::scheme::get_scheme_type ( std::string_view scheme)
constexprnoexcept

Returns the scheme of an input, or NOT_SPECIAL if it's not a special scheme defined by the spec.

Definition at line 72 of file scheme-inl.h.

References ada::scheme::details::is_special_list, and NOT_SPECIAL.

◆ get_special_port() [1/2]

uint16_t ada::scheme::get_special_port ( ada::scheme::type type)
constexprnoexcept

Returns the port number of a special scheme.

See also
https://url.spec.whatwg.org/#special-scheme

Definition at line 69 of file scheme-inl.h.

References ada::scheme::details::special_ports.

◆ get_special_port() [2/2]

uint16_t ada::scheme::get_special_port ( std::string_view scheme)
constexprnoexcept

A special scheme is an ASCII string that is listed in the first column of the following table. The default port for a special scheme is listed in the second column on the same row. The default port for any other ASCII string is null.

See also
https://url.spec.whatwg.org/#url-miscellaneous
Parameters
scheme
Returns
The special port

Definition at line 57 of file scheme-inl.h.

References ada::scheme::details::is_special_list, and ada::scheme::details::special_ports.