From 307facfaa88f954ba6135796d22f9548c12956d3 Mon Sep 17 00:00:00 2001 From: alandefreitas Date: Thu, 15 Sep 2022 13:49:45 -0300 Subject: [PATCH] authority view string token fix #546 --- include/boost/url/authority_view.hpp | 78 +++++++++++++++++------ include/boost/url/impl/authority_view.ipp | 54 ---------------- 2 files changed, 60 insertions(+), 72 deletions(-) diff --git a/include/boost/url/authority_view.hpp b/include/boost/url/authority_view.hpp index d264a333..60dd1d60 100644 --- a/include/boost/url/authority_view.hpp +++ b/include/boost/url/authority_view.hpp @@ -349,9 +349,16 @@ public: @ref password, @ref user. */ - BOOST_URL_DECL - std::string - userinfo() const; + template + BOOST_URL_STRTOK_RETURN + userinfo( + BOOST_URL_STRTOK_ARG(token)) const + { + decode_opts opt; + opt.plus_to_space = false; + return encoded_userinfo().decode( + opt, std::move(token)); + } /** Return the userinfo @@ -440,9 +447,16 @@ public: @ref password, @ref userinfo. */ - BOOST_URL_DECL - std::string - user() const; + template + BOOST_URL_STRTOK_RETURN + user( + BOOST_URL_STRTOK_ARG(token)) const + { + decode_opts opt; + opt.plus_to_space = false; + return encoded_user().decode( + opt, std::move(token)); + } /** Return the user @@ -572,9 +586,16 @@ public: @ref user, @ref userinfo. */ - BOOST_URL_DECL - std::string - password() const; + template + BOOST_URL_STRTOK_RETURN + password( + BOOST_URL_STRTOK_ARG(token)) const + { + decode_opts opt; + opt.plus_to_space = false; + return encoded_password().decode( + opt, std::move(token)); + } /** Return the password @@ -687,9 +708,16 @@ public: @li 3.2.2. Host (rfc3986) */ - BOOST_URL_DECL - std::string - host() const; + template + BOOST_URL_STRTOK_RETURN + host( + BOOST_URL_STRTOK_ARG(token)) const + { + decode_opts opt; + opt.plus_to_space = false; + return encoded_host().decode( + opt, std::move(token)); + } /** Return the host @@ -776,9 +804,16 @@ public: @li 3.2.2. Host (rfc3986) */ - BOOST_URL_DECL - std::string - host_address() const; + template + BOOST_URL_STRTOK_RETURN + host_address( + BOOST_URL_STRTOK_ARG(token)) const + { + decode_opts opt; + opt.plus_to_space = false; + return encoded_host_address().decode( + opt, std::move(token)); + } /** Return the host @@ -990,9 +1025,16 @@ public: @li 3.2.2. Host (rfc3986) */ - BOOST_URL_DECL - std::string - host_name() const; + template + BOOST_URL_STRTOK_RETURN + host_name( + BOOST_URL_STRTOK_ARG(token)) const + { + decode_opts opt; + opt.plus_to_space = false; + return encoded_host_name().decode( + opt, std::move(token)); + } /** Return the host name diff --git a/include/boost/url/impl/authority_view.ipp b/include/boost/url/impl/authority_view.ipp index fcc9f2c1..630263fc 100644 --- a/include/boost/url/impl/authority_view.ipp +++ b/include/boost/url/impl/authority_view.ipp @@ -91,15 +91,6 @@ has_userinfo() const noexcept return true; } -std::string -authority_view:: -userinfo() const -{ - decode_opts opt; - opt.plus_to_space = false; - return encoded_userinfo().decode(opt); -} - pct_string_view authority_view:: encoded_userinfo() const noexcept @@ -114,15 +105,6 @@ encoded_userinfo() const noexcept return detail::make_pct_string_view(s); } -std::string -authority_view:: -user() const -{ - decode_opts opt; - opt.plus_to_space = false; - return encoded_user().decode(opt); -} - pct_string_view authority_view:: encoded_user() const noexcept @@ -150,15 +132,6 @@ has_password() const noexcept return false; } -std::string -authority_view:: -password() const -{ - decode_opts opt; - opt.plus_to_space = false; - return encoded_password().decode(opt); -} - pct_string_view authority_view:: encoded_password() const noexcept @@ -203,15 +176,6 @@ std::string host_name() // return decoded name or "" pct_string_view encoded_host_name() // return encoded host name or "" */ -std::string -authority_view:: -host() const -{ - decode_opts opt; - opt.plus_to_space = false; - return encoded_host().decode(opt); -} - pct_string_view authority_view:: encoded_host() const noexcept @@ -221,15 +185,6 @@ encoded_host() const noexcept u_.decoded_[id_host]); } -std::string -authority_view:: -host_address() const -{ - decode_opts opt; - opt.plus_to_space = false; - return encoded_host_address().decode(opt); -} - pct_string_view authority_view:: encoded_host_address() const noexcept @@ -307,15 +262,6 @@ host_ipvfuture() const noexcept return s; } -std::string -authority_view:: -host_name() const -{ - decode_opts opt; - opt.plus_to_space = false; - return encoded_host_name().decode(opt); -} - pct_string_view authority_view:: encoded_host_name() const noexcept