]>
Commit | Line | Data |
---|---|---|
b32b8144 FG |
1 | // |
2 | // Copyright (c) 2016-2017 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_IPP | |
11 | #define BOOST_BEAST_HTTP_IMPL_PARSER_IPP | |
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>:: | |
22 | parser() | |
11fdf7f2 TL |
23 | : parser{detail::has_deprecated_body_reader<Body>{}} |
24 | { | |
25 | } | |
26 | ||
27 | template<bool isRequest, class Body, class Allocator> | |
28 | parser<isRequest, Body, Allocator>:: | |
29 | parser(std::true_type) | |
30 | : rd_(m_) | |
31 | { | |
32 | #ifndef BOOST_BEAST_ALLOW_DEPRECATED | |
33 | // Deprecated BodyReader Concept (v1.66) | |
34 | static_assert(sizeof(Body) == 0, | |
35 | BOOST_BEAST_DEPRECATION_STRING); | |
36 | #endif | |
37 | } | |
38 | ||
39 | template<bool isRequest, class Body, class Allocator> | |
40 | parser<isRequest, Body, Allocator>:: | |
41 | parser(std::false_type) | |
42 | : rd_(m_.base(), m_.body()) | |
b32b8144 FG |
43 | { |
44 | } | |
45 | ||
46 | template<bool isRequest, class Body, class Allocator> | |
47 | template<class Arg1, class... ArgN, class> | |
48 | parser<isRequest, Body, Allocator>:: | |
49 | parser(Arg1&& arg1, ArgN&&... argn) | |
11fdf7f2 TL |
50 | : parser(std::forward<Arg1>(arg1), |
51 | detail::has_deprecated_body_reader<Body>{}, | |
52 | std::forward<ArgN>(argn)...) | |
53 | { | |
54 | } | |
55 | ||
56 | // VFALCO arg1 comes before `true_type` to make | |
57 | // the signature unambiguous. | |
58 | template<bool isRequest, class Body, class Allocator> | |
59 | template<class Arg1, class... ArgN, class> | |
60 | parser<isRequest, Body, Allocator>:: | |
61 | parser(Arg1&& arg1, std::true_type, ArgN&&... argn) | |
b32b8144 FG |
62 | : m_(std::forward<Arg1>(arg1), |
63 | std::forward<ArgN>(argn)...) | |
11fdf7f2 | 64 | , rd_(m_) |
b32b8144 FG |
65 | { |
66 | m_.clear(); | |
11fdf7f2 TL |
67 | #ifndef BOOST_BEAST_ALLOW_DEPRECATED |
68 | /* Deprecated BodyWriter Concept (v1.66) */ | |
69 | static_assert(sizeof(Body) == 0, | |
70 | BOOST_BEAST_DEPRECATION_STRING); | |
71 | #endif // BOOST_BEAST_ALLOW_DEPRECATED | |
72 | } | |
73 | ||
74 | // VFALCO arg1 comes before `false_type` to make | |
75 | // the signature unambiguous. | |
76 | template<bool isRequest, class Body, class Allocator> | |
77 | template<class Arg1, class... ArgN, class> | |
78 | parser<isRequest, Body, Allocator>:: | |
79 | parser(Arg1&& arg1, std::false_type, ArgN&&... argn) | |
80 | : m_(std::forward<Arg1>(arg1), | |
81 | std::forward<ArgN>(argn)...) | |
82 | , rd_(m_.base(), m_.body()) | |
83 | { | |
84 | m_.clear(); | |
85 | } | |
86 | ||
87 | template<bool isRequest, class Body, class Allocator> | |
88 | template<class OtherBody, class... Args, class> | |
89 | parser<isRequest, Body, Allocator>:: | |
90 | parser( | |
91 | parser<isRequest, OtherBody, Allocator>&& other, | |
92 | Args&&... args) | |
93 | : parser(detail::has_deprecated_body_reader<Body>{}, | |
94 | std::move(other), std::forward<Args>(args)...) | |
95 | { | |
96 | } | |
97 | ||
98 | template<bool isRequest, class Body, class Allocator> | |
99 | template<class OtherBody, class... Args, class> | |
100 | parser<isRequest, Body, Allocator>:: | |
101 | parser(std::true_type, | |
102 | parser<isRequest, OtherBody, Allocator>&& other, | |
103 | Args&&... args) | |
104 | : base_type(std::move(other)) | |
105 | , m_(other.release(), std::forward<Args>(args)...) | |
106 | , rd_(m_) | |
107 | { | |
108 | if(other.rd_inited_) | |
109 | BOOST_THROW_EXCEPTION(std::invalid_argument{ | |
110 | "moved-from parser has a body"}); | |
111 | #ifndef BOOST_BEAST_ALLOW_DEPRECATED | |
112 | // Deprecated BodyReader Concept (v1.66) | |
113 | static_assert(sizeof(Body) == 0, | |
114 | BOOST_BEAST_DEPRECATION_STRING); | |
115 | #endif | |
b32b8144 FG |
116 | } |
117 | ||
118 | template<bool isRequest, class Body, class Allocator> | |
119 | template<class OtherBody, class... Args, class> | |
120 | parser<isRequest, Body, Allocator>:: | |
11fdf7f2 | 121 | parser(std::false_type, parser<isRequest, OtherBody, Allocator>&& other, |
b32b8144 FG |
122 | Args&&... args) |
123 | : base_type(std::move(other)) | |
124 | , m_(other.release(), std::forward<Args>(args)...) | |
11fdf7f2 | 125 | , rd_(m_.base(), m_.body()) |
b32b8144 FG |
126 | { |
127 | if(other.rd_inited_) | |
128 | BOOST_THROW_EXCEPTION(std::invalid_argument{ | |
129 | "moved-from parser has a body"}); | |
130 | } | |
131 | ||
132 | } // http | |
133 | } // beast | |
134 | } // boost | |
135 | ||
136 | #endif |