Ada 4.1.1
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 <cstddef>
16#include <cstdint>
17#include <string>
18#include <string_view>
19
20namespace ada {
21
28enum url_host_type : uint8_t {
32 IPV4 = 1,
34 IPV6 = 2,
35};
36
51struct url_base {
52 virtual ~url_base() = default;
53
58 bool is_valid{true};
59
64 bool has_opaque_path{false};
65
70
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
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:43
@ NOT_SPECIAL
Definition scheme.h:45
url_host_type
Enum representing the type of host in a URL.
Definition url_base.h:28
@ IPV6
Definition url_base.h:34
@ IPV4
Definition url_base.h:32
@ DEFAULT
Definition url_base.h:30
URL scheme type definitions and utilities.
Abstract base class for URL representations.
Definition url_base.h:51
ada_really_inline constexpr bool is_special() const noexcept
virtual ~url_base()=default
virtual std::string get_origin() const =0
url_host_type host_type
Definition url_base.h:69
virtual bool has_valid_domain() const noexcept=0
bool is_valid
Definition url_base.h:58
bool has_opaque_path
Definition url_base.h:64
virtual std::string to_string() const =0