update boost

This commit is contained in:
2023-11-24 12:56:13 -06:00
parent cfc99971af
commit 19d727037a
9260 changed files with 849256 additions and 299957 deletions

View File

@@ -0,0 +1,172 @@
//
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/url
//
#ifndef BOOST_URL_IMPL_PCT_ENCODED_VIEW_HPP
#define BOOST_URL_IMPL_PCT_ENCODED_VIEW_HPP
#include <boost/url/grammar/type_traits.hpp>
#include <boost/static_assert.hpp>
namespace boost {
namespace urls {
class decode_view::iterator
{
char const* begin_ = nullptr;
char const* pos_ = nullptr;
bool space_as_plus_ = true;
friend decode_view;
iterator(
char const* str,
bool space_as_plus) noexcept
: begin_(str)
, pos_(str)
, space_as_plus_(
space_as_plus)
{
}
// end ctor
iterator(
char const* str,
size_type n,
bool space_as_plus) noexcept
: begin_(str)
, pos_(str + n)
, space_as_plus_(space_as_plus)
{
}
public:
using value_type = char;
using reference = char;
using pointer = void const*;
using const_reference = char;
using size_type = std::size_t;
using difference_type = std::ptrdiff_t;
using iterator_category =
std::bidirectional_iterator_tag;
iterator() = default;
iterator(iterator const&) = default;
iterator&
operator=(iterator const&) = default;
BOOST_URL_DECL
reference
operator*() const noexcept;
iterator&
operator++() noexcept
{
BOOST_ASSERT(pos_ != nullptr);
if (*pos_ != '%')
++pos_;
else
pos_ += 3;
return *this;
}
iterator&
operator--() noexcept
{
BOOST_ASSERT(pos_ != begin_);
if (pos_ - begin_ < 3 ||
pos_[-3] != '%')
--pos_;
else
pos_ -= 3;
return *this;
}
iterator
operator++(int) noexcept
{
auto tmp = *this;
++*this;
return tmp;
}
iterator
operator--(int) noexcept
{
auto tmp = *this;
--*this;
return tmp;
}
char const*
base()
{
return pos_;
}
bool
operator==(
iterator const& other) const noexcept
{
return pos_ == other.pos_;
}
bool
operator!=(
iterator const& other) const noexcept
{
return !(*this == other);
}
};
//------------------------------------------------
inline
auto
decode_view::
begin() const noexcept ->
const_iterator
{
return {p_, space_as_plus_};
}
inline
auto
decode_view::
end() const noexcept ->
const_iterator
{
return {p_, n_, space_as_plus_};
}
inline
auto
decode_view::
front() const noexcept ->
const_reference
{
BOOST_ASSERT( !empty() );
return *begin();
}
inline
auto
decode_view::
back() const noexcept ->
const_reference
{
BOOST_ASSERT( !empty() );
return *--end();
}
} // urls
} // boost
#endif

View File

@@ -0,0 +1,278 @@
//
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/url
//
#ifndef BOOST_URL_IMPL_ENCODE_HPP
#define BOOST_URL_IMPL_ENCODE_HPP
#include <boost/url/detail/encode.hpp>
#include <boost/url/detail/except.hpp>
#include <boost/url/encoding_opts.hpp>
#include <boost/url/grammar/charset.hpp>
#include <boost/url/grammar/hexdig_chars.hpp>
#include <boost/url/grammar/type_traits.hpp>
#include <boost/assert.hpp>
#include <boost/static_assert.hpp>
namespace boost {
namespace urls {
//------------------------------------------------
template<class CharSet>
std::size_t
encoded_size(
core::string_view s,
CharSet const& unreserved,
encoding_opts opt) noexcept
{
/* If you get a compile error here, it
means that the value you passed does
not meet the requirements stated in
the documentation.
*/
static_assert(
grammar::is_charset<CharSet>::value,
"Type requirements not met");
std::size_t n = 0;
auto it = s.data();
auto const last = it + s.size();
if(! opt.space_as_plus ||
unreserved(' '))
{
while(it != last)
{
if(unreserved(*it))
n += 1;
else
n += 3;
++it;
}
}
else
{
while(it != last)
{
auto c = *it;
if(unreserved(c))
++n;
else if(c == ' ')
++n;
else
n += 3;
++it;
}
}
return n;
}
//------------------------------------------------
template<class CharSet>
std::size_t
encode(
char* dest,
std::size_t size,
core::string_view s,
CharSet const& unreserved,
encoding_opts opt)
{
/* If you get a compile error here, it
means that the value you passed does
not meet the requirements stated in
the documentation.
*/
static_assert(
grammar::is_charset<CharSet>::value,
"Type requirements not met");
// '%' must be reserved
BOOST_ASSERT(! unreserved('%'));
char const* const hex =
detail::hexdigs[opt.lower_case];
auto const encode = [hex](
char*& dest,
unsigned char c) noexcept
{
*dest++ = '%';
*dest++ = hex[c>>4];
*dest++ = hex[c&0xf];
};
auto it = s.data();
auto const end = dest + size;
auto const last = it + s.size();
auto const dest0 = dest;
auto const end3 = end - 3;
if(! opt.space_as_plus)
{
while(it != last)
{
if(unreserved(*it))
{
if(dest == end)
return dest - dest0;
*dest++ = *it++;
continue;
}
if(dest > end3)
return dest - dest0;
encode(dest, *it++);
}
return dest - dest0;
}
else if(! unreserved(' '))
{
// VFALCO space is usually reserved,
// and we depend on this for an
// optimization. if this assert
// goes off we can split the loop
// below into two versions.
BOOST_ASSERT(! unreserved(' '));
while(it != last)
{
if(unreserved(*it))
{
if(dest == end)
return dest - dest0;
*dest++ = *it++;
continue;
}
if(*it == ' ')
{
if(dest == end)
return dest - dest0;
*dest++ = '+';
++it;
continue;
}
if(dest > end3)
return dest - dest0;
encode(dest, *it++);
}
}
return dest - dest0;
}
//------------------------------------------------
// unsafe encode just
// asserts on the output buffer
//
template<class CharSet>
std::size_t
encode_unsafe(
char* dest,
std::size_t size,
core::string_view s,
CharSet const& unreserved,
encoding_opts opt)
{
// '%' must be reserved
BOOST_ASSERT(! unreserved('%'));
auto it = s.data();
auto const last = it + s.size();
auto const end = dest + size;
ignore_unused(end);
char const* const hex =
detail::hexdigs[opt.lower_case];
auto const encode = [end, hex](
char*& dest,
unsigned char c) noexcept
{
ignore_unused(end);
*dest++ = '%';
BOOST_ASSERT(dest != end);
*dest++ = hex[c>>4];
BOOST_ASSERT(dest != end);
*dest++ = hex[c&0xf];
};
auto const dest0 = dest;
if(! opt.space_as_plus)
{
while(it != last)
{
BOOST_ASSERT(dest != end);
if(unreserved(*it))
*dest++ = *it++;
else
encode(dest, *it++);
}
}
else
{
// VFALCO space is usually reserved,
// and we depend on this for an
// optimization. if this assert
// goes off we can split the loop
// below into two versions.
BOOST_ASSERT(! unreserved(' '));
while(it != last)
{
BOOST_ASSERT(dest != end);
if(unreserved(*it))
{
*dest++ = *it++;
}
else if(*it == ' ')
{
*dest++ = '+';
++it;
}
else
{
encode(dest, *it++);
}
}
}
return dest - dest0;
}
//------------------------------------------------
template<
class StringToken,
class CharSet>
BOOST_URL_STRTOK_RETURN
encode(
core::string_view s,
CharSet const& unreserved,
encoding_opts opt,
StringToken&& token) noexcept
{
/* If you get a compile error here, it
means that the value you passed does
not meet the requirements stated in
the documentation.
*/
static_assert(
grammar::is_charset<CharSet>::value,
"Type requirements not met");
auto const n = encoded_size(
s, unreserved, opt);
auto p = token.prepare(n);
if(n > 0)
encode_unsafe(
p, n, s, unreserved, opt);
return token.result();
}
} // urls
} // boost
#endif

View File

@@ -0,0 +1,79 @@
//
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/url
//
#ifndef BOOST_URL_IMPL_ERROR_HPP
#define BOOST_URL_IMPL_ERROR_HPP
#include <type_traits>
namespace boost {
//-----------------------------------------------
namespace system {
template<>
struct is_error_code_enum<::boost::urls::error>
{
static bool const value = true;
};
} // system
//-----------------------------------------------
namespace urls {
namespace detail {
struct BOOST_SYMBOL_VISIBLE
error_cat_type
: system::error_category
{
BOOST_URL_DECL
const char* name(
) const noexcept override;
BOOST_URL_DECL
std::string message(
int) const override;
BOOST_URL_DECL
char const* message(
int, char*, std::size_t
) const noexcept override;
BOOST_URL_DECL
system::error_condition
default_error_condition(
int code) const noexcept override;
BOOST_SYSTEM_CONSTEXPR error_cat_type() noexcept
: error_category(0xbc15399d7a4ce829)
{
}
};
BOOST_URL_DECL extern
error_cat_type error_cat;
} // detail
inline
BOOST_SYSTEM_CONSTEXPR
system::error_code
make_error_code(
error ev) noexcept
{
return system::error_code{
static_cast<std::underlying_type<
error>::type>(ev),
detail::error_cat};
}
} // urls
} // boost
#endif

View File

@@ -0,0 +1,116 @@
//
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/url
//
#ifndef BOOST_URL_IMPL_PARAMS_BASE_HPP
#define BOOST_URL_IMPL_PARAMS_BASE_HPP
#include <boost/url/detail/params_iter_impl.hpp>
#include <iterator>
namespace boost {
namespace urls {
//------------------------------------------------
class BOOST_URL_DECL params_base::iterator
{
detail::params_iter_impl it_;
bool space_as_plus_ = true;
friend class params_base;
friend class params_ref;
iterator(
detail::query_ref const& ref,
encoding_opts opt) noexcept;
iterator(
detail::query_ref const& impl,
encoding_opts opt,
int) noexcept;
iterator(
detail::params_iter_impl const& it,
encoding_opts opt) noexcept
: it_(it)
, space_as_plus_(opt.space_as_plus)
{
}
public:
using value_type = params_base::value_type;
using reference = params_base::reference;
using pointer = reference;
using difference_type =
params_base::difference_type;
using iterator_category =
std::bidirectional_iterator_tag;
iterator() = default;
iterator(iterator const&) = default;
iterator& operator=(
iterator const&) noexcept = default;
iterator&
operator++() noexcept
{
it_.increment();
return *this;
}
iterator
operator++(int) noexcept
{
auto tmp = *this;
++*this;
return tmp;
}
iterator&
operator--() noexcept
{
it_.decrement();
return *this;
}
iterator
operator--(int) noexcept
{
auto tmp = *this;
--*this;
return tmp;
}
reference
operator*() const;
// the return value is too expensive
pointer operator->() const = delete;
bool
operator==(
iterator const& other) const noexcept
{
return it_.equal(other.it_);
}
bool
operator!=(
iterator const& other) const noexcept
{
return ! it_.equal(other.it_);
}
};
} // urls
} // boost
#endif

View File

@@ -0,0 +1,186 @@
//
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/url
//
#ifndef BOOST_URL_IMPL_PARAMS_ENCODED_BASE_HPP
#define BOOST_URL_IMPL_PARAMS_ENCODED_BASE_HPP
#include <boost/url/detail/params_iter_impl.hpp>
namespace boost {
namespace urls {
#ifndef BOOST_URL_DOCS
class params_ref;
#endif
//------------------------------------------------
class params_encoded_base::iterator
{
detail::params_iter_impl it_;
friend class params_encoded_base;
friend class params_encoded_ref;
iterator(detail::query_ref const& ref) noexcept;
iterator(detail::query_ref const& ref, int) noexcept;
iterator(
detail::params_iter_impl const& it)
: it_(it)
{
}
public:
using value_type =
params_encoded_base::value_type;
using reference =
params_encoded_base::reference;
using pointer = reference;
using difference_type = std::ptrdiff_t;
using iterator_category =
std::bidirectional_iterator_tag;
iterator() = default;
iterator(iterator const&) = default;
iterator& operator=(
iterator const&) = default;
iterator&
operator++() noexcept
{
it_.increment();
return *this;
}
iterator
operator++(int) noexcept
{
auto tmp = *this;
++*this;
return tmp;
}
iterator&
operator--() noexcept
{
it_.decrement();
return *this;
}
iterator
operator--(int) noexcept
{
auto tmp = *this;
--*this;
return tmp;
}
reference
operator*() const
{
return it_.dereference();
}
pointer
operator->() const
{
return it_.dereference();
}
friend
bool
operator==(
iterator const& it0,
iterator const& it1) noexcept
{
return it0.it_.equal(it1.it_);
}
friend
bool
operator!=(
iterator const& it0,
iterator const& it1) noexcept
{
return ! it0.it_.equal(it1.it_);
}
};
//------------------------------------------------
//
// Observers
//
//------------------------------------------------
inline
bool
params_encoded_base::
contains(
pct_string_view key,
ignore_case_param ic) const noexcept
{
return find_impl(
begin().it_, key, ic) != end();
}
inline
auto
params_encoded_base::
find(
pct_string_view key,
ignore_case_param ic) const noexcept ->
iterator
{
return find_impl(
begin().it_, key, ic);
}
inline
auto
params_encoded_base::
find(
iterator it,
pct_string_view key,
ignore_case_param ic) const noexcept ->
iterator
{
return find_impl(
it.it_, key, ic);
}
inline
auto
params_encoded_base::
find_last(
pct_string_view key,
ignore_case_param ic) const noexcept ->
iterator
{
return find_last_impl(
end().it_, key, ic);
}
inline
auto
params_encoded_base::
find_last(
iterator it,
pct_string_view key,
ignore_case_param ic) const noexcept ->
iterator
{
return find_last_impl(
it.it_, key, ic);
}
} // urls
} // boost
#endif

View File

@@ -0,0 +1,196 @@
//
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/url
//
#ifndef BOOST_URL_IMPL_PARAMS_ENCODED_REF_HPP
#define BOOST_URL_IMPL_PARAMS_ENCODED_REF_HPP
#include <boost/url/detail/except.hpp>
#include <boost/assert.hpp>
namespace boost {
namespace urls {
//------------------------------------------------
//
// Modifiers
//
//------------------------------------------------
inline
void
params_encoded_ref::
clear() noexcept
{
u_->remove_query();
}
template<class FwdIt>
void
params_encoded_ref::
assign(FwdIt first, FwdIt last)
{
/* If you get a compile error here, it
means that the iterators you passed
do not meet the requirements stated
in the documentation.
*/
static_assert(
std::is_convertible<
typename std::iterator_traits<
FwdIt>::reference,
param_view>::value,
"Type requirements not met");
assign(first, last,
typename std::iterator_traits<
FwdIt>::iterator_category{});
}
inline
auto
params_encoded_ref::
append(
param_pct_view const& p) ->
iterator
{
return insert(end(), p);
}
inline
auto
params_encoded_ref::
append(
std::initializer_list<
param_pct_view> init) ->
iterator
{
return insert(end(), init);
}
template<class FwdIt>
auto
params_encoded_ref::
append(
FwdIt first, FwdIt last) ->
iterator
{
/* If you get a compile error here, it
means that the iterators you passed
do not meet the requirements stated
in the documentation.
*/
static_assert(
std::is_convertible<
typename std::iterator_traits<
FwdIt>::reference,
param_view>::value,
"Type requirements not met");
return insert(
end(), first, last);
}
template<class FwdIt>
auto
params_encoded_ref::
insert(
iterator before,
FwdIt first,
FwdIt last) ->
iterator
{
/* If you get a compile error here, it
means that the iterators you passed
do not meet the requirements stated
in the documentation.
*/
static_assert(
std::is_convertible<
typename std::iterator_traits<
FwdIt>::reference,
param_view>::value,
"Type requirements not met");
return insert(
before,
first,
last,
typename std::iterator_traits<
FwdIt>::iterator_category{});
}
template<class FwdIt>
auto
params_encoded_ref::
replace(
iterator from,
iterator to,
FwdIt first,
FwdIt last) ->
iterator
{
/* If you get a compile error here, it
means that the iterators you passed
do not meet the requirements stated
in the documentation.
*/
static_assert(
std::is_convertible<
typename std::iterator_traits<
FwdIt>::reference,
param_view>::value,
"Type requirements not met");
return u_->edit_params(
from.it_, to.it_,
detail::make_params_encoded_iter(
first, last));
}
//------------------------------------------------
//
// implementation
//
//------------------------------------------------
template<class FwdIt>
void
params_encoded_ref::
assign(FwdIt first, FwdIt last,
std::forward_iterator_tag)
{
u_->edit_params(
begin().it_,
end().it_,
detail::make_params_encoded_iter(
first, last));
}
template<class FwdIt>
auto
params_encoded_ref::
insert(
iterator before,
FwdIt first,
FwdIt last,
std::forward_iterator_tag) ->
iterator
{
return u_->edit_params(
before.it_,
before.it_,
detail::make_params_encoded_iter(
first, last));
}
} // urls
} // boost
#endif

View File

@@ -0,0 +1,240 @@
//
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/url
//
#ifndef BOOST_URL_IMPL_PARAMS_REF_HPP
#define BOOST_URL_IMPL_PARAMS_REF_HPP
#include <boost/url/params_view.hpp>
#include <boost/url/detail/any_params_iter.hpp>
#include <boost/url/detail/except.hpp>
#include <boost/url/grammar/recycled.hpp>
#include <boost/assert.hpp>
namespace boost {
namespace urls {
inline
params_ref::
params_ref(
url_base& u,
encoding_opts opt) noexcept
: params_base(u.impl_, opt)
, u_(&u)
{
}
//------------------------------------------------
//
// Special Members
//
//------------------------------------------------
inline
params_ref::
params_ref(
params_ref const& other,
encoding_opts opt) noexcept
: params_ref(*other.u_, opt)
{
}
inline
auto
params_ref::
operator=(std::initializer_list<
param_view> init) ->
params_ref&
{
assign(init);
return *this;
}
//------------------------------------------------
//
// Modifiers
//
//------------------------------------------------
inline
void
params_ref::
clear() noexcept
{
u_->remove_query();
}
//------------------------------------------------
template<class FwdIt>
void
params_ref::
assign(FwdIt first, FwdIt last)
{
/* If you get a compile error here, it
means that the iterators you passed
do not meet the requirements stated
in the documentation.
*/
static_assert(
std::is_convertible<
typename std::iterator_traits<
FwdIt>::reference,
param_view>::value,
"Type requirements not met");
assign(first, last,
typename std::iterator_traits<
FwdIt>::iterator_category{});
}
inline
auto
params_ref::
append(
param_view const& p) ->
iterator
{
return insert(end(), p);
}
inline
auto
params_ref::
append(
std::initializer_list<
param_view> init) ->
iterator
{
return insert(end(), init);
}
template<class FwdIt>
auto
params_ref::
append(FwdIt first, FwdIt last) ->
iterator
{
/* If you get a compile error here, it
means that the iterators you passed
do not meet the requirements stated
in the documentation.
*/
static_assert(
std::is_convertible<
typename std::iterator_traits<
FwdIt>::reference,
param_view>::value,
"Type requirements not met");
return insert(
end(), first, last);
}
template<class FwdIt>
auto
params_ref::
insert(
iterator before,
FwdIt first,
FwdIt last) ->
iterator
{
/* If you get a compile error here, it
means that the iterators you passed
do not meet the requirements stated
in the documentation.
*/
static_assert(
std::is_convertible<
typename std::iterator_traits<
FwdIt>::reference,
param_view>::value,
"Type requirements not met");
return insert(
before,
first,
last,
typename std::iterator_traits<
FwdIt>::iterator_category{});
}
template<class FwdIt>
auto
params_ref::
replace(
iterator from,
iterator to,
FwdIt first,
FwdIt last) ->
iterator
{
/* If you get a compile error here, it
means that the iterators you passed
do not meet the requirements stated
in the documentation.
*/
static_assert(
std::is_convertible<
typename std::iterator_traits<
FwdIt>::reference,
param_view>::value,
"Type requirements not met");
return iterator(
u_->edit_params(
from.it_, to.it_,
detail::make_params_iter(
first, last)),
opt_);
}
//------------------------------------------------
//
// implementation
//
//------------------------------------------------
template<class FwdIt>
void
params_ref::
assign(FwdIt first, FwdIt last,
std::forward_iterator_tag)
{
u_->edit_params(
begin().it_,
end().it_,
detail::make_params_iter(
first, last));
}
template<class FwdIt>
auto
params_ref::
insert(
iterator before,
FwdIt first,
FwdIt last,
std::forward_iterator_tag) ->
iterator
{
return iterator(
u_->edit_params(
before.it_,
before.it_,
detail::make_params_iter(
first, last)),
opt_);
}
} // urls
} // boost
#endif

View File

@@ -0,0 +1,126 @@
//
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/url
//
#ifndef BOOST_URL_IMPL_SEGMENTS_BASE_HPP
#define BOOST_URL_IMPL_SEGMENTS_BASE_HPP
#include <boost/url/detail/segments_iter_impl.hpp>
#include <boost/assert.hpp>
#include <iterator>
namespace boost {
namespace urls {
class segments_base::iterator
{
detail::segments_iter_impl it_;
friend class segments_base;
friend class segments_ref;
iterator(detail::path_ref const&) noexcept;
iterator(detail::path_ref const&, int) noexcept;
iterator(
detail::segments_iter_impl const& it) noexcept
: it_(it)
{
}
public:
using value_type = segments_base::value_type;
using reference = segments_base::reference;
using pointer = reference;
using difference_type =
segments_base::difference_type;
using iterator_category =
std::bidirectional_iterator_tag;
iterator() = default;
iterator(iterator const&) = default;
iterator& operator=(
iterator const&) noexcept = default;
BOOST_URL_DECL
reference
operator*() const;
// the return value is too expensive
pointer operator->() const = delete;
iterator&
operator++() noexcept
{
it_.increment();
return *this;
}
iterator&
operator--() noexcept
{
it_.decrement();
return *this;
}
iterator
operator++(int) noexcept
{
auto tmp = *this;
++*this;
return tmp;
}
iterator
operator--(int) noexcept
{
auto tmp = *this;
--*this;
return tmp;
}
bool
operator==(
iterator const& other) const noexcept
{
return it_.equal(other.it_);
}
bool
operator!=(
iterator const& other) const noexcept
{
return ! it_.equal(other.it_);
}
};
//------------------------------------------------
inline
std::string
segments_base::
front() const noexcept
{
BOOST_ASSERT(! empty());
return *begin();
}
inline
std::string
segments_base::
back() const noexcept
{
BOOST_ASSERT(! empty());
return *--end();
}
} // urls
} // boost
#endif

View File

@@ -0,0 +1,132 @@
//
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/url
//
#ifndef BOOST_URL_IMPL_SEGMENTS_ENCODED_BASE_HPP
#define BOOST_URL_IMPL_SEGMENTS_ENCODED_BASE_HPP
#include <boost/url/detail/segments_iter_impl.hpp>
#include <boost/assert.hpp>
namespace boost {
namespace urls {
class segments_encoded_base::iterator
{
detail::segments_iter_impl it_;
friend class url_base;
friend class segments_encoded_base;
friend class segments_encoded_ref;
iterator(detail::path_ref const&) noexcept;
iterator(detail::path_ref const&, int) noexcept;
iterator(
detail::segments_iter_impl const& it) noexcept
: it_(it)
{
}
public:
using value_type =
segments_encoded_base::value_type;
using reference =
segments_encoded_base::reference;
using pointer = reference;
using difference_type = std::ptrdiff_t;
using iterator_category =
std::bidirectional_iterator_tag;
iterator() = default;
iterator(iterator const&) = default;
iterator& operator=(
iterator const&) = default;
reference
operator*() const noexcept
{
return it_.dereference();
}
pointer
operator->() const noexcept
{
return it_.dereference();
}
iterator&
operator++() noexcept
{
it_.increment();
return *this;
}
iterator&
operator--() noexcept
{
it_.decrement();
return *this;
}
iterator
operator++(int) noexcept
{
auto tmp = *this;
++*this;
return tmp;
}
iterator
operator--(int) noexcept
{
auto tmp = *this;
--*this;
return tmp;
}
bool
operator==(
iterator const& other) const noexcept
{
return it_.equal(other.it_);
}
bool
operator!=(
iterator const& other) const noexcept
{
return ! it_.equal(other.it_);
}
};
//------------------------------------------------
inline
pct_string_view
segments_encoded_base::
front() const noexcept
{
BOOST_ASSERT(! empty());
return *begin();
}
inline
pct_string_view
segments_encoded_base::
back() const noexcept
{
BOOST_ASSERT(! empty());
return *--end();
}
} // urls
} // boost
#endif

View File

@@ -0,0 +1,170 @@
//
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/url
//
#ifndef BOOST_URL_IMPL_SEGMENTS_ENCODED_REF_HPP
#define BOOST_URL_IMPL_SEGMENTS_ENCODED_REF_HPP
#include <boost/url/detail/config.hpp>
#include <boost/url/detail/segments_iter_impl.hpp>
#include <boost/url/detail/any_segments_iter.hpp>
#include <type_traits>
namespace boost {
namespace urls {
//------------------------------------------------
//
// Modifiers
//
//------------------------------------------------
inline
void
segments_encoded_ref::
clear() noexcept
{
erase(begin(), end());
}
template<class FwdIt>
void
segments_encoded_ref::
assign(
FwdIt first, FwdIt last)
{
/* If you get a compile error here, it
means that the iterators you passed
do not meet the requirements stated
in the documentation.
*/
static_assert(
std::is_convertible<
typename std::iterator_traits<
FwdIt>::reference,
core::string_view>::value,
"Type requirements not met");
u_->edit_segments(
begin().it_,
end().it_,
detail::make_segments_encoded_iter(
first, last));
}
template<class FwdIt>
auto
segments_encoded_ref::
insert(
iterator before,
FwdIt first,
FwdIt last) ->
iterator
{
/* If you get a compile error here, it
means that the iterators you passed
do not meet the requirements stated
in the documentation.
*/
static_assert(
std::is_convertible<
typename std::iterator_traits<
FwdIt>::reference,
core::string_view>::value,
"Type requirements not met");
return insert(
before,
first,
last,
typename std::iterator_traits<
FwdIt>::iterator_category{});
}
inline
auto
segments_encoded_ref::
erase(
iterator pos) noexcept ->
iterator
{
return erase(pos, std::next(pos));
}
template<class FwdIt>
auto
segments_encoded_ref::
replace(
iterator from,
iterator to,
FwdIt first,
FwdIt last) ->
iterator
{
/* If you get a compile error here, it
means that the iterators you passed
do not meet the requirements stated
in the documentation.
*/
static_assert(
std::is_convertible<
typename std::iterator_traits<
FwdIt>::reference,
core::string_view>::value,
"Type requirements not met");
return u_->edit_segments(
from.it_,
to.it_,
detail::make_segments_encoded_iter(
first, last));
}
//------------------------------------------------
inline
void
segments_encoded_ref::
push_back(
pct_string_view s)
{
insert(end(), s);
}
inline
void
segments_encoded_ref::
pop_back() noexcept
{
erase(std::prev(end()));
}
//------------------------------------------------
template<class FwdIt>
auto
segments_encoded_ref::
insert(
iterator before,
FwdIt first,
FwdIt last,
std::forward_iterator_tag) ->
iterator
{
return u_->edit_segments(
before.it_,
before.it_,
detail::make_segments_encoded_iter(
first, last));
}
} // urls
} // boost
#endif

View File

@@ -0,0 +1,169 @@
//
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/url
//
#ifndef BOOST_URL_IMPL_SEGMENTS_REF_HPP
#define BOOST_URL_IMPL_SEGMENTS_REF_HPP
#include <boost/url/detail/config.hpp>
#include <boost/url/detail/any_segments_iter.hpp>
#include <boost/url/detail/segments_iter_impl.hpp>
#include <type_traits>
namespace boost {
namespace urls {
//------------------------------------------------
//
// Modifiers
//
//------------------------------------------------
inline
void
segments_ref::
clear() noexcept
{
erase(begin(), end());
}
template<class FwdIt>
void
segments_ref::
assign(FwdIt first, FwdIt last)
{
/* If you get a compile error here, it
means that the iterators you passed
do not meet the requirements stated
in the documentation.
*/
static_assert(
std::is_convertible<
typename std::iterator_traits<
FwdIt>::reference,
core::string_view>::value,
"Type requirements not met");
u_->edit_segments(
begin().it_,
end().it_,
detail::make_segments_iter(
first, last));
}
template<class FwdIt>
auto
segments_ref::
insert(
iterator before,
FwdIt first,
FwdIt last) ->
iterator
{
/* If you get a compile error here, it
means that the iterators you passed
do not meet the requirements stated
in the documentation.
*/
static_assert(
std::is_convertible<
typename std::iterator_traits<
FwdIt>::reference,
core::string_view>::value,
"Type requirements not met");
return insert(
before,
first,
last,
typename std::iterator_traits<
FwdIt>::iterator_category{});
}
inline
auto
segments_ref::
erase(
iterator pos) noexcept ->
iterator
{
return erase(pos, std::next(pos));
}
template<class FwdIt>
auto
segments_ref::
replace(
iterator from,
iterator to,
FwdIt first,
FwdIt last) ->
iterator
{
/* If you get a compile error here, it
means that the iterators you passed
do not meet the requirements stated
in the documentation.
*/
static_assert(
std::is_convertible<
typename std::iterator_traits<
FwdIt>::reference,
core::string_view>::value,
"Type requirements not met");
return u_->edit_segments(
from.it_,
to.it_,
detail::make_segments_iter(
first, last));
}
//------------------------------------------------
inline
void
segments_ref::
push_back(
core::string_view s)
{
insert(end(), s);
}
inline
void
segments_ref::
pop_back() noexcept
{
erase(std::prev(end()));
}
//------------------------------------------------
template<class FwdIt>
auto
segments_ref::
insert(
iterator before,
FwdIt first,
FwdIt last,
std::forward_iterator_tag) ->
iterator
{
return u_->edit_segments(
before.it_,
before.it_,
detail::make_segments_iter(
first, last));
}
} // urls
} // boost
#endif