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:

## Public Member Functions

virtual | ~url_base ()=default
ada_really_inline constexpr bool | is_special () const noexcept
virtual std::string | get_origin () const =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 | ( |  | ) |

virtual default

## Member Function Documentation

## get_origin()

virtual std::string ada::url_base::get_origin | ( |  | ) | const

nodiscard pure virtual

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

nodiscard pure virtual noexcept

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

nodiscard constexpr noexcept

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

nodiscard pure 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:

- include/ada/url_base.h
- include/ada/url_base-inl.h