static_url.ipp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //
  2. // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // Official repository: https://github.com/boostorg/url
  8. //
  9. #ifndef BOOST_URL_IMPL_STATIC_URL_IPP
  10. #define BOOST_URL_IMPL_STATIC_URL_IPP
  11. #include <boost/url/static_url.hpp>
  12. #include <boost/url/url_view.hpp>
  13. #include <boost/url/detail/except.hpp>
  14. #include <boost/assert.hpp>
  15. namespace boost {
  16. namespace urls {
  17. static_url_base::
  18. static_url_base(
  19. char* buf,
  20. std::size_t cap) noexcept
  21. {
  22. s_ = buf;
  23. cap_ = cap;
  24. s_[0] = '\0';
  25. impl_.cs_ = s_;
  26. }
  27. static_url_base::
  28. static_url_base(
  29. char* buf,
  30. std::size_t cap,
  31. string_view s)
  32. : static_url_base(buf, cap)
  33. {
  34. copy(parse_uri_reference(s
  35. ).value(BOOST_URL_POS));
  36. }
  37. void
  38. static_url_base::
  39. clear_impl() noexcept
  40. {
  41. impl_ = {from::url};
  42. s_[0] = '\0';
  43. impl_.cs_ = s_;
  44. }
  45. void
  46. static_url_base::
  47. reserve_impl(
  48. std::size_t n,
  49. op_t&)
  50. {
  51. if(n <= cap_)
  52. return;
  53. detail::throw_length_error();
  54. }
  55. //----------------------------------------------------------
  56. void
  57. static_url_base::
  58. cleanup(op_t&)
  59. {
  60. }
  61. } // urls
  62. } // boost
  63. #endif