Loading...
Searching...
No Matches
ada::scheme Namespace Reference

URL scheme utilities and constants. 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 }
| Enumeration of URL scheme types. More...

## 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

URL scheme utilities and constants.

Provides functions for working with URL schemes, including identification of special schemes and retrieval of default port numbers.

## Enumeration Type Documentation

## type

enum ada::scheme::type : uint8_t

Enumeration of URL scheme types.

Special schemes have specific parsing rules and default ports. Using an enum allows efficient scheme comparisons without string operations.

Default ports:

- HTTP: 80
- HTTPS: 443
- WS: 80
- WSS: 443
- FTP: 21
- FILE: (none)

Enumerator
HTTP | http:// scheme (port 80)
NOT_SPECIAL | Non-special scheme (no default port)
HTTPS | https:// scheme (port 443)
WS | ws:// WebSocket scheme (port 80)
FTP | ftp:// scheme (port 21)
WSS | wss:// secure WebSocket scheme (port 443)
FILE | file:// scheme (no default port)

Definition at line 41 of file scheme.h.

## Function Documentation

## get_scheme_type()

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

constexpr noexcept

Converts a scheme string to its type enum.

Parameters

  scheme | The scheme string to convert.

Returns
  The corresponding scheme type, or NOT_SPECIAL if not recognized.

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

References ada::scheme::details::branchless_load5(), ada::scheme::details::is_special_list, NOT_SPECIAL, and ada::scheme::details::scheme_keys.

## get_special_port() [1/2]

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

constexpr noexcept

Returns the default port for a scheme type.

Parameters

  type | The scheme type enum value.

Returns
  The default port number, or 0 if not applicable.

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

Definition at line 104 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 | ) |

constexpr noexcept

Returns the default port for a special scheme string.

Parameters

  scheme | The scheme string (e.g., "http", "https").

Returns
  The default port number, or 0 if not a special scheme.

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

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

References ada::scheme::details::branchless_load5(), ada::scheme::details::is_special_list, ada::scheme::details::scheme_keys, and ada::scheme::details::special_ports.