Ada 3.4.0
Fast spec-compliant URL parser
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)
constexprnoexcept

Converts a scheme string to its type enum.

Parameters
schemeThe scheme string to convert.
Returns
The corresponding scheme type, or NOT_SPECIAL if not recognized.

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 default port for a scheme type.

Parameters
typeThe 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 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

Returns the default port for a special scheme string.

Parameters
schemeThe 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 57 of file scheme-inl.h.

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