Ada
3.4.3
Fast spec-compliant URL parser
Toggle main menu visibility
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
18
namespace
ada
{
19
26
enum
url_host_type
: uint8_t {
28
DEFAULT
= 0,
30
IPV4
= 1,
32
IPV6
= 2,
33
};
34
49
struct
url_base
{
50
virtual
~url_base
() =
default
;
51
56
bool
is_valid
{
true
};
57
62
bool
has_opaque_path
{
false
};
63
67
url_host_type
host_type
=
url_host_type::DEFAULT
;
68
73
ada::scheme::type
type{
ada::scheme::type::NOT_SPECIAL
};
74
80
[[nodiscard]]
ada_really_inline
constexpr
bool
is_special
() const noexcept;
81
87
[[nodiscard]] virtual std::
string
get_origin
() const = 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) = 0;
118
120
virtual
ada_really_inline
size_t
parse_port(std::string_view view) {
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
common_defs.h
Cross-platform compiler macros and common definitions.
ada_really_inline
#define ada_really_inline
Definition
common_defs.h:85
ada::scheme::type
type
Enumeration of URL scheme types.
Definition
scheme.h:41
ada::scheme::NOT_SPECIAL
@ NOT_SPECIAL
Definition
scheme.h:43
ada
Definition
ada_idna.h:13
ada::url_host_type
url_host_type
Enum representing the type of host in a URL.
Definition
url_base.h:26
ada::IPV6
@ IPV6
Definition
url_base.h:32
ada::IPV4
@ IPV4
Definition
url_base.h:30
ada::DEFAULT
@ DEFAULT
Definition
url_base.h:28
scheme.h
URL scheme type definitions and utilities.
ada::url_base
Abstract base class for URL representations.
Definition
url_base.h:49
ada::url_base::is_special
ada_really_inline constexpr bool is_special() const noexcept
Definition
url_base-inl.h:19
ada::url_base::~url_base
virtual ~url_base()=default
ada::url_base::get_origin
virtual std::string get_origin() const =0
ada::url_base::host_type
url_host_type host_type
Definition
url_base.h:67
ada::url_base::has_valid_domain
virtual bool has_valid_domain() const noexcept=0
ada::url_base::is_valid
bool is_valid
Definition
url_base.h:56
ada::url_base::has_opaque_path
bool has_opaque_path
Definition
url_base.h:62
ada::url_base::to_string
virtual std::string to_string() const =0