Ada
4.1.1
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 <cstddef>
16
#include <cstdint>
17
#include <string>
18
#include <string_view>
19
20
namespace
ada
{
21
28
enum
url_host_type
: uint8_t {
30
DEFAULT
= 0,
32
IPV4
= 1,
34
IPV6
= 2,
35
};
36
51
struct
url_base
{
52
virtual
~url_base
() =
default
;
53
58
bool
is_valid
{
true
};
59
64
bool
has_opaque_path
{
false
};
65
69
url_host_type
host_type
=
url_host_type::DEFAULT
;
70
75
ada::scheme::type
type{
ada::scheme::type::NOT_SPECIAL
};
76
82
[[nodiscard]]
ada_really_inline
constexpr
bool
is_special
() const noexcept;
83
89
[[nodiscard]] virtual std::
string
get_origin
() const = 0;
90
96
[[nodiscard]] virtual
bool
has_valid_domain
() const noexcept = 0;
97
103
[[nodiscard]] inline uint16_t get_special_port() const noexcept;
104
109
[[nodiscard]]
ada_really_inline
uint16_t scheme_default_port() const noexcept;
110
118
virtual
size_t
parse_port(std::string_view view,
119
bool
check_trailing_content) = 0;
120
122
virtual
ada_really_inline
size_t
parse_port(std::string_view view) {
123
return
this->parse_port(view,
false
);
124
}
125
130
[[nodiscard]]
virtual
std::string
to_string
()
const
= 0;
131
133
virtual
inline
void
clear_pathname() = 0;
134
136
virtual
inline
void
clear_search() = 0;
137
139
[[nodiscard]]
virtual
inline
bool
has_hash() const noexcept = 0;
140
142
[[nodiscard]] virtual inline
bool
has_search() const noexcept = 0;
143
144
};
// url_base
145
146
}
// namespace ada
147
148
#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:43
ada::scheme::NOT_SPECIAL
@ NOT_SPECIAL
Definition
scheme.h:45
ada
Definition
identifier.h:7
ada::url_host_type
url_host_type
Enum representing the type of host in a URL.
Definition
url_base.h:28
ada::IPV6
@ IPV6
Definition
url_base.h:34
ada::IPV4
@ IPV4
Definition
url_base.h:32
ada::DEFAULT
@ DEFAULT
Definition
url_base.h:30
scheme.h
URL scheme type definitions and utilities.
ada::url_base
Abstract base class for URL representations.
Definition
url_base.h:51
ada::url_base::is_special
ada_really_inline constexpr bool is_special() const noexcept
Definition
url_base-inl.h:20
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:69
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:58
ada::url_base::has_opaque_path
bool has_opaque_path
Definition
url_base.h:64
ada::url_base::to_string
virtual std::string to_string() const =0