Ada 3.4.0
Fast spec-compliant URL parser
Loading...
Searching...
No Matches
ada::url_base Struct Referenceabstract

Abstract base class for URL representations. More...

#include <url_base.h>

Inheritance diagram for ada::url_base:
ada::url ada::url_aggregator

Public Member Functions

virtual ~url_base ()=default
 
ada_really_inline constexpr bool is_special () const noexcept
 
virtual std::string get_origin () const noexcept=0
 
virtual bool has_valid_domain () const noexcept=0
 
virtual std::string to_string () const =0
 

Public Attributes

bool is_valid {true}
 
bool has_opaque_path {false}
 
url_host_type host_type = url_host_type::DEFAULT
 

Detailed Description

Abstract base class for URL representations.

The url_base class provides the common interface and state shared by both ada::url and ada::url_aggregator. It contains basic URL attributes like validity status and scheme type, but delegates component storage and access to derived classes.

Note
This is an abstract class and cannot be instantiated directly. Use ada::url or ada::url_aggregator instead.
See also
url
url_aggregator

Definition at line 49 of file url_base.h.

Constructor & Destructor Documentation

◆ ~url_base()

virtual ada::url_base::~url_base ( )
virtualdefault

Member Function Documentation

◆ get_origin()

virtual std::string ada::url_base::get_origin ( ) const
nodiscardpure virtualnoexcept

Returns the URL's origin (scheme + host + port for special URLs).

Returns
A newly allocated string containing the serialized origin.
See also
https://url.spec.whatwg.org/#concept-url-origin

Implemented in ada::url, and ada::url_aggregator.

References get_origin().

Referenced by get_origin().

◆ has_valid_domain()

virtual bool ada::url_base::has_valid_domain ( ) const
nodiscardpure virtualnoexcept

Validates whether the hostname is a valid domain according to RFC 1034. Checks that the domain and its labels have valid lengths.

Returns
true if the domain is valid, false otherwise.

Implemented in ada::url, and ada::url_aggregator.

References ada_really_inline, and has_valid_domain().

Referenced by has_valid_domain().

◆ is_special()

ada_really_inline constexpr bool ada::url_base::is_special ( ) const
nodiscardconstexprnoexcept

Checks if the URL has a special scheme (http, https, ws, wss, ftp, file). Special schemes have specific parsing rules and default ports.

Returns
true if the scheme is special, false otherwise.

Definition at line 19 of file url_base-inl.h.

References ada_really_inline, and ada::scheme::NOT_SPECIAL.

Referenced by ada::url::get_origin(), ada::url_aggregator::get_origin(), ada::url::get_protocol(), ada::parser::parse_url_impl(), ada::url::set_search(), and ada::url_aggregator::set_search().

◆ to_string()

virtual std::string ada::url_base::to_string ( ) const
nodiscardpure virtual

Returns a JSON string representation of this URL for debugging.

Returns
A JSON-formatted string with URL information.

Implemented in ada::url, and ada::url_aggregator.

Member Data Documentation

◆ has_opaque_path

bool ada::url_base::has_opaque_path {false}

Indicates whether the URL has an opaque path (non-hierarchical). Opaque paths occur in non-special URLs like mailto: or javascript:.

Definition at line 62 of file url_base.h.

Referenced by ada::url::get_components(), ada::url::get_href(), ada::parser::parse_url_impl(), ada::url::set_pathname(), ada::url_aggregator::set_pathname(), ada::url::to_string(), ada::url_aggregator::to_string(), and ada::url_aggregator::validate().

◆ host_type

url_host_type ada::url_base::host_type = url_host_type::DEFAULT

The type of the URL's host (domain, IPv4, or IPv6).

Definition at line 67 of file url_base.h.

◆ is_valid

bool ada::url_base::is_valid {true}

Indicates whether the URL was successfully parsed. Set to false if parsing failed (e.g., invalid URL syntax).

Definition at line 56 of file url_base.h.

Referenced by ada::can_parse(), ada::parser::parse_url_impl(), ada::url::set_port(), ada::url_aggregator::set_port(), ada::url_aggregator::to_diagram(), ada::url::to_string(), ada::url_aggregator::to_string(), and ada::url_aggregator::validate().


The documentation for this struct was generated from the following files: