parser.hpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //
  2. // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot 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/beast
  8. //
  9. #ifndef BOOST_BEAST_HTTP_IMPL_PARSER_HPP
  10. #define BOOST_BEAST_HTTP_IMPL_PARSER_HPP
  11. #include <boost/throw_exception.hpp>
  12. #include <stdexcept>
  13. namespace boost {
  14. namespace beast {
  15. namespace http {
  16. template<bool isRequest, class Body, class Allocator>
  17. parser<isRequest, Body, Allocator>::
  18. parser()
  19. : rd_(m_.base(), m_.body())
  20. {
  21. }
  22. template<bool isRequest, class Body, class Allocator>
  23. template<class Arg1, class... ArgN, class>
  24. parser<isRequest, Body, Allocator>::
  25. parser(Arg1&& arg1, ArgN&&... argn)
  26. : m_(
  27. std::forward<Arg1>(arg1),
  28. std::forward<ArgN>(argn)...)
  29. , rd_(m_.base(), m_.body())
  30. {
  31. m_.clear();
  32. }
  33. template<bool isRequest, class Body, class Allocator>
  34. template<class OtherBody, class... Args, class>
  35. parser<isRequest, Body, Allocator>::
  36. parser(
  37. parser<isRequest, OtherBody, Allocator>&& other,
  38. Args&&... args)
  39. : basic_parser<isRequest>(std::move(other))
  40. , m_(other.release(), std::forward<Args>(args)...)
  41. , rd_(m_.base(), m_.body())
  42. {
  43. if(other.rd_inited_)
  44. BOOST_THROW_EXCEPTION(std::invalid_argument{
  45. "moved-from parser has a body"});
  46. }
  47. } // http
  48. } // beast
  49. } // boost
  50. #endif