Loading...
Searching...
No Matches
url_base.h
Go to the documentation of this file.
#ifndef ADA_URL_BASE_H
#define ADA_URL_BASE_H
#include "ada/common_defs.h"
#include "ada/scheme.h"
#include <string>
#include <string_view>
namespace ada {
enum url_host_type : uint8_t {
DEFAULT = 0,
IPV4 = 1,
IPV6 = 2,
};
struct url_base {
virtual ~url_base() = default;
bool is_valid{true};
bool has_opaque_path{false};
url_host_type host_type = url_host_type::DEFAULT;
ada::scheme::type type{ada::scheme::type::NOT_SPECIAL};
[[nodiscard]] ada_really_inline constexpr bool is_special() const noexcept;
[[nodiscard]] virtual std::string get_origin() const = 0;
[[nodiscard]] virtual bool has_valid_domain() const noexcept = 0;
[[nodiscard]] inline uint16_t get_special_port() const noexcept;
[[nodiscard]] ada_really_inline uint16_t scheme_default_port() const noexcept;
virtual size_t parse_port(std::string_view view,
bool check_trailing_content) = 0;
virtual ada_really_inline size_t parse_port(std::string_view view) {
return this->parse_port(view, false);
}
[[nodiscard]] virtual std::string to_string() const = 0;
virtual inline void clear_pathname() = 0;
virtual inline void clear_search() = 0;
[[nodiscard]] virtual inline bool has_hash() const noexcept = 0;
[[nodiscard]] virtual inline bool has_search() const noexcept = 0;
}; // url_base
} // namespace ada
#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