1  
//
1  
//
2  
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
2  
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
3  
//
3  
//
4  
// Distributed under the Boost Software License, Version 1.0. (See accompanying
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)
5  
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6  
//
6  
//
7  
// Official repository: https://github.com/boostorg/json
7  
// Official repository: https://github.com/boostorg/json
8  
//
8  
//
9  

9  

10  
#ifndef BOOST_JSON_DETAIL_IMPL_HANDLER_HPP
10  
#ifndef BOOST_JSON_DETAIL_IMPL_HANDLER_HPP
11  
#define BOOST_JSON_DETAIL_IMPL_HANDLER_HPP
11  
#define BOOST_JSON_DETAIL_IMPL_HANDLER_HPP
12  

12  

13  
#include <boost/json/detail/handler.hpp>
13  
#include <boost/json/detail/handler.hpp>
14  
#include <utility>
14  
#include <utility>
15  

15  

16  
namespace boost {
16  
namespace boost {
17  
namespace json {
17  
namespace json {
18  
namespace detail {
18  
namespace detail {
19  

19  

20  
template<class... Args>
20  
template<class... Args>
21  
handler::
21  
handler::
22  
handler(Args&&... args)
22  
handler(Args&&... args)
23  
    : st(std::forward<Args>(args)...)
23  
    : st(std::forward<Args>(args)...)
24  
{
24  
{
25  
}
25  
}
26  

26  

27  
bool
27  
bool
28  
handler::
28  
handler::
29  
on_document_begin(
29  
on_document_begin(
30  
    system::error_code&)
30  
    system::error_code&)
31  
{
31  
{
32  
    return true;
32  
    return true;
33  
}
33  
}
34  

34  

35  
bool
35  
bool
36  
handler::
36  
handler::
37  
on_document_end(
37  
on_document_end(
38  
    system::error_code&)
38  
    system::error_code&)
39  
{
39  
{
40  
    return true;
40  
    return true;
41  
}
41  
}
42  

42  

43  
bool
43  
bool
44  
handler::
44  
handler::
45  
on_object_begin(
45  
on_object_begin(
46  
    system::error_code&)
46  
    system::error_code&)
47  
{
47  
{
48  
    return true;
48  
    return true;
49  
}
49  
}
50  

50  

51  
bool
51  
bool
52  
handler::
52  
handler::
53  
on_object_end(
53  
on_object_end(
54  
    std::size_t n,
54  
    std::size_t n,
55  
    system::error_code&)
55  
    system::error_code&)
56  
{
56  
{
57  
    st.push_object(n);
57  
    st.push_object(n);
58  
    return true;
58  
    return true;
59  
}
59  
}
60  

60  

61  
bool
61  
bool
62  
handler::
62  
handler::
63  
on_array_begin(
63  
on_array_begin(
64  
    system::error_code&)
64  
    system::error_code&)
65  
{
65  
{
66  
    return true;
66  
    return true;
67  
}
67  
}
68  

68  

69  
bool
69  
bool
70  
handler::
70  
handler::
71  
on_array_end(
71  
on_array_end(
72  
    std::size_t n,
72  
    std::size_t n,
73  
    system::error_code&)
73  
    system::error_code&)
74  
{
74  
{
75  
    st.push_array(n);
75  
    st.push_array(n);
76  
    return true;
76  
    return true;
77  
}
77  
}
78  

78  

79  
bool
79  
bool
80  
handler::
80  
handler::
81  
on_key_part(
81  
on_key_part(
82  
    string_view s,
82  
    string_view s,
83  
    std::size_t,
83  
    std::size_t,
84  
    system::error_code&)
84  
    system::error_code&)
85  
{
85  
{
86  
    st.push_chars(s);
86  
    st.push_chars(s);
87  
    return true;
87  
    return true;
88  
}
88  
}
89  

89  

90  
bool
90  
bool
91  
handler::
91  
handler::
92  
on_key(
92  
on_key(
93  
    string_view s,
93  
    string_view s,
94  
    std::size_t,
94  
    std::size_t,
95  
    system::error_code&)
95  
    system::error_code&)
96  
{
96  
{
97  
    st.push_key(s);
97  
    st.push_key(s);
98  
    return true;
98  
    return true;
99  
}
99  
}
100  

100  

101  
bool
101  
bool
102  
handler::
102  
handler::
103  
on_string_part(
103  
on_string_part(
104  
    string_view s,
104  
    string_view s,
105  
    std::size_t,
105  
    std::size_t,
106  
    system::error_code&)
106  
    system::error_code&)
107  
{
107  
{
108  
    st.push_chars(s);
108  
    st.push_chars(s);
109  
    return true;
109  
    return true;
110  
}
110  
}
111  

111  

112  
bool
112  
bool
113  
handler::
113  
handler::
114  
on_string(
114  
on_string(
115  
    string_view s,
115  
    string_view s,
116  
    std::size_t,
116  
    std::size_t,
117  
    system::error_code&)
117  
    system::error_code&)
118  
{
118  
{
119  
    st.push_string(s);
119  
    st.push_string(s);
120  
    return true;
120  
    return true;
121  
}
121  
}
122  

122  

123  
bool
123  
bool
124  
handler::
124  
handler::
125  
on_number_part(
125  
on_number_part(
126  
    string_view,
126  
    string_view,
127  
    system::error_code&)
127  
    system::error_code&)
128  
{
128  
{
129  
    return true;
129  
    return true;
130  
}
130  
}
131  

131  

132  
bool
132  
bool
133  
handler::
133  
handler::
134  
on_int64(
134  
on_int64(
135  
    std::int64_t i,
135  
    std::int64_t i,
136  
    string_view,
136  
    string_view,
137  
    system::error_code&)
137  
    system::error_code&)
138  
{
138  
{
139  
    st.push_int64(i);
139  
    st.push_int64(i);
140  
    return true;
140  
    return true;
141  
}
141  
}
142  

142  

143  
bool
143  
bool
144  
handler::
144  
handler::
145  
on_uint64(
145  
on_uint64(
146  
    std::uint64_t u,
146  
    std::uint64_t u,
147  
    string_view,
147  
    string_view,
148  
    system::error_code&)
148  
    system::error_code&)
149  
{
149  
{
150  
    st.push_uint64(u);
150  
    st.push_uint64(u);
151  
    return true;
151  
    return true;
152  
}
152  
}
153  

153  

154  
bool
154  
bool
155  
handler::
155  
handler::
156  
on_double(
156  
on_double(
157  
    double d,
157  
    double d,
158  
    string_view,
158  
    string_view,
159  
    system::error_code&)
159  
    system::error_code&)
160  
{
160  
{
161  
    st.push_double(d);
161  
    st.push_double(d);
162  
    return true;
162  
    return true;
163  
}
163  
}
164  

164  

165  
bool
165  
bool
166  
handler::
166  
handler::
167  
on_bool(
167  
on_bool(
168  
    bool b,
168  
    bool b,
169  
    system::error_code&)
169  
    system::error_code&)
170  
{
170  
{
171  
    st.push_bool(b);
171  
    st.push_bool(b);
172  
    return true;
172  
    return true;
173  
}
173  
}
174  

174  

175  
bool
175  
bool
176  
handler::
176  
handler::
177  
on_null(system::error_code&)
177  
on_null(system::error_code&)
178  
{
178  
{
179  
    st.push_null();
179  
    st.push_null();
180  
    return true;
180  
    return true;
181  
}
181  
}
182  

182  

183  
bool
183  
bool
184  
handler::
184  
handler::
185  
on_comment_part(
185  
on_comment_part(
186  
    string_view,
186  
    string_view,
187  
    system::error_code&)
187  
    system::error_code&)
188  
{
188  
{
189  
    return true;
189  
    return true;
190  
}
190  
}
191  

191  

192  
bool
192  
bool
193  
handler::
193  
handler::
194  
on_comment(
194  
on_comment(
195  
    string_view, system::error_code&)
195  
    string_view, system::error_code&)
196  
{
196  
{
197  
    return true;
197  
    return true;
198  
}
198  
}
199  

199  

200  
} // detail
200  
} // detail
201  
} // namespace json
201  
} // namespace json
202  
} // namespace boost
202  
} // namespace boost
203  

203  

204  
#endif
204  
#endif