mirror of
https://github.com/boostorg/url.git
synced 2026-02-21 15:32:13 +00:00
track url_impl source
This commit is contained in:
@@ -42,7 +42,7 @@ apply_userinfo(
|
||||
{
|
||||
// this function is for
|
||||
// authority_view_rule only
|
||||
BOOST_ASSERT(is_authority);
|
||||
BOOST_ASSERT(from_ == from::authority);
|
||||
|
||||
// userinfo
|
||||
set_size(id_user, user.size());
|
||||
@@ -71,7 +71,7 @@ apply_host(
|
||||
{
|
||||
// this function is for
|
||||
// authority_view_rule only
|
||||
BOOST_ASSERT(is_authority);
|
||||
BOOST_ASSERT(from_ == from::authority);
|
||||
|
||||
// host, port
|
||||
host_type_ = ht;
|
||||
@@ -92,7 +92,7 @@ apply_port(
|
||||
{
|
||||
// this function is for
|
||||
// authority_view_rule only
|
||||
BOOST_ASSERT(is_authority);
|
||||
BOOST_ASSERT(from_ == from::authority);
|
||||
|
||||
port_number_ = pn;
|
||||
set_size(id_port, 1 + s.size());
|
||||
@@ -103,12 +103,12 @@ url_impl::
|
||||
apply_authority(
|
||||
authority_view const& a) noexcept
|
||||
{
|
||||
BOOST_ASSERT(! is_authority);
|
||||
BOOST_ASSERT(from_ != from::authority);
|
||||
|
||||
// userinfo
|
||||
set_size(id_user,
|
||||
a.u_.len(id_user) +
|
||||
(is_authority ? 0 : 2));
|
||||
(from_ == from::authority ? 0 : 2));
|
||||
set_size(id_pass, a.u_.len(id_pass));
|
||||
decoded_[id_user] = a.u_.decoded_[id_user];
|
||||
decoded_[id_pass] = a.u_.decoded_[id_pass];
|
||||
@@ -165,8 +165,19 @@ apply_frag(
|
||||
path_ref::
|
||||
path_ref(
|
||||
url_impl const& impl) noexcept
|
||||
: impl_(&impl)
|
||||
{
|
||||
if(impl.from_ == url_impl::from::url)
|
||||
{
|
||||
impl_ = &impl;
|
||||
}
|
||||
else
|
||||
{
|
||||
string_view s = impl.get(id_path);
|
||||
data_ = s.data();
|
||||
size_ = s.size();
|
||||
nseg_ = impl.nseg_;
|
||||
dn_ = impl.decoded_[id_path];
|
||||
}
|
||||
}
|
||||
|
||||
path_ref::
|
||||
@@ -254,8 +265,24 @@ query_ref(
|
||||
query_ref::
|
||||
query_ref(
|
||||
url_impl const& impl) noexcept
|
||||
: impl_(&impl)
|
||||
{
|
||||
if(impl.from_ == url_impl::from::url)
|
||||
{
|
||||
impl_ = &impl;
|
||||
}
|
||||
else
|
||||
{
|
||||
string_view s = impl.get(id_query);
|
||||
if (!s.empty())
|
||||
{
|
||||
s.remove_prefix(1);
|
||||
question_mark_ = true;
|
||||
}
|
||||
data_ = s.data();
|
||||
size_ = s.size();
|
||||
nparam_ = impl.nparam_;
|
||||
dn_ = impl.decoded_[id_query];
|
||||
}
|
||||
}
|
||||
|
||||
pct_string_view
|
||||
@@ -294,7 +321,7 @@ size() const noexcept
|
||||
return impl_->len(id_query);
|
||||
if(size_ > 0)
|
||||
return size_ + 1;
|
||||
return 0;
|
||||
return question_mark_;
|
||||
}
|
||||
|
||||
// no '?'
|
||||
|
||||
@@ -32,6 +32,18 @@ struct parts_base
|
||||
id_frag, // leading '#'
|
||||
id_end // one past the end
|
||||
};
|
||||
|
||||
enum class from : char {
|
||||
// this belongs to a string
|
||||
string,
|
||||
// this belongs to url_base
|
||||
// segments/params containers point to
|
||||
// another url
|
||||
url,
|
||||
// this belongs to authority_view
|
||||
// id_user will not have the leading "//"
|
||||
authority,
|
||||
};
|
||||
};
|
||||
|
||||
} // detail
|
||||
|
||||
@@ -52,15 +52,11 @@ struct url_impl : parts_base
|
||||
scheme scheme_ =
|
||||
urls::scheme::none;
|
||||
|
||||
// true if this belongs to
|
||||
// authority_view. in this case id_user
|
||||
// will not have the leading "//".
|
||||
bool is_authority;
|
||||
from from_ = from::string;
|
||||
|
||||
explicit
|
||||
url_impl(
|
||||
bool b) noexcept
|
||||
: is_authority(b)
|
||||
from b) noexcept
|
||||
: from_(b)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -152,6 +148,7 @@ class query_ref
|
||||
std::size_t size_ = 0;
|
||||
std::size_t nparam_ = 0;
|
||||
std::size_t dn_ = 0;
|
||||
bool question_mark_ = false;
|
||||
|
||||
public:
|
||||
query_ref(
|
||||
|
||||
@@ -51,7 +51,7 @@ authority_view::
|
||||
|
||||
authority_view::
|
||||
authority_view() noexcept
|
||||
: u_(true)
|
||||
: u_(from::authority)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace urls {
|
||||
params_encoded_ref::
|
||||
params_encoded_ref(
|
||||
url_base& u) noexcept
|
||||
: params_encoded_base(u.u_)
|
||||
: params_encoded_base(u.impl_)
|
||||
, u_(&u)
|
||||
{
|
||||
}
|
||||
@@ -229,7 +229,7 @@ find_impl(
|
||||
pct_string_view key,
|
||||
ignore_case_param ic) const noexcept
|
||||
{
|
||||
detail::params_iter_impl end_(u_->u_, 0);
|
||||
detail::params_iter_impl end_(u_->impl_, 0);
|
||||
if(! ic)
|
||||
{
|
||||
for(;;)
|
||||
@@ -259,13 +259,13 @@ find_last_impl(
|
||||
pct_string_view key,
|
||||
ignore_case_param ic) const noexcept
|
||||
{
|
||||
detail::params_iter_impl begin_(u_->u_);
|
||||
detail::params_iter_impl begin_(u_->impl_);
|
||||
if(! ic)
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
if(it.equal(begin_))
|
||||
return { u_->u_, 0 };
|
||||
return { u_->impl_, 0 };
|
||||
it.decrement();
|
||||
if(*it.key() == *key)
|
||||
return it;
|
||||
@@ -274,7 +274,7 @@ find_last_impl(
|
||||
for(;;)
|
||||
{
|
||||
if(it.equal(begin_))
|
||||
return { u_->u_, 0 };
|
||||
return { u_->impl_, 0 };
|
||||
it.decrement();
|
||||
if(grammar::ci_is_equal(
|
||||
*it.key(), *key))
|
||||
|
||||
@@ -24,7 +24,7 @@ inline
|
||||
params_ref::
|
||||
params_ref(
|
||||
url_base& u) noexcept
|
||||
: params_base(u.u_)
|
||||
: params_base(u.impl_)
|
||||
, u_(&u)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ find_impl(
|
||||
string_view key,
|
||||
ignore_case_param ic) const noexcept
|
||||
{
|
||||
detail::params_iter_impl end_(u_->u_, 0);
|
||||
detail::params_iter_impl end_(u_->impl_, 0);
|
||||
if(! ic)
|
||||
{
|
||||
for(;;)
|
||||
@@ -243,13 +243,13 @@ find_last_impl(
|
||||
string_view key,
|
||||
ignore_case_param ic) const noexcept
|
||||
{
|
||||
detail::params_iter_impl begin_(u_->u_);
|
||||
detail::params_iter_impl begin_(u_->impl_);
|
||||
if(! ic)
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
if(it.equal(begin_))
|
||||
return { u_->u_, 0 };
|
||||
return { u_->impl_, 0 };
|
||||
it.decrement();
|
||||
if(*it.key() == key)
|
||||
return it;
|
||||
@@ -258,7 +258,7 @@ find_last_impl(
|
||||
for(;;)
|
||||
{
|
||||
if(it.equal(begin_))
|
||||
return { u_->u_, 0 };
|
||||
return { u_->impl_, 0 };
|
||||
it.decrement();
|
||||
if(grammar::ci_is_equal(
|
||||
*it.key(), key))
|
||||
|
||||
@@ -28,7 +28,7 @@ segments_encoded_ref::
|
||||
segments_encoded_ref(
|
||||
url_base& u) noexcept
|
||||
: segments_encoded_base(
|
||||
detail::path_ref(u.u_))
|
||||
detail::path_ref(u.impl_))
|
||||
, u_(&u)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ segments_ref::
|
||||
segments_ref(
|
||||
url_base& u) noexcept
|
||||
: segments_base(
|
||||
detail::path_ref(u.u_))
|
||||
detail::path_ref(u.impl_))
|
||||
, u_(&u)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ static_url_base(
|
||||
s_ = buf;
|
||||
cap_ = cap;
|
||||
s_[0] = '\0';
|
||||
u_.cs_ = s_;
|
||||
impl_.cs_ = s_;
|
||||
}
|
||||
|
||||
static_url_base::
|
||||
@@ -44,9 +44,9 @@ void
|
||||
static_url_base::
|
||||
clear_impl() noexcept
|
||||
{
|
||||
u_ = detail::url_impl(false);
|
||||
impl_ = {from::url};
|
||||
s_[0] = '\0';
|
||||
u_.cs_ = s_;
|
||||
impl_.cs_ = s_;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -43,13 +43,13 @@ url(string_view s)
|
||||
|
||||
url::
|
||||
url(url&& u) noexcept
|
||||
: url_base(u.u_)
|
||||
: url_base(u.impl_)
|
||||
{
|
||||
s_ = u.s_;
|
||||
cap_ = u.cap_;
|
||||
u.s_ = nullptr;
|
||||
u.cap_ = 0;
|
||||
u.u_ = detail::url_impl(false);
|
||||
u.impl_ = {from::url};
|
||||
}
|
||||
|
||||
url&
|
||||
@@ -58,12 +58,12 @@ operator=(url&& u) noexcept
|
||||
{
|
||||
if(s_)
|
||||
deallocate(s_);
|
||||
u_ = u.u_;
|
||||
impl_ = u.impl_;
|
||||
s_ = u.s_;
|
||||
cap_ = u.cap_;
|
||||
u.s_ = nullptr;
|
||||
u.cap_ = 0;
|
||||
u.u_ = detail::url_impl(false);
|
||||
u.impl_ = {from::url};
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -92,13 +92,13 @@ clear_impl() noexcept
|
||||
if(s_)
|
||||
{
|
||||
// preserve capacity
|
||||
u_ = detail::url_impl(false);
|
||||
impl_ = {from::url};
|
||||
s_[0] = '\0';
|
||||
u_.cs_ = s_;
|
||||
impl_.cs_ = s_;
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_ASSERT(u_.cs_ ==
|
||||
BOOST_ASSERT(impl_.cs_ ==
|
||||
detail::empty_c_str_);
|
||||
}
|
||||
}
|
||||
@@ -136,7 +136,7 @@ reserve_impl(
|
||||
s_ = allocate(n);
|
||||
s_[0] = '\0';
|
||||
}
|
||||
u_.cs_ = s_;
|
||||
impl_.cs_ = s_;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -158,7 +158,12 @@ swap(url& other) noexcept
|
||||
return;
|
||||
std::swap(s_, other.s_);
|
||||
std::swap(cap_, other.cap_);
|
||||
std::swap(u_, other.u_);
|
||||
std::swap(impl_, other.impl_);
|
||||
std::swap(pi_, other.pi_);
|
||||
if (pi_ == &other.impl_)
|
||||
pi_ = &impl_;
|
||||
if (other.pi_ == &impl_)
|
||||
other.pi_ = &other.impl_;
|
||||
}
|
||||
|
||||
} // urls
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -48,8 +48,17 @@ url_view(string_view s)
|
||||
url_view::
|
||||
url_view(
|
||||
url_view_base const& u) noexcept
|
||||
: url_view_base(u.u_)
|
||||
: url_view_base(u.impl_)
|
||||
{
|
||||
if (u.pi_->from_ == from::url)
|
||||
{
|
||||
pi_ = u.pi_;
|
||||
}
|
||||
else
|
||||
{
|
||||
impl_ = u.impl_;
|
||||
pi_ = &impl_;
|
||||
}
|
||||
}
|
||||
|
||||
url_view&
|
||||
@@ -57,7 +66,15 @@ url_view::
|
||||
operator=(
|
||||
url_view_base const& u) noexcept
|
||||
{
|
||||
u_ = u.u_;
|
||||
if (u.pi_->from_ == from::url)
|
||||
{
|
||||
pi_ = u.pi_;
|
||||
}
|
||||
else
|
||||
{
|
||||
impl_ = u.impl_;
|
||||
pi_ = &impl_;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,8 @@ namespace urls {
|
||||
// construct empty view
|
||||
url_view_base::
|
||||
url_view_base() noexcept
|
||||
: u_(false)
|
||||
: impl_(from::url)
|
||||
, pi_(&impl_)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -29,7 +30,8 @@ url_view_base() noexcept
|
||||
url_view_base::
|
||||
url_view_base(
|
||||
detail::url_impl const& impl) noexcept
|
||||
: u_(impl)
|
||||
: impl_(impl)
|
||||
, pi_(&impl_)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -40,15 +42,15 @@ url_view_base::
|
||||
digest(std::size_t salt) const noexcept
|
||||
{
|
||||
detail::fnv_1a h(salt);
|
||||
detail::ci_digest(u_.get(id_scheme), h);
|
||||
detail::digest_encoded(u_.get(id_user), h);
|
||||
detail::digest_encoded(u_.get(id_pass), h);
|
||||
detail::ci_digest_encoded(u_.get(id_host), h);
|
||||
h.put(u_.get(id_port));
|
||||
detail::ci_digest(pi_->get(id_scheme), h);
|
||||
detail::digest_encoded(pi_->get(id_user), h);
|
||||
detail::digest_encoded(pi_->get(id_pass), h);
|
||||
detail::ci_digest_encoded(pi_->get(id_host), h);
|
||||
h.put(pi_->get(id_port));
|
||||
detail::normalized_path_digest(
|
||||
u_.get(id_path), is_path_absolute(), h);
|
||||
detail::digest_encoded(u_.get(id_query), h);
|
||||
detail::digest_encoded(u_.get(id_frag), h);
|
||||
pi_->get(id_path), is_path_absolute(), h);
|
||||
detail::digest_encoded(pi_->get(id_query), h);
|
||||
detail::digest_encoded(pi_->get(id_frag), h);
|
||||
return h.digest();
|
||||
}
|
||||
|
||||
@@ -70,7 +72,7 @@ struct url_view_base::shared_impl
|
||||
url_view const& u) noexcept
|
||||
: url_view(u)
|
||||
{
|
||||
u_.cs_ = reinterpret_cast<
|
||||
impl_.cs_ = reinterpret_cast<
|
||||
char const*>(this + 1);
|
||||
}
|
||||
};
|
||||
@@ -84,7 +86,7 @@ persist() const
|
||||
Alloc a;
|
||||
auto p = std::allocate_shared<T>(
|
||||
detail::over_allocator<T, Alloc>(
|
||||
size(), a), url_view(u_));
|
||||
size(), a), url_view(*pi_));
|
||||
std::memcpy(
|
||||
reinterpret_cast<char*>(
|
||||
p.get() + 1), data(), size());
|
||||
@@ -101,13 +103,13 @@ bool
|
||||
url_view_base::
|
||||
has_scheme() const noexcept
|
||||
{
|
||||
auto const n = u_.len(
|
||||
auto const n = pi_->len(
|
||||
id_scheme);
|
||||
if(n == 0)
|
||||
return false;
|
||||
BOOST_ASSERT(n > 1);
|
||||
BOOST_ASSERT(
|
||||
u_.get(id_scheme
|
||||
pi_->get(id_scheme
|
||||
).ends_with(':'));
|
||||
return true;
|
||||
}
|
||||
@@ -116,7 +118,7 @@ string_view
|
||||
url_view_base::
|
||||
scheme() const noexcept
|
||||
{
|
||||
auto s = u_.get(id_scheme);
|
||||
auto s = pi_->get(id_scheme);
|
||||
if(! s.empty())
|
||||
{
|
||||
BOOST_ASSERT(s.size() > 1);
|
||||
@@ -130,7 +132,7 @@ urls::scheme
|
||||
url_view_base::
|
||||
scheme_id() const noexcept
|
||||
{
|
||||
return u_.scheme_;
|
||||
return pi_->scheme_;
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
@@ -143,29 +145,29 @@ authority_view
|
||||
url_view_base::
|
||||
authority() const noexcept
|
||||
{
|
||||
detail::url_impl u(true);
|
||||
detail::url_impl u(from::authority);
|
||||
u.cs_ = encoded_authority().data();
|
||||
if(has_authority())
|
||||
{
|
||||
u.set_size(id_user, u_.len(id_user) - 2);
|
||||
u.set_size(id_pass, u_.len(id_pass));
|
||||
u.set_size(id_host, u_.len(id_host));
|
||||
u.set_size(id_port, u_.len(id_port));
|
||||
u.set_size(id_user, pi_->len(id_user) - 2);
|
||||
u.set_size(id_pass, pi_->len(id_pass));
|
||||
u.set_size(id_host, pi_->len(id_host));
|
||||
u.set_size(id_port, pi_->len(id_port));
|
||||
}
|
||||
else
|
||||
{
|
||||
u.set_size(id_user, u_.len(id_user));
|
||||
BOOST_ASSERT(u_.len(id_pass) == 0);
|
||||
BOOST_ASSERT(u_.len(id_host) == 0);
|
||||
BOOST_ASSERT(u_.len(id_port) == 0);
|
||||
u.set_size(id_user, pi_->len(id_user));
|
||||
BOOST_ASSERT(pi_->len(id_pass) == 0);
|
||||
BOOST_ASSERT(pi_->len(id_host) == 0);
|
||||
BOOST_ASSERT(pi_->len(id_port) == 0);
|
||||
}
|
||||
u.decoded_[id_user] = u_.decoded_[id_user];
|
||||
u.decoded_[id_pass] = u_.decoded_[id_pass];
|
||||
u.decoded_[id_host] = u_.decoded_[id_host];
|
||||
u.decoded_[id_user] = pi_->decoded_[id_user];
|
||||
u.decoded_[id_pass] = pi_->decoded_[id_pass];
|
||||
u.decoded_[id_host] = pi_->decoded_[id_host];
|
||||
for (int i = 0; i < 16; ++i)
|
||||
u.ip_addr_[i] = u_.ip_addr_[i];
|
||||
u.port_number_ = u_.port_number_;
|
||||
u.host_type_ = u_.host_type_;
|
||||
u.ip_addr_[i] = pi_->ip_addr_[i];
|
||||
u.port_number_ = pi_->port_number_;
|
||||
u.host_type_ = pi_->host_type_;
|
||||
return u.construct_authority();
|
||||
}
|
||||
|
||||
@@ -173,7 +175,7 @@ pct_string_view
|
||||
url_view_base::
|
||||
encoded_authority() const noexcept
|
||||
{
|
||||
auto s = u_.get(id_user, id_path);
|
||||
auto s = pi_->get(id_user, id_path);
|
||||
if(! s.empty())
|
||||
{
|
||||
BOOST_ASSERT(has_authority());
|
||||
@@ -192,11 +194,11 @@ bool
|
||||
url_view_base::
|
||||
has_userinfo() const noexcept
|
||||
{
|
||||
auto n = u_.len(id_pass);
|
||||
auto n = pi_->len(id_pass);
|
||||
if(n == 0)
|
||||
return false;
|
||||
BOOST_ASSERT(has_authority());
|
||||
BOOST_ASSERT(u_.get(
|
||||
BOOST_ASSERT(pi_->get(
|
||||
id_pass).ends_with('@'));
|
||||
return true;
|
||||
}
|
||||
@@ -205,7 +207,7 @@ pct_string_view
|
||||
url_view_base::
|
||||
encoded_userinfo() const noexcept
|
||||
{
|
||||
auto s = u_.get(
|
||||
auto s = pi_->get(
|
||||
id_user, id_host);
|
||||
if(s.empty())
|
||||
return s;
|
||||
@@ -218,14 +220,14 @@ encoded_userinfo() const noexcept
|
||||
s.ends_with('@'));
|
||||
s.remove_suffix(1);
|
||||
return detail::make_pct_string_view(
|
||||
s, u_.decoded_[id_user] + u_.decoded_[id_pass] + has_password());
|
||||
s, pi_->decoded_[id_user] + pi_->decoded_[id_pass] + has_password());
|
||||
}
|
||||
|
||||
pct_string_view
|
||||
url_view_base::
|
||||
encoded_user() const noexcept
|
||||
{
|
||||
auto s = u_.get(id_user);
|
||||
auto s = pi_->get(id_user);
|
||||
if(! s.empty())
|
||||
{
|
||||
BOOST_ASSERT(
|
||||
@@ -233,23 +235,23 @@ encoded_user() const noexcept
|
||||
s.remove_prefix(2);
|
||||
}
|
||||
return detail::make_pct_string_view(
|
||||
s, u_.decoded_[id_user]);
|
||||
s, pi_->decoded_[id_user]);
|
||||
}
|
||||
|
||||
bool
|
||||
url_view_base::
|
||||
has_password() const noexcept
|
||||
{
|
||||
auto const n = u_.len(id_pass);
|
||||
auto const n = pi_->len(id_pass);
|
||||
if(n > 1)
|
||||
{
|
||||
BOOST_ASSERT(u_.get(id_pass
|
||||
BOOST_ASSERT(pi_->get(id_pass
|
||||
).starts_with(':'));
|
||||
BOOST_ASSERT(u_.get(id_pass
|
||||
BOOST_ASSERT(pi_->get(id_pass
|
||||
).ends_with('@'));
|
||||
return true;
|
||||
}
|
||||
BOOST_ASSERT(n == 0 || u_.get(
|
||||
BOOST_ASSERT(n == 0 || pi_->get(
|
||||
id_pass).ends_with('@'));
|
||||
return false;
|
||||
}
|
||||
@@ -258,7 +260,7 @@ pct_string_view
|
||||
url_view_base::
|
||||
encoded_password() const noexcept
|
||||
{
|
||||
auto s = u_.get(id_pass);
|
||||
auto s = pi_->get(id_pass);
|
||||
switch(s.size())
|
||||
{
|
||||
case 1:
|
||||
@@ -275,7 +277,7 @@ encoded_password() const noexcept
|
||||
BOOST_ASSERT(s.starts_with(':'));
|
||||
return detail::make_pct_string_view(
|
||||
s.substr(1, s.size() - 2),
|
||||
u_.decoded_[id_pass]);
|
||||
pi_->decoded_[id_pass]);
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
@@ -303,17 +305,17 @@ url_view_base::
|
||||
encoded_host() const noexcept
|
||||
{
|
||||
return detail::make_pct_string_view(
|
||||
u_.get(id_host),
|
||||
u_.decoded_[id_host]);
|
||||
pi_->get(id_host),
|
||||
pi_->decoded_[id_host]);
|
||||
}
|
||||
|
||||
pct_string_view
|
||||
url_view_base::
|
||||
encoded_host_address() const noexcept
|
||||
{
|
||||
string_view s = u_.get(id_host);
|
||||
string_view s = pi_->get(id_host);
|
||||
std::size_t n;
|
||||
switch(u_.host_type_)
|
||||
switch(pi_->host_type_)
|
||||
{
|
||||
default:
|
||||
case urls::host_type::none:
|
||||
@@ -323,20 +325,20 @@ encoded_host_address() const noexcept
|
||||
|
||||
case urls::host_type::name:
|
||||
case urls::host_type::ipv4:
|
||||
n = u_.decoded_[id_host];
|
||||
n = pi_->decoded_[id_host];
|
||||
break;
|
||||
|
||||
case urls::host_type::ipv6:
|
||||
case urls::host_type::ipvfuture:
|
||||
{
|
||||
BOOST_ASSERT(
|
||||
u_.decoded_[id_host] ==
|
||||
pi_->decoded_[id_host] ==
|
||||
s.size());
|
||||
BOOST_ASSERT(s.size() >= 2);
|
||||
BOOST_ASSERT(s.front() == '[');
|
||||
BOOST_ASSERT(s.back() == ']');
|
||||
s = s.substr(1, s.size() - 2);
|
||||
n = u_.decoded_[id_host] - 2;
|
||||
n = pi_->decoded_[id_host] - 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -347,12 +349,12 @@ urls::ipv4_address
|
||||
url_view_base::
|
||||
host_ipv4_address() const noexcept
|
||||
{
|
||||
if(u_.host_type_ !=
|
||||
if(pi_->host_type_ !=
|
||||
urls::host_type::ipv4)
|
||||
return {};
|
||||
ipv4_address::bytes_type b;
|
||||
std::memcpy(
|
||||
&b[0], &u_.ip_addr_[0], b.size());
|
||||
&b[0], &pi_->ip_addr_[0], b.size());
|
||||
return urls::ipv4_address(b);
|
||||
}
|
||||
|
||||
@@ -360,12 +362,12 @@ urls::ipv6_address
|
||||
url_view_base::
|
||||
host_ipv6_address() const noexcept
|
||||
{
|
||||
if(u_.host_type_ !=
|
||||
if(pi_->host_type_ !=
|
||||
urls::host_type::ipv6)
|
||||
return {};
|
||||
ipv6_address::bytes_type b;
|
||||
std::memcpy(
|
||||
&b[0], &u_.ip_addr_[0], b.size());
|
||||
&b[0], &pi_->ip_addr_[0], b.size());
|
||||
return urls::ipv6_address(b);
|
||||
}
|
||||
|
||||
@@ -373,10 +375,10 @@ string_view
|
||||
url_view_base::
|
||||
host_ipvfuture() const noexcept
|
||||
{
|
||||
if(u_.host_type_ !=
|
||||
if(pi_->host_type_ !=
|
||||
urls::host_type::ipvfuture)
|
||||
return {};
|
||||
string_view s = u_.get(id_host);
|
||||
string_view s = pi_->get(id_host);
|
||||
BOOST_ASSERT(s.size() >= 6);
|
||||
BOOST_ASSERT(s.front() == '[');
|
||||
BOOST_ASSERT(s.back() == ']');
|
||||
@@ -388,12 +390,12 @@ pct_string_view
|
||||
url_view_base::
|
||||
encoded_host_name() const noexcept
|
||||
{
|
||||
if(u_.host_type_ !=
|
||||
if(pi_->host_type_ !=
|
||||
urls::host_type::name)
|
||||
return {};
|
||||
string_view s = u_.get(id_host);
|
||||
string_view s = pi_->get(id_host);
|
||||
return detail::make_pct_string_view(
|
||||
s, u_.decoded_[id_host]);
|
||||
s, pi_->decoded_[id_host]);
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
@@ -402,11 +404,11 @@ bool
|
||||
url_view_base::
|
||||
has_port() const noexcept
|
||||
{
|
||||
auto const n = u_.len(id_port);
|
||||
auto const n = pi_->len(id_port);
|
||||
if(n == 0)
|
||||
return false;
|
||||
BOOST_ASSERT(
|
||||
u_.get(id_port).starts_with(':'));
|
||||
pi_->get(id_port).starts_with(':'));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -414,7 +416,7 @@ string_view
|
||||
url_view_base::
|
||||
port() const noexcept
|
||||
{
|
||||
auto s = u_.get(id_port);
|
||||
auto s = pi_->get(id_port);
|
||||
if(s.empty())
|
||||
return s;
|
||||
BOOST_ASSERT(has_port());
|
||||
@@ -427,8 +429,8 @@ port_number() const noexcept
|
||||
{
|
||||
BOOST_ASSERT(
|
||||
has_port() ||
|
||||
u_.port_number_ == 0);
|
||||
return u_.port_number_;
|
||||
pi_->port_number_ == 0);
|
||||
return pi_->port_number_;
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
@@ -438,16 +440,16 @@ url_view_base::
|
||||
encoded_host_and_port() const noexcept
|
||||
{
|
||||
return detail::make_pct_string_view(
|
||||
u_.get(id_host, id_path));
|
||||
pi_->get(id_host, id_path));
|
||||
}
|
||||
|
||||
pct_string_view
|
||||
url_view_base::
|
||||
encoded_origin() const noexcept
|
||||
{
|
||||
if(u_.len(id_user) < 2)
|
||||
if(pi_->len(id_user) < 2)
|
||||
return {};
|
||||
return u_.get(id_scheme, id_path);
|
||||
return pi_->get(id_scheme, id_path);
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
@@ -461,14 +463,14 @@ url_view_base::
|
||||
encoded_path() const noexcept
|
||||
{
|
||||
return detail::make_pct_string_view(
|
||||
u_.get(id_path), u_.decoded_[id_path]);
|
||||
pi_->get(id_path), pi_->decoded_[id_path]);
|
||||
}
|
||||
|
||||
segments_view
|
||||
url_view_base::
|
||||
segments() const noexcept
|
||||
{
|
||||
return {detail::path_ref(u_)};
|
||||
return {detail::path_ref(*pi_)};
|
||||
}
|
||||
|
||||
segments_encoded_view
|
||||
@@ -476,7 +478,7 @@ url_view_base::
|
||||
encoded_segments() const noexcept
|
||||
{
|
||||
return segments_encoded_view(
|
||||
detail::path_ref(u_));
|
||||
detail::path_ref(*pi_));
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
@@ -489,12 +491,12 @@ bool
|
||||
url_view_base::
|
||||
has_query() const noexcept
|
||||
{
|
||||
auto const n = u_.len(
|
||||
auto const n = pi_->len(
|
||||
id_query);
|
||||
if(n == 0)
|
||||
return false;
|
||||
BOOST_ASSERT(
|
||||
u_.get(id_query).
|
||||
pi_->get(id_query).
|
||||
starts_with('?'));
|
||||
return true;
|
||||
}
|
||||
@@ -503,7 +505,7 @@ pct_string_view
|
||||
url_view_base::
|
||||
encoded_query() const noexcept
|
||||
{
|
||||
auto s = u_.get(id_query);
|
||||
auto s = pi_->get(id_query);
|
||||
if(s.empty())
|
||||
return s;
|
||||
BOOST_ASSERT(
|
||||
@@ -515,14 +517,14 @@ params_encoded_view
|
||||
url_view_base::
|
||||
encoded_params() const noexcept
|
||||
{
|
||||
return params_encoded_view(u_);
|
||||
return params_encoded_view(*pi_);
|
||||
}
|
||||
|
||||
params_view
|
||||
url_view_base::
|
||||
params() const noexcept
|
||||
{
|
||||
return params_view(u_);
|
||||
return params_view(*pi_);
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
@@ -532,15 +534,15 @@ url_view_base::
|
||||
encoded_target() const noexcept
|
||||
{
|
||||
auto n =
|
||||
u_.decoded_[id_path] +
|
||||
u_.decoded_[id_query];
|
||||
pi_->decoded_[id_path] +
|
||||
pi_->decoded_[id_query];
|
||||
if(has_query())
|
||||
++n;
|
||||
BOOST_ASSERT(pct_string_view(
|
||||
u_.get(id_path, id_frag)
|
||||
pi_->get(id_path, id_frag)
|
||||
).decoded_size() == n);
|
||||
return detail::make_pct_string_view(
|
||||
u_.get(id_path, id_frag), n);
|
||||
pi_->get(id_path, id_frag), n);
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
@@ -553,11 +555,11 @@ bool
|
||||
url_view_base::
|
||||
has_fragment() const noexcept
|
||||
{
|
||||
auto const n = u_.len(id_frag);
|
||||
auto const n = pi_->len(id_frag);
|
||||
if(n == 0)
|
||||
return false;
|
||||
BOOST_ASSERT(
|
||||
u_.get(id_frag).
|
||||
pi_->get(id_frag).
|
||||
starts_with('#'));
|
||||
return true;
|
||||
}
|
||||
@@ -566,7 +568,7 @@ pct_string_view
|
||||
url_view_base::
|
||||
encoded_fragment() const noexcept
|
||||
{
|
||||
auto s = u_.get(id_frag);
|
||||
auto s = pi_->get(id_frag);
|
||||
if(! s.empty())
|
||||
{
|
||||
BOOST_ASSERT(
|
||||
@@ -574,7 +576,7 @@ encoded_fragment() const noexcept
|
||||
s.remove_prefix(1);
|
||||
}
|
||||
return detail::make_pct_string_view(
|
||||
s, u_.decoded_[id_frag]);
|
||||
s, pi_->decoded_[id_frag]);
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
@@ -584,18 +586,18 @@ url_view_base::
|
||||
encoded_resource() const noexcept
|
||||
{
|
||||
auto n =
|
||||
u_.decoded_[id_path] +
|
||||
u_.decoded_[id_query] +
|
||||
u_.decoded_[id_frag];
|
||||
pi_->decoded_[id_path] +
|
||||
pi_->decoded_[id_query] +
|
||||
pi_->decoded_[id_frag];
|
||||
if(has_query())
|
||||
++n;
|
||||
if(has_fragment())
|
||||
++n;
|
||||
BOOST_ASSERT(pct_string_view(
|
||||
u_.get(id_path, id_end)
|
||||
pi_->get(id_path, id_end)
|
||||
).decoded_size() == n);
|
||||
return detail::make_pct_string_view(
|
||||
u_.get(id_path, id_end), n);
|
||||
pi_->get(id_path, id_end), n);
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
@@ -31,7 +31,7 @@ parse(
|
||||
) const noexcept ->
|
||||
result<value_type>
|
||||
{
|
||||
detail::url_impl u(false);
|
||||
detail::url_impl u(detail::url_impl::from::string);
|
||||
u.cs_ = it;
|
||||
|
||||
// scheme
|
||||
|
||||
@@ -29,7 +29,7 @@ parse(
|
||||
) const noexcept ->
|
||||
result<value_type>
|
||||
{
|
||||
detail::url_impl u(true);
|
||||
detail::url_impl u(detail::url_impl::from::authority);
|
||||
u.cs_ = it;
|
||||
|
||||
// [ userinfo "@" ]
|
||||
|
||||
@@ -28,7 +28,7 @@ parse(
|
||||
) const noexcept ->
|
||||
result<value_type>
|
||||
{
|
||||
detail::url_impl u(false);
|
||||
detail::url_impl u(detail::url_impl::from::string);
|
||||
u.cs_ = it;
|
||||
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ parse(
|
||||
) const noexcept ->
|
||||
result<value_type>
|
||||
{
|
||||
detail::url_impl u(false);
|
||||
detail::url_impl u(detail::url_impl::from::string);
|
||||
u.cs_ = it;
|
||||
|
||||
// relative-part
|
||||
|
||||
@@ -31,7 +31,7 @@ parse(
|
||||
) const noexcept ->
|
||||
result<value_type>
|
||||
{
|
||||
detail::url_impl u(false);
|
||||
detail::url_impl u(detail::url_impl::from::string);
|
||||
u.cs_ = it;
|
||||
|
||||
// scheme
|
||||
|
||||
@@ -124,7 +124,7 @@ public:
|
||||
char const*
|
||||
c_str() const noexcept
|
||||
{
|
||||
return u_.cs_;
|
||||
return pi_->cs_;
|
||||
}
|
||||
|
||||
/** Return the number of characters that can be stored without reallocating
|
||||
|
||||
@@ -59,7 +59,8 @@ class BOOST_SYMBOL_VISIBLE
|
||||
url_view_base
|
||||
: private detail::parts_base
|
||||
{
|
||||
detail::url_impl u_;
|
||||
detail::url_impl impl_;
|
||||
detail::url_impl const* pi_;
|
||||
|
||||
friend class url;
|
||||
friend class url_base;
|
||||
@@ -82,12 +83,22 @@ class BOOST_SYMBOL_VISIBLE
|
||||
|
||||
BOOST_URL_DECL
|
||||
url_view_base() noexcept;
|
||||
|
||||
BOOST_URL_DECL
|
||||
explicit url_view_base(
|
||||
detail::url_impl const&) noexcept;
|
||||
|
||||
~url_view_base() = default;
|
||||
|
||||
url_view_base(
|
||||
url_view_base const&) = default;
|
||||
url_view_base const& o) noexcept
|
||||
: impl_(o.impl_)
|
||||
, pi_(o.pi_)
|
||||
{
|
||||
if (pi_ == &o.impl_)
|
||||
pi_ = &impl_;
|
||||
}
|
||||
|
||||
url_view_base& operator=(
|
||||
url_view_base const&) = delete;
|
||||
|
||||
@@ -149,7 +160,7 @@ public:
|
||||
std::size_t
|
||||
size() const noexcept
|
||||
{
|
||||
return u_.offset(id_end);
|
||||
return pi_->offset(id_end);
|
||||
}
|
||||
|
||||
/** Return true if the URL is empty
|
||||
@@ -185,7 +196,7 @@ public:
|
||||
bool
|
||||
empty() const noexcept
|
||||
{
|
||||
return u_.offset(id_end) == 0;
|
||||
return pi_->offset(id_end) == 0;
|
||||
}
|
||||
|
||||
/** Return a pointer to the URL's character buffer
|
||||
@@ -203,7 +214,7 @@ public:
|
||||
char const*
|
||||
data() const noexcept
|
||||
{
|
||||
return u_.cs_;
|
||||
return pi_->cs_;
|
||||
}
|
||||
|
||||
/** Return the URL string
|
||||
@@ -454,7 +465,7 @@ public:
|
||||
bool
|
||||
has_authority() const noexcept
|
||||
{
|
||||
return u_.len(id_user) > 0;
|
||||
return pi_->len(id_user) > 0;
|
||||
}
|
||||
|
||||
/** Return the authority
|
||||
@@ -956,7 +967,7 @@ public:
|
||||
urls::host_type
|
||||
host_type() const noexcept
|
||||
{
|
||||
return u_.host_type_;
|
||||
return pi_->host_type_;
|
||||
}
|
||||
|
||||
/** Return the host
|
||||
@@ -1593,8 +1604,8 @@ public:
|
||||
is_path_absolute() const noexcept
|
||||
{
|
||||
return
|
||||
u_.len(id_path) > 0 &&
|
||||
u_.cs_[u_.offset(id_path)] == '/';
|
||||
pi_->len(id_path) > 0 &&
|
||||
pi_->cs_[pi_->offset(id_path)] == '/';
|
||||
}
|
||||
|
||||
/** Return the path
|
||||
|
||||
Reference in New Issue
Block a user