• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
10 #ifndef BOOST_BEAST_HTTP_IMPL_PARSER_HPP
11 #define BOOST_BEAST_HTTP_IMPL_PARSER_HPP
12 
13 #include <boost/throw_exception.hpp>
14 #include <stdexcept>
15 
16 namespace boost {
17 namespace beast {
18 namespace http {
19 
20 template<bool isRequest, class Body, class Allocator>
21 parser<isRequest, Body, Allocator>::
parser()22 parser()
23     : rd_(m_.base(), m_.body())
24 {
25 }
26 
27 template<bool isRequest, class Body, class Allocator>
28 template<class Arg1, class... ArgN, class>
29 parser<isRequest, Body, Allocator>::
parser(Arg1 && arg1,ArgN &&...argn)30 parser(Arg1&& arg1, ArgN&&... argn)
31     : m_(
32         std::forward<Arg1>(arg1),
33         std::forward<ArgN>(argn)...)
34     , rd_(m_.base(), m_.body())
35 {
36     m_.clear();
37 }
38 
39 template<bool isRequest, class Body, class Allocator>
40 template<class OtherBody, class... Args, class>
41 parser<isRequest, Body, Allocator>::
parser(parser<isRequest,OtherBody,Allocator> && other,Args &&...args)42 parser(
43     parser<isRequest, OtherBody, Allocator>&& other,
44     Args&&... args)
45     : basic_parser<isRequest>(std::move(other))
46     , m_(other.release(), std::forward<Args>(args)...)
47     , rd_(m_.base(), m_.body())
48 {
49     if(other.rd_inited_)
50         BOOST_THROW_EXCEPTION(std::invalid_argument{
51             "moved-from parser has a body"});
52 }
53 
54 } // http
55 } // beast
56 } // boost
57 
58 #endif
59