url_view.ipp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //
  2. // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
  3. // Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
  4. //
  5. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  6. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. //
  8. // Official repository: https://github.com/boostorg/url
  9. //
  10. #ifndef BOOST_URL_IMPL_URL_VIEW_IPP
  11. #define BOOST_URL_IMPL_URL_VIEW_IPP
  12. #include <boost/url/url_view.hpp>
  13. #include <boost/url/detail/except.hpp>
  14. namespace boost {
  15. namespace urls {
  16. namespace detail {
  17. url_view
  18. url_impl::
  19. construct() const noexcept
  20. {
  21. return url_view(*this);
  22. }
  23. } // detail
  24. //------------------------------------------------
  25. url_view::
  26. url_view() noexcept = default;
  27. url_view::
  28. url_view(string_view s)
  29. : url_view(parse_uri_reference(s
  30. ).value(BOOST_URL_POS))
  31. {
  32. }
  33. url_view::
  34. url_view(
  35. url_view_base const& u) noexcept
  36. : url_view_base(u.impl_)
  37. {
  38. if (u.pi_->from_ == from::url)
  39. {
  40. pi_ = u.pi_;
  41. }
  42. else
  43. {
  44. impl_ = u.impl_;
  45. pi_ = &impl_;
  46. }
  47. }
  48. url_view&
  49. url_view::
  50. operator=(
  51. url_view_base const& u) noexcept
  52. {
  53. if (pi_ == u.pi_)
  54. return *this;
  55. if (u.pi_->from_ == from::url)
  56. {
  57. pi_ = u.pi_;
  58. }
  59. else
  60. {
  61. impl_ = u.impl_;
  62. pi_ = &impl_;
  63. }
  64. return *this;
  65. }
  66. } // urls
  67. } // boost
  68. #endif