Ada 2.7.8
Fast spec-compliant URL parser
Loading...
Searching...
No Matches
url_aggregator.h
Go to the documentation of this file.
1
5#ifndef ADA_URL_AGGREGATOR_H
6#define ADA_URL_AGGREGATOR_H
7
8#include "ada/common_defs.h"
9#include "ada/url_base.h"
10#include "ada/url_components.h"
11
12#include <string>
13#include <string_view>
14
15namespace ada {
16
26 url_aggregator() = default;
27 url_aggregator(const url_aggregator &u) = default;
28 url_aggregator(url_aggregator &&u) noexcept = default;
29 url_aggregator &operator=(url_aggregator &&u) noexcept = default;
31 ~url_aggregator() override = default;
32
33 bool set_href(std::string_view input);
34 bool set_host(std::string_view input);
35 bool set_hostname(std::string_view input);
36 bool set_protocol(std::string_view input);
37 bool set_username(std::string_view input);
38 bool set_password(std::string_view input);
39 bool set_port(std::string_view input);
40 bool set_pathname(std::string_view input);
41 void set_search(std::string_view input);
42 void set_hash(std::string_view input);
43
136
142
169 [[nodiscard]] std::string to_string() const override;
173 [[nodiscard]] std::string to_diagram() const;
174
180 [[nodiscard]] bool validate() const noexcept;
181
198
199 inline void clear_port();
200 inline void clear_hash();
202
203 private:
208
209 std::string buffer{};
210 url_components components{};
211
217 [[nodiscard]] ada_really_inline bool is_at_path() const noexcept;
218
219 inline void add_authority_slashes_if_needed() noexcept;
220
225 inline void reserve(uint32_t capacity);
226
227 ada_really_inline size_t parse_port(
229
230 ada_really_inline size_t parse_port(std::string_view view) noexcept override {
231 return this->parse_port(view, false);
232 }
233
240 [[nodiscard]] bool parse_ipv4(std::string_view input, bool in_place);
241
246 [[nodiscard]] bool parse_ipv6(std::string_view input);
247
252 [[nodiscard]] bool parse_opaque_host(std::string_view input);
253
254 ada_really_inline void parse_path(std::string_view input);
255
260 [[nodiscard]] inline bool cannot_have_credentials_or_port() const;
261
262 template <bool override_hostname = false>
263 bool set_host_or_hostname(std::string_view input);
264
265 ada_really_inline bool parse_host(std::string_view input);
266
267 inline void update_base_authority(std::string_view base_buffer,
268 const ada::url_components &base);
269 inline void update_unencoded_base_hash(std::string_view input);
270 inline void update_base_hostname(std::string_view input);
271 inline void update_base_search(std::string_view input);
272 inline void update_base_search(std::string_view input,
274 inline void update_base_pathname(std::string_view input);
275 inline void update_base_username(std::string_view input);
276 inline void append_base_username(std::string_view input);
277 inline void update_base_password(std::string_view input);
278 inline void append_base_password(std::string_view input);
279 inline void update_base_port(uint32_t input);
280 inline void append_base_pathname(std::string_view input);
281 [[nodiscard]] inline uint32_t retrieve_base_port() const;
282 inline void clear_hostname();
283 inline void clear_password();
284 inline void clear_pathname() override;
285 [[nodiscard]] inline bool has_dash_dot() const noexcept;
286 void delete_dash_dot();
287 inline void consume_prepared_path(std::string_view input);
289 [[nodiscard]] ada_really_inline bool parse_scheme_with_colon(
291 ada_really_inline uint32_t replace_and_resize(uint32_t start, uint32_t end,
293 [[nodiscard]] inline bool has_authority() const noexcept;
294 inline void set_protocol_as_file();
295 inline void set_scheme(std::string_view new_scheme) noexcept;
300 inline void set_scheme_from_view_with_colon(
302 inline void copy_scheme(const url_aggregator &u) noexcept;
303
304}; // url_aggregator
305
307} // namespace ada
308
309#endif
Common definitions for cross-platform compiler support.
#define ada_really_inline
Definition common_defs.h:84
Definition ada_idna.h:13
ada_warn_unused ada::result< result_type > parse(std::string_view input, const result_type *base_url=nullptr)
Lightweight URL struct.
url_aggregator & operator=(const url_aggregator &u)=default
url_aggregator & operator=(url_aggregator &&u) noexcept=default
bool has_non_empty_username() const noexcept
std::string_view get_pathname() const noexcept
ada_really_inline const ada::url_components & get_components() const noexcept
void set_hash(std::string_view input)
void clear_search() override
url_aggregator()=default
std::string_view get_host() const noexcept
bool has_hostname() const noexcept
bool has_non_empty_password() const noexcept
friend void ada::helpers::strip_trailing_spaces_from_opaque_path(ada::url_aggregator &url) noexcept
ada_really_inline bool has_credentials() const noexcept
friend ada::url_aggregator ada::parser::parse_url(std::string_view, const ada::url_aggregator *)
std::string_view get_search() const noexcept
std::string_view get_username() const noexcept
std::string to_string() const override
bool has_empty_hostname() const noexcept
bool has_search() const noexcept override
std::string to_diagram() const
bool set_protocol(std::string_view input)
std::string get_origin() const noexcept override
bool validate() const noexcept
std::string_view get_protocol() const noexcept
bool has_password() const noexcept
std::string_view get_port() const noexcept
std::string_view get_hostname() const noexcept
ada_really_inline uint32_t get_pathname_length() const noexcept
bool has_valid_domain() const noexcept override
bool set_hostname(std::string_view input)
std::string_view get_href() const noexcept
bool set_password(std::string_view input)
~url_aggregator() override=default
bool set_pathname(std::string_view input)
std::string_view get_password() const noexcept
bool has_hash() const noexcept override
bool set_href(std::string_view input)
void set_search(std::string_view input)
bool has_port() const noexcept
url_aggregator(url_aggregator &&u) noexcept=default
std::string_view get_hash() const noexcept
bool set_host(std::string_view input)
bool set_port(std::string_view input)
url_aggregator(const url_aggregator &u)=default
bool set_username(std::string_view input)
Base class of URL implementations.
Definition url_base.h:44
URL Component representations using offsets.
Generic URL struct reliant on std::string instantiation.
Definition url.h:38
Declaration for the basic URL definitions.
Declaration for the URL Components.