From d2cd4f86c7b94833779408c3f39d57f4eb370c0b Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Sat, 30 Nov 2024 13:41:29 -0500 Subject: [PATCH] create url_pattern-inl.h --- include/ada.h | 1 + include/ada/url_pattern-inl.h | 64 +++++++++++++++++++++++++++++++++++ include/ada/url_pattern.h | 31 ++++++----------- 3 files changed, 76 insertions(+), 20 deletions(-) create mode 100644 include/ada/url_pattern-inl.h diff --git a/include/ada.h b/include/ada.h index eafbb12d5..54a43fd09 100644 --- a/include/ada.h +++ b/include/ada.h @@ -27,6 +27,7 @@ #include "ada/url_search_params.h" #include "ada/url_search_params-inl.h" #include "ada/url_pattern.h" +#include "ada/url_pattern-inl.h" // Public API #include "ada/ada_version.h" diff --git a/include/ada/url_pattern-inl.h b/include/ada/url_pattern-inl.h new file mode 100644 index 000000000..aa111d537 --- /dev/null +++ b/include/ada/url_pattern-inl.h @@ -0,0 +1,64 @@ +/** + * @file url_pattern-inl.h + * @brief Declaration for the URLPattern inline functions. + */ +#ifndef ADA_URL_PATTERN_INL_H +#define ADA_URL_PATTERN_INL_H + +#include "ada/common_defs.h" +#include "ada/url_pattern.h" + +#include + +namespace ada { +inline std::string_view URLPattern::Component::get_pattern() const noexcept + ada_lifetime_bound { + return pattern; +} + +inline std::string_view URLPattern::Component::get_regex() const noexcept + ada_lifetime_bound { + return regex; +} + +inline const std::vector& URLPattern::Component::get_names() + const noexcept ada_lifetime_bound { + return names; +} + +inline const URLPattern::Component& URLPattern::get_protocol() const + ada_lifetime_bound { + return protocol; +} +inline const URLPattern::Component& URLPattern::get_username() const + ada_lifetime_bound { + return username; +} +inline const URLPattern::Component& URLPattern::get_password() const + ada_lifetime_bound { + return password; +} +inline const URLPattern::Component& URLPattern::get_port() const + ada_lifetime_bound { + return port; +} +inline const URLPattern::Component& URLPattern::get_pathname() const + ada_lifetime_bound { + return pathname; +} +inline const URLPattern::Component& URLPattern::get_search() const + ada_lifetime_bound { + return search; +} +inline const URLPattern::Component& URLPattern::get_hash() const + ada_lifetime_bound { + return hash; +} + +inline bool URLPattern::case_ignored() const ada_lifetime_bound { + return ignore_case; +} + +} // namespace ada + +#endif \ No newline at end of file diff --git a/include/ada/url_pattern.h b/include/ada/url_pattern.h index 8490dc665..5baa7d8d6 100644 --- a/include/ada/url_pattern.h +++ b/include/ada/url_pattern.h @@ -23,17 +23,10 @@ class URLPattern { explicit Component(std::string_view pattern, std::string_view regex, const std::vector& names); - // TODO(anonrig): Move these implementations to `url_pattern-inl.h` - std::string_view get_pattern() const noexcept ada_lifetime_bound { - return pattern; - } - std::string_view get_regex() const noexcept ada_lifetime_bound { - return regex; - } + std::string_view get_pattern() const noexcept ada_lifetime_bound; + std::string_view get_regex() const noexcept ada_lifetime_bound; const std::vector& get_names() const noexcept - ada_lifetime_bound { - return names; - } + ada_lifetime_bound; private: // Disallow copy. @@ -106,19 +99,17 @@ class URLPattern { bool test(std::optional input, std::optional base_url); - // TODO(anonrig): Move these to `url_pattern-inl.h`. - const Component& get_protocol() const ada_lifetime_bound { return protocol; } - const Component& get_username() const ada_lifetime_bound { return username; } - const Component& get_password() const ada_lifetime_bound { return password; } - const Component& get_port() const ada_lifetime_bound { return port; } - const Component& get_pathname() const ada_lifetime_bound { return pathname; } - const Component& get_search() const ada_lifetime_bound { return search; } - const Component& get_hash() const ada_lifetime_bound { return hash; } + const Component& get_protocol() const ada_lifetime_bound; + const Component& get_username() const ada_lifetime_bound; + const Component& get_password() const ada_lifetime_bound; + const Component& get_port() const ada_lifetime_bound; + const Component& get_pathname() const ada_lifetime_bound; + const Component& get_search() const ada_lifetime_bound; + const Component& get_hash() const ada_lifetime_bound; // If ignoreCase is true, the JavaScript regular expression created for each // pattern must use the `vi` flag. Otherwise, they must use the `v` flag. - // TODO(anonrig): Move these to `url_pattern-inl.h`. - bool case_ignored() const ada_lifetime_bound { return ignore_case; } + bool case_ignored() const ada_lifetime_bound; private: Component protocol;