123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240 |
- //
- // Copyright (c) 2019 Vinnie Falco ([email protected])
- // Copyright (c) 2022 Alan de Freitas ([email protected])
- //
- // 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
|