Ada 2.9.2
Fast spec-compliant URL parser
Loading...
Searching...
No Matches
url_base.h
Go to the documentation of this file.
1
5#ifndef ADA_URL_BASE_H
6#define ADA_URL_BASE_H
7
8#include "ada/common_defs.h"
10#include "ada/scheme.h"
11
12#include <string_view>
13
14namespace ada {
15
19enum url_host_type : uint8_t {
27 IPV4 = 1,
32 IPV6 = 2,
33};
34
44struct url_base {
45 virtual ~url_base() = default;
46
50 bool is_valid{true};
51
55 bool has_opaque_path{false};
56
61
66
71 [[nodiscard]] ada_really_inline constexpr bool is_special() const noexcept;
72
79 [[nodiscard]] virtual std::string get_origin() const noexcept = 0;
80
86 [[nodiscard]] virtual bool has_valid_domain() const noexcept = 0;
87
94 [[nodiscard]] inline uint16_t get_special_port() const noexcept;
95
101 [[nodiscard]] ada_really_inline uint16_t scheme_default_port() const noexcept;
102
114 virtual size_t parse_port(std::string_view view,
115 bool check_trailing_content) noexcept = 0;
116
117 virtual ada_really_inline size_t parse_port(std::string_view view) noexcept {
118 return this->parse_port(view, false);
119 }
120
124 [[nodiscard]] virtual std::string to_string() const = 0;
125
127 virtual inline void clear_pathname() = 0;
128
130 virtual inline void clear_search() = 0;
131
133 [[nodiscard]] virtual inline bool has_hash() const noexcept = 0;
134
136 [[nodiscard]] virtual inline bool has_search() const noexcept = 0;
137
138}; // url_base
139
140} // namespace ada
141
142#endif
Common definitions for cross-platform compiler support.
#define ada_really_inline
Definition common_defs.h:77
@ NOT_SPECIAL
Definition scheme.h:31
Definition ada_idna.h:13
url_host_type
Definition url_base.h:19
@ IPV6
Definition url_base.h:32
@ IPV4
Definition url_base.h:27
@ DEFAULT
Definition url_base.h:23
Declarations for the URL scheme.
Base class of URL implementations.
Definition url_base.h:44
ada_really_inline constexpr bool is_special() const noexcept
virtual ~url_base()=default
url_host_type host_type
Definition url_base.h:60
virtual bool has_valid_domain() const noexcept=0
bool is_valid
Definition url_base.h:50
virtual std::string get_origin() const noexcept=0
bool has_opaque_path
Definition url_base.h:55
virtual std::string to_string() const =0
Declaration for the URL Components.