Ada 3.4.0
Fast spec-compliant URL parser
Loading...
Searching...
No Matches
url_base.h
Go to the documentation of this file.
1
9#ifndef ADA_URL_BASE_H
10#define ADA_URL_BASE_H
11
12#include "ada/common_defs.h"
13#include "ada/scheme.h"
14
15#include <string>
16#include <string_view>
17
18namespace ada {
19
26enum url_host_type : uint8_t {
30 IPV4 = 1,
32 IPV6 = 2,
33};
34
49struct url_base {
50 virtual ~url_base() = default;
51
56 bool is_valid{true};
57
62 bool has_opaque_path{false};
63
68
74
80 [[nodiscard]] ada_really_inline constexpr bool is_special() const noexcept;
81
87 [[nodiscard]] virtual std::string get_origin() const noexcept = 0;
88
94 [[nodiscard]] virtual bool has_valid_domain() const noexcept = 0;
95
101 [[nodiscard]] inline uint16_t get_special_port() const noexcept;
102
107 [[nodiscard]] ada_really_inline uint16_t scheme_default_port() const noexcept;
108
116 virtual size_t parse_port(std::string_view view,
117 bool check_trailing_content) noexcept = 0;
118
120 virtual ada_really_inline size_t parse_port(std::string_view view) noexcept {
121 return this->parse_port(view, false);
122 }
123
128 [[nodiscard]] virtual std::string to_string() const = 0;
129
131 virtual inline void clear_pathname() = 0;
132
134 virtual inline void clear_search() = 0;
135
137 [[nodiscard]] virtual inline bool has_hash() const noexcept = 0;
138
140 [[nodiscard]] virtual inline bool has_search() const noexcept = 0;
141
142}; // url_base
143
144} // namespace ada
145
146#endif
Cross-platform compiler macros and common definitions.
#define ada_really_inline
Definition common_defs.h:85
type
Enumeration of URL scheme types.
Definition scheme.h:41
@ NOT_SPECIAL
Definition scheme.h:43
Definition ada_idna.h:13
url_host_type
Enum representing the type of host in a URL.
Definition url_base.h:26
@ IPV6
Definition url_base.h:32
@ IPV4
Definition url_base.h:30
@ DEFAULT
Definition url_base.h:28
URL scheme type definitions and utilities.
Abstract base class for URL representations.
Definition url_base.h:49
ada_really_inline constexpr bool is_special() const noexcept
virtual ~url_base()=default
url_host_type host_type
Definition url_base.h:67
virtual bool has_valid_domain() const noexcept=0
bool is_valid
Definition url_base.h:56
virtual std::string get_origin() const noexcept=0
bool has_opaque_path
Definition url_base.h:62
virtual std::string to_string() const =0