jsoncons 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ext/jsoncons/extconf.rb +43 -0
- data/ext/jsoncons/jsoncons.cpp +161 -0
- data/ext/jsoncons/jsoncons.h +10 -0
- data/jsoncons.gemspec +44 -0
- data/lib/jsoncons/jsoncons/examples/input/address-book.json +13 -0
- data/lib/jsoncons/jsoncons/examples/input/books.json +28 -0
- data/lib/jsoncons/jsoncons/examples/input/countries.json +7 -0
- data/lib/jsoncons/jsoncons/examples/input/employees.json +30 -0
- data/lib/jsoncons/jsoncons/examples/input/jsonschema/name.json +15 -0
- data/lib/jsoncons/jsoncons/examples/input/multiple-json-objects.json +3 -0
- data/lib/jsoncons/jsoncons/examples/input/sales.csv +6 -0
- data/lib/jsoncons/jsoncons/examples/input/store.json +28 -0
- data/lib/jsoncons/jsoncons/examples/input/tasks.csv +6 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/allocator_holder.hpp +38 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/basic_json.hpp +5905 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/bigint.hpp +1611 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/byte_string.hpp +820 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/config/binary_config.hpp +226 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/config/compiler_support.hpp +375 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/config/jsoncons_config.hpp +309 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/config/version.hpp +40 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/conv_error.hpp +218 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/decode_json.hpp +209 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/decode_traits.hpp +651 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/detail/endian.hpp +44 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/detail/grisu3.hpp +312 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/detail/optional.hpp +483 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/detail/parse_number.hpp +1133 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/detail/span.hpp +188 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/detail/string_view.hpp +537 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/detail/string_wrapper.hpp +370 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/detail/write_number.hpp +567 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/encode_json.hpp +315 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/encode_traits.hpp +378 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/json.hpp +18 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/json_array.hpp +324 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/json_content_handler.hpp +12 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/json_cursor.hpp +448 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/json_decoder.hpp +420 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/json_encoder.hpp +1587 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/json_error.hpp +156 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/json_exception.hpp +241 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/json_filter.hpp +653 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/json_fwd.hpp +23 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/json_object.hpp +1772 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/json_options.hpp +862 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/json_parser.hpp +2900 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/json_reader.hpp +731 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/json_traits_macros.hpp +1072 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/json_traits_macros_deprecated.hpp +144 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/json_type.hpp +206 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/json_type_traits.hpp +1830 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/json_visitor.hpp +1560 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/json_visitor2.hpp +2079 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/pretty_print.hpp +89 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/ser_context.hpp +62 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/sink.hpp +289 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/source.hpp +777 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/source_adaptor.hpp +148 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/staj2_cursor.hpp +1189 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/staj_cursor.hpp +1254 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/staj_iterator.hpp +449 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/tag_type.hpp +245 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/text_source_adaptor.hpp +144 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/traits_extension.hpp +884 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/typed_array_view.hpp +250 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/unicode_traits.hpp +1330 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/uri.hpp +635 -0
- data/lib/jsoncons/jsoncons/include/jsoncons/value_converter.hpp +340 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson.hpp +23 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_cursor.hpp +320 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_decimal128.hpp +865 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_encoder.hpp +585 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_error.hpp +103 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_oid.hpp +245 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_options.hpp +75 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_parser.hpp +645 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_reader.hpp +92 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_type.hpp +44 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/decode_bson.hpp +201 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/encode_bson.hpp +144 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor.hpp +26 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_cursor.hpp +351 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_cursor2.hpp +265 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_detail.hpp +93 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_encoder.hpp +1766 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_error.hpp +105 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_options.hpp +113 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_parser.hpp +1942 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_reader.hpp +116 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/decode_cbor.hpp +203 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/encode_cbor.hpp +151 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv.hpp +17 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv_cursor.hpp +358 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv_encoder.hpp +954 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv_error.hpp +85 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv_options.hpp +973 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv_parser.hpp +2099 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv_reader.hpp +348 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv_serializer.hpp +12 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/decode_csv.hpp +208 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/encode_csv.hpp +122 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/jmespath/jmespath.hpp +5215 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/jmespath/jmespath_error.hpp +215 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpatch/jsonpatch.hpp +579 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpatch/jsonpatch_error.hpp +121 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/expression.hpp +3329 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/flatten.hpp +432 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/json_location.hpp +445 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/json_query.hpp +115 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/jsonpath.hpp +13 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/jsonpath_error.hpp +240 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/jsonpath_expression.hpp +2612 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/jsonpath_selector.hpp +1322 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpointer/jsonpointer.hpp +1577 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpointer/jsonpointer_error.hpp +119 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/format_validator.hpp +968 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/json_validator.hpp +120 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/jsonschema.hpp +13 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/jsonschema_error.hpp +105 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/jsonschema_version.hpp +18 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/keyword_validator.hpp +1745 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/keyword_validator_factory.hpp +556 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/schema_draft7.hpp +198 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/schema_location.hpp +200 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/schema_version.hpp +35 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/subschema.hpp +144 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/mergepatch/mergepatch.hpp +103 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/decode_msgpack.hpp +202 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/encode_msgpack.hpp +142 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack.hpp +24 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_cursor.hpp +343 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_cursor2.hpp +259 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_encoder.hpp +753 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_error.hpp +94 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_options.hpp +74 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_parser.hpp +748 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_reader.hpp +116 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_type.hpp +63 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/decode_ubjson.hpp +201 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/encode_ubjson.hpp +142 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson.hpp +23 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson_cursor.hpp +307 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson_encoder.hpp +502 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson_error.hpp +100 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson_options.hpp +87 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson_parser.hpp +880 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson_reader.hpp +92 -0
- data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson_type.hpp +43 -0
- data/lib/jsoncons/version.rb +5 -0
- data/lib/jsoncons.rb +33 -0
- data/test/jsoncons_test.rb +108 -0
- data/test/test_helper.rb +7 -0
- metadata +268 -0
@@ -0,0 +1,653 @@
|
|
1
|
+
// Copyright 2013 Daniel Parker
|
2
|
+
// Distributed under the Boost license, Version 1.0.
|
3
|
+
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
4
|
+
|
5
|
+
// See https://github.com/danielaparker/jsoncons for latest version
|
6
|
+
|
7
|
+
#ifndef JSONCONS_JSON_FILTER_HPP
|
8
|
+
#define JSONCONS_JSON_FILTER_HPP
|
9
|
+
|
10
|
+
#include <string>
|
11
|
+
|
12
|
+
#include <jsoncons/json_visitor.hpp>
|
13
|
+
|
14
|
+
namespace jsoncons {
|
15
|
+
|
16
|
+
template <class CharT>
|
17
|
+
class basic_json_filter : public basic_json_visitor<CharT>
|
18
|
+
{
|
19
|
+
public:
|
20
|
+
using typename basic_json_visitor<CharT>::char_type;
|
21
|
+
using typename basic_json_visitor<CharT>::string_view_type;
|
22
|
+
private:
|
23
|
+
basic_json_visitor<char_type>* destination_;
|
24
|
+
|
25
|
+
// noncopyable
|
26
|
+
basic_json_filter(const basic_json_filter&) = delete;
|
27
|
+
basic_json_filter& operator=(const basic_json_filter&) = delete;
|
28
|
+
public:
|
29
|
+
basic_json_filter(basic_json_visitor<char_type>& visitor)
|
30
|
+
: destination_(std::addressof(visitor))
|
31
|
+
{
|
32
|
+
}
|
33
|
+
|
34
|
+
// moveable
|
35
|
+
basic_json_filter(basic_json_filter&&) = default;
|
36
|
+
basic_json_filter& operator=(basic_json_filter&&) = default;
|
37
|
+
|
38
|
+
basic_json_visitor<char_type>& destination()
|
39
|
+
{
|
40
|
+
return *destination_;
|
41
|
+
}
|
42
|
+
|
43
|
+
#if !defined(JSONCONS_NO_DEPRECATED)
|
44
|
+
|
45
|
+
JSONCONS_DEPRECATED_MSG("Instead, use destination()")
|
46
|
+
basic_json_visitor<char_type>& to_handler()
|
47
|
+
{
|
48
|
+
return destination_;
|
49
|
+
}
|
50
|
+
JSONCONS_DEPRECATED_MSG("Instead, use destination")
|
51
|
+
basic_json_visitor<char_type>& input_handler()
|
52
|
+
{
|
53
|
+
return destination_;
|
54
|
+
}
|
55
|
+
|
56
|
+
JSONCONS_DEPRECATED_MSG("Instead, use destination")
|
57
|
+
basic_json_visitor<char_type>& downstream_handler()
|
58
|
+
{
|
59
|
+
return destination_;
|
60
|
+
}
|
61
|
+
|
62
|
+
JSONCONS_DEPRECATED_MSG("Instead, use destination")
|
63
|
+
basic_json_visitor<char_type>& destination_handler()
|
64
|
+
{
|
65
|
+
return destination_;
|
66
|
+
}
|
67
|
+
#endif
|
68
|
+
|
69
|
+
private:
|
70
|
+
void visit_flush() override
|
71
|
+
{
|
72
|
+
destination_->flush();
|
73
|
+
}
|
74
|
+
|
75
|
+
bool visit_begin_object(semantic_tag tag, const ser_context& context, std::error_code& ec) override
|
76
|
+
{
|
77
|
+
return destination_->begin_object(tag, context, ec);
|
78
|
+
}
|
79
|
+
|
80
|
+
bool visit_begin_object(std::size_t length, semantic_tag tag, const ser_context& context, std::error_code& ec) override
|
81
|
+
{
|
82
|
+
return destination_->begin_object(length, tag, context, ec);
|
83
|
+
}
|
84
|
+
|
85
|
+
bool visit_end_object(const ser_context& context, std::error_code& ec) override
|
86
|
+
{
|
87
|
+
return destination_->end_object(context, ec);
|
88
|
+
}
|
89
|
+
|
90
|
+
bool visit_begin_array(semantic_tag tag, const ser_context& context, std::error_code& ec) override
|
91
|
+
{
|
92
|
+
return destination_->begin_array(tag, context, ec);
|
93
|
+
}
|
94
|
+
|
95
|
+
bool visit_begin_array(std::size_t length, semantic_tag tag, const ser_context& context, std::error_code& ec) override
|
96
|
+
{
|
97
|
+
return destination_->begin_array(length, tag, context, ec);
|
98
|
+
}
|
99
|
+
|
100
|
+
bool visit_end_array(const ser_context& context, std::error_code& ec) override
|
101
|
+
{
|
102
|
+
return destination_->end_array(context, ec);
|
103
|
+
}
|
104
|
+
|
105
|
+
bool visit_key(const string_view_type& name,
|
106
|
+
const ser_context& context,
|
107
|
+
std::error_code& ec) override
|
108
|
+
{
|
109
|
+
return destination_->key(name, context, ec);
|
110
|
+
}
|
111
|
+
|
112
|
+
bool visit_string(const string_view_type& value,
|
113
|
+
semantic_tag tag,
|
114
|
+
const ser_context& context,
|
115
|
+
std::error_code& ec) override
|
116
|
+
{
|
117
|
+
return destination_->string_value(value, tag, context, ec);
|
118
|
+
}
|
119
|
+
|
120
|
+
bool visit_byte_string(const byte_string_view& b,
|
121
|
+
semantic_tag tag,
|
122
|
+
const ser_context& context,
|
123
|
+
std::error_code& ec) override
|
124
|
+
{
|
125
|
+
return destination_->byte_string_value(b, tag, context, ec);
|
126
|
+
}
|
127
|
+
|
128
|
+
bool visit_byte_string(const byte_string_view& b,
|
129
|
+
uint64_t ext_tag,
|
130
|
+
const ser_context& context,
|
131
|
+
std::error_code& ec) override
|
132
|
+
{
|
133
|
+
return destination_->byte_string_value(b, ext_tag, context, ec);
|
134
|
+
}
|
135
|
+
|
136
|
+
bool visit_uint64(uint64_t value, semantic_tag tag, const ser_context& context, std::error_code& ec) override
|
137
|
+
{
|
138
|
+
return destination_->uint64_value(value, tag, context, ec);
|
139
|
+
}
|
140
|
+
|
141
|
+
bool visit_int64(int64_t value, semantic_tag tag, const ser_context& context, std::error_code& ec) override
|
142
|
+
{
|
143
|
+
return destination_->int64_value(value, tag, context, ec);
|
144
|
+
}
|
145
|
+
|
146
|
+
bool visit_half(uint16_t value, semantic_tag tag, const ser_context& context, std::error_code& ec) override
|
147
|
+
{
|
148
|
+
return destination_->half_value(value, tag, context, ec);
|
149
|
+
}
|
150
|
+
|
151
|
+
bool visit_double(double value, semantic_tag tag, const ser_context& context, std::error_code& ec) override
|
152
|
+
{
|
153
|
+
return destination_->double_value(value, tag, context, ec);
|
154
|
+
}
|
155
|
+
|
156
|
+
bool visit_bool(bool value, semantic_tag tag, const ser_context& context, std::error_code& ec) override
|
157
|
+
{
|
158
|
+
return destination_->bool_value(value, tag, context, ec);
|
159
|
+
}
|
160
|
+
|
161
|
+
bool visit_null(semantic_tag tag, const ser_context& context, std::error_code& ec) override
|
162
|
+
{
|
163
|
+
return destination_->null_value(tag, context, ec);
|
164
|
+
}
|
165
|
+
|
166
|
+
bool visit_typed_array(const jsoncons::span<const uint8_t>& s,
|
167
|
+
semantic_tag tag,
|
168
|
+
const ser_context& context,
|
169
|
+
std::error_code& ec) override
|
170
|
+
{
|
171
|
+
return destination_->typed_array(s, tag, context, ec);
|
172
|
+
}
|
173
|
+
|
174
|
+
bool visit_typed_array(const jsoncons::span<const uint16_t>& s,
|
175
|
+
semantic_tag tag,
|
176
|
+
const ser_context& context,
|
177
|
+
std::error_code& ec) override
|
178
|
+
{
|
179
|
+
return destination_->typed_array(s, tag, context, ec);
|
180
|
+
}
|
181
|
+
|
182
|
+
bool visit_typed_array(const jsoncons::span<const uint32_t>& s,
|
183
|
+
semantic_tag tag,
|
184
|
+
const ser_context& context,
|
185
|
+
std::error_code& ec) override
|
186
|
+
{
|
187
|
+
return destination_->typed_array(s, tag, context, ec);
|
188
|
+
}
|
189
|
+
|
190
|
+
bool visit_typed_array(const jsoncons::span<const uint64_t>& s,
|
191
|
+
semantic_tag tag,
|
192
|
+
const ser_context& context,
|
193
|
+
std::error_code& ec) override
|
194
|
+
{
|
195
|
+
return destination_->typed_array(s, tag, context, ec);
|
196
|
+
}
|
197
|
+
|
198
|
+
bool visit_typed_array(const jsoncons::span<const int8_t>& s,
|
199
|
+
semantic_tag tag,
|
200
|
+
const ser_context& context,
|
201
|
+
std::error_code& ec) override
|
202
|
+
{
|
203
|
+
return destination_->typed_array(s, tag, context, ec);
|
204
|
+
}
|
205
|
+
|
206
|
+
bool visit_typed_array(const jsoncons::span<const int16_t>& s,
|
207
|
+
semantic_tag tag,
|
208
|
+
const ser_context& context,
|
209
|
+
std::error_code& ec) override
|
210
|
+
{
|
211
|
+
return destination_->typed_array(s, tag, context, ec);
|
212
|
+
}
|
213
|
+
|
214
|
+
bool visit_typed_array(const jsoncons::span<const int32_t>& s,
|
215
|
+
semantic_tag tag,
|
216
|
+
const ser_context& context,
|
217
|
+
std::error_code& ec) override
|
218
|
+
{
|
219
|
+
return destination_->typed_array(s, tag, context, ec);
|
220
|
+
}
|
221
|
+
|
222
|
+
bool visit_typed_array(const jsoncons::span<const int64_t>& s,
|
223
|
+
semantic_tag tag,
|
224
|
+
const ser_context& context,
|
225
|
+
std::error_code& ec) override
|
226
|
+
{
|
227
|
+
return destination_->typed_array(s, tag, context, ec);
|
228
|
+
}
|
229
|
+
|
230
|
+
bool visit_typed_array(half_arg_t,
|
231
|
+
const jsoncons::span<const uint16_t>& s,
|
232
|
+
semantic_tag tag,
|
233
|
+
const ser_context& context,
|
234
|
+
std::error_code& ec) override
|
235
|
+
{
|
236
|
+
return destination_->typed_array(half_arg, s, tag, context, ec);
|
237
|
+
}
|
238
|
+
|
239
|
+
bool visit_typed_array(const jsoncons::span<const float>& s,
|
240
|
+
semantic_tag tag,
|
241
|
+
const ser_context& context,
|
242
|
+
std::error_code& ec) override
|
243
|
+
{
|
244
|
+
return destination_->typed_array(s, tag, context, ec);
|
245
|
+
}
|
246
|
+
|
247
|
+
bool visit_typed_array(const jsoncons::span<const double>& s,
|
248
|
+
semantic_tag tag,
|
249
|
+
const ser_context& context,
|
250
|
+
std::error_code& ec) override
|
251
|
+
{
|
252
|
+
return destination_->typed_array(s, tag, context, ec);
|
253
|
+
}
|
254
|
+
|
255
|
+
bool visit_begin_multi_dim(const jsoncons::span<const size_t>& shape,
|
256
|
+
semantic_tag tag,
|
257
|
+
const ser_context& context,
|
258
|
+
std::error_code& ec) override
|
259
|
+
{
|
260
|
+
return destination_->begin_multi_dim(shape, tag, context, ec);
|
261
|
+
}
|
262
|
+
|
263
|
+
bool visit_end_multi_dim(const ser_context& context,
|
264
|
+
std::error_code& ec) override
|
265
|
+
{
|
266
|
+
return destination_->end_multi_dim(context, ec);
|
267
|
+
}
|
268
|
+
};
|
269
|
+
|
270
|
+
template <class CharT>
|
271
|
+
class basic_rename_object_key_filter : public basic_json_filter<CharT>
|
272
|
+
{
|
273
|
+
public:
|
274
|
+
using typename basic_json_filter<CharT>::string_view_type;
|
275
|
+
|
276
|
+
private:
|
277
|
+
std::basic_string<CharT> name_;
|
278
|
+
std::basic_string<CharT> new_name_;
|
279
|
+
public:
|
280
|
+
basic_rename_object_key_filter(const std::basic_string<CharT>& name,
|
281
|
+
const std::basic_string<CharT>& new_name,
|
282
|
+
basic_json_visitor<CharT>& visitor)
|
283
|
+
: basic_json_filter<CharT>(visitor),
|
284
|
+
name_(name), new_name_(new_name)
|
285
|
+
{
|
286
|
+
}
|
287
|
+
|
288
|
+
private:
|
289
|
+
bool visit_key(const string_view_type& name,
|
290
|
+
const ser_context& context,
|
291
|
+
std::error_code& ec) override
|
292
|
+
{
|
293
|
+
if (name == name_)
|
294
|
+
{
|
295
|
+
return this->destination().key(new_name_,context, ec);
|
296
|
+
}
|
297
|
+
else
|
298
|
+
{
|
299
|
+
return this->destination().key(name,context,ec);
|
300
|
+
}
|
301
|
+
}
|
302
|
+
};
|
303
|
+
|
304
|
+
template <class From,class To>
|
305
|
+
class json_visitor_adaptor_base : public From
|
306
|
+
{
|
307
|
+
public:
|
308
|
+
using typename From::string_view_type;
|
309
|
+
private:
|
310
|
+
To* destination_;
|
311
|
+
|
312
|
+
// noncopyable
|
313
|
+
json_visitor_adaptor_base(const json_visitor_adaptor_base&) = delete;
|
314
|
+
json_visitor_adaptor_base& operator=(const json_visitor_adaptor_base&) = delete;
|
315
|
+
public:
|
316
|
+
json_visitor_adaptor_base(To& visitor)
|
317
|
+
: destination_(std::addressof(visitor))
|
318
|
+
{
|
319
|
+
}
|
320
|
+
|
321
|
+
// moveable
|
322
|
+
json_visitor_adaptor_base(json_visitor_adaptor_base&&) = default;
|
323
|
+
json_visitor_adaptor_base& operator=(json_visitor_adaptor_base&&) = default;
|
324
|
+
|
325
|
+
To& destination()
|
326
|
+
{
|
327
|
+
return *destination_;
|
328
|
+
}
|
329
|
+
|
330
|
+
private:
|
331
|
+
void visit_flush() override
|
332
|
+
{
|
333
|
+
destination_->flush();
|
334
|
+
}
|
335
|
+
|
336
|
+
bool visit_begin_object(semantic_tag tag,
|
337
|
+
const ser_context& context,
|
338
|
+
std::error_code& ec) override
|
339
|
+
{
|
340
|
+
return destination_->begin_object(tag, context, ec);
|
341
|
+
}
|
342
|
+
|
343
|
+
bool visit_begin_object(std::size_t length,
|
344
|
+
semantic_tag tag,
|
345
|
+
const ser_context& context,
|
346
|
+
std::error_code& ec) override
|
347
|
+
{
|
348
|
+
return destination_->begin_object(length, tag, context, ec);
|
349
|
+
}
|
350
|
+
|
351
|
+
bool visit_end_object(const ser_context& context, std::error_code& ec) override
|
352
|
+
{
|
353
|
+
return destination_->end_object(context, ec);
|
354
|
+
}
|
355
|
+
|
356
|
+
bool visit_begin_array(semantic_tag tag,
|
357
|
+
const ser_context& context,
|
358
|
+
std::error_code& ec) override
|
359
|
+
{
|
360
|
+
return destination_->begin_array(tag, context, ec);
|
361
|
+
}
|
362
|
+
|
363
|
+
bool visit_begin_array(std::size_t length,
|
364
|
+
semantic_tag tag,
|
365
|
+
const ser_context& context,
|
366
|
+
std::error_code& ec) override
|
367
|
+
{
|
368
|
+
return destination_->begin_array(length, tag, context, ec);
|
369
|
+
}
|
370
|
+
|
371
|
+
bool visit_end_array(const ser_context& context, std::error_code& ec) override
|
372
|
+
{
|
373
|
+
return destination_->end_array(context, ec);
|
374
|
+
}
|
375
|
+
|
376
|
+
bool visit_byte_string(const byte_string_view& b,
|
377
|
+
semantic_tag tag,
|
378
|
+
const ser_context& context,
|
379
|
+
std::error_code& ec) override
|
380
|
+
{
|
381
|
+
return destination_->byte_string_value(b, tag, context, ec);
|
382
|
+
}
|
383
|
+
|
384
|
+
bool visit_byte_string(const byte_string_view& b,
|
385
|
+
uint64_t ext_tag,
|
386
|
+
const ser_context& context,
|
387
|
+
std::error_code& ec) override
|
388
|
+
{
|
389
|
+
return destination_->byte_string_value(b, ext_tag, context, ec);
|
390
|
+
}
|
391
|
+
|
392
|
+
bool visit_half(uint16_t value, semantic_tag tag, const ser_context& context, std::error_code& ec) override
|
393
|
+
{
|
394
|
+
return destination_->half_value(value, tag, context, ec);
|
395
|
+
}
|
396
|
+
|
397
|
+
bool visit_double(double value, semantic_tag tag, const ser_context& context, std::error_code& ec) override
|
398
|
+
{
|
399
|
+
return destination_->double_value(value, tag, context, ec);
|
400
|
+
}
|
401
|
+
|
402
|
+
bool visit_int64(int64_t value, semantic_tag tag, const ser_context& context, std::error_code& ec) override
|
403
|
+
{
|
404
|
+
return destination_->int64_value(value, tag, context, ec);
|
405
|
+
}
|
406
|
+
|
407
|
+
bool visit_uint64(uint64_t value, semantic_tag tag, const ser_context& context, std::error_code& ec) override
|
408
|
+
{
|
409
|
+
return destination_->uint64_value(value, tag, context, ec);
|
410
|
+
}
|
411
|
+
|
412
|
+
bool visit_bool(bool value, semantic_tag tag, const ser_context& context, std::error_code& ec) override
|
413
|
+
{
|
414
|
+
return destination_->bool_value(value, tag, context, ec);
|
415
|
+
}
|
416
|
+
|
417
|
+
bool visit_null(semantic_tag tag, const ser_context& context, std::error_code& ec) override
|
418
|
+
{
|
419
|
+
return destination_->null_value(tag, context, ec);
|
420
|
+
}
|
421
|
+
|
422
|
+
bool visit_typed_array(const jsoncons::span<const uint8_t>& s,
|
423
|
+
semantic_tag tag,
|
424
|
+
const ser_context& context,
|
425
|
+
std::error_code& ec) override
|
426
|
+
{
|
427
|
+
return destination_->typed_array(s, tag, context, ec);
|
428
|
+
}
|
429
|
+
|
430
|
+
bool visit_typed_array(const jsoncons::span<const uint16_t>& s,
|
431
|
+
semantic_tag tag,
|
432
|
+
const ser_context& context,
|
433
|
+
std::error_code& ec) override
|
434
|
+
{
|
435
|
+
return destination_->typed_array(s, tag, context, ec);
|
436
|
+
}
|
437
|
+
|
438
|
+
bool visit_typed_array(const jsoncons::span<const uint32_t>& s,
|
439
|
+
semantic_tag tag,
|
440
|
+
const ser_context& context,
|
441
|
+
std::error_code& ec) override
|
442
|
+
{
|
443
|
+
return destination_->typed_array(s, tag, context, ec);
|
444
|
+
}
|
445
|
+
|
446
|
+
bool visit_typed_array(const jsoncons::span<const uint64_t>& s,
|
447
|
+
semantic_tag tag,
|
448
|
+
const ser_context& context,
|
449
|
+
std::error_code& ec) override
|
450
|
+
{
|
451
|
+
return destination_->typed_array(s, tag, context, ec);
|
452
|
+
}
|
453
|
+
|
454
|
+
bool visit_typed_array(const jsoncons::span<const int8_t>& s,
|
455
|
+
semantic_tag tag,
|
456
|
+
const ser_context& context,
|
457
|
+
std::error_code& ec) override
|
458
|
+
{
|
459
|
+
return destination_->typed_array(s, tag, context, ec);
|
460
|
+
}
|
461
|
+
|
462
|
+
bool visit_typed_array(const jsoncons::span<const int16_t>& s,
|
463
|
+
semantic_tag tag,
|
464
|
+
const ser_context& context,
|
465
|
+
std::error_code& ec) override
|
466
|
+
{
|
467
|
+
return destination_->typed_array(s, tag, context, ec);
|
468
|
+
}
|
469
|
+
|
470
|
+
bool visit_typed_array(const jsoncons::span<const int32_t>& s,
|
471
|
+
semantic_tag tag,
|
472
|
+
const ser_context& context,
|
473
|
+
std::error_code& ec) override
|
474
|
+
{
|
475
|
+
return destination_->typed_array(s, tag, context, ec);
|
476
|
+
}
|
477
|
+
|
478
|
+
bool visit_typed_array(const jsoncons::span<const int64_t>& s,
|
479
|
+
semantic_tag tag,
|
480
|
+
const ser_context& context,
|
481
|
+
std::error_code& ec) override
|
482
|
+
{
|
483
|
+
return destination_->typed_array(s, tag, context, ec);
|
484
|
+
}
|
485
|
+
|
486
|
+
bool visit_typed_array(half_arg_t,
|
487
|
+
const jsoncons::span<const uint16_t>& s,
|
488
|
+
semantic_tag tag,
|
489
|
+
const ser_context& context,
|
490
|
+
std::error_code& ec) override
|
491
|
+
{
|
492
|
+
return destination_->typed_array(half_arg, s, tag, context, ec);
|
493
|
+
}
|
494
|
+
|
495
|
+
bool visit_typed_array(const jsoncons::span<const float>& s,
|
496
|
+
semantic_tag tag,
|
497
|
+
const ser_context& context,
|
498
|
+
std::error_code& ec) override
|
499
|
+
{
|
500
|
+
return destination_->typed_array(s, tag, context, ec);
|
501
|
+
}
|
502
|
+
|
503
|
+
bool visit_typed_array(const jsoncons::span<const double>& s,
|
504
|
+
semantic_tag tag,
|
505
|
+
const ser_context& context,
|
506
|
+
std::error_code& ec) override
|
507
|
+
{
|
508
|
+
return destination_->typed_array(s, tag, context, ec);
|
509
|
+
}
|
510
|
+
|
511
|
+
bool visit_begin_multi_dim(const jsoncons::span<const size_t>& shape,
|
512
|
+
semantic_tag tag,
|
513
|
+
const ser_context& context,
|
514
|
+
std::error_code& ec) override
|
515
|
+
{
|
516
|
+
return destination_->begin_multi_dim(shape, tag, context, ec);
|
517
|
+
}
|
518
|
+
|
519
|
+
bool visit_end_multi_dim(const ser_context& context,
|
520
|
+
std::error_code& ec) override
|
521
|
+
{
|
522
|
+
return destination_->end_multi_dim(context, ec);
|
523
|
+
}
|
524
|
+
|
525
|
+
};
|
526
|
+
|
527
|
+
template <class From,class To,class Enable=void>
|
528
|
+
class json_visitor_adaptor
|
529
|
+
{
|
530
|
+
};
|
531
|
+
|
532
|
+
template <class From,class To>
|
533
|
+
class json_visitor_adaptor<From,To,typename std::enable_if<traits_extension::is_narrow_character<typename From::char_type>::value &&
|
534
|
+
traits_extension::is_narrow_character<typename To::char_type>::value>::type> : public json_visitor_adaptor_base<From,To>
|
535
|
+
{
|
536
|
+
using supertype = json_visitor_adaptor_base<From,To>;
|
537
|
+
using to_char_type = typename To::char_type;
|
538
|
+
using from_char_type = typename From::char_type;
|
539
|
+
public:
|
540
|
+
using typename From::string_view_type;
|
541
|
+
using supertype::destination;
|
542
|
+
private:
|
543
|
+
|
544
|
+
// noncopyable
|
545
|
+
json_visitor_adaptor(const json_visitor_adaptor&) = delete;
|
546
|
+
json_visitor_adaptor& operator=(const json_visitor_adaptor&) = delete;
|
547
|
+
public:
|
548
|
+
json_visitor_adaptor(To& visitor)
|
549
|
+
: supertype(visitor)
|
550
|
+
{
|
551
|
+
}
|
552
|
+
|
553
|
+
// moveable
|
554
|
+
json_visitor_adaptor(json_visitor_adaptor&&) = default;
|
555
|
+
json_visitor_adaptor& operator=(json_visitor_adaptor&&) = default;
|
556
|
+
|
557
|
+
private:
|
558
|
+
|
559
|
+
bool visit_key(const string_view_type& key,
|
560
|
+
const ser_context& context,
|
561
|
+
std::error_code& ec) override
|
562
|
+
{
|
563
|
+
return destination().key(string_view_type(reinterpret_cast<const to_char_type*>(key.data()),key.size()), context, ec);
|
564
|
+
}
|
565
|
+
|
566
|
+
bool visit_string(const string_view_type& value,
|
567
|
+
semantic_tag tag,
|
568
|
+
const ser_context& context,
|
569
|
+
std::error_code& ec) override
|
570
|
+
{
|
571
|
+
return destination().string_value(string_view_type(reinterpret_cast<const to_char_type*>(value.data()),value.size()), tag, context, ec);
|
572
|
+
}
|
573
|
+
};
|
574
|
+
|
575
|
+
template <class From,class To>
|
576
|
+
class json_visitor_adaptor<From,To,typename std::enable_if<!(traits_extension::is_narrow_character<typename From::char_type>::value &&
|
577
|
+
traits_extension::is_narrow_character<typename To::char_type>::value)>::type> : public json_visitor_adaptor_base<From,To>
|
578
|
+
{
|
579
|
+
using supertype = json_visitor_adaptor_base<From,To>;
|
580
|
+
public:
|
581
|
+
using typename From::string_view_type;
|
582
|
+
using supertype::destination;
|
583
|
+
private:
|
584
|
+
|
585
|
+
// noncopyable
|
586
|
+
json_visitor_adaptor(const json_visitor_adaptor&) = delete;
|
587
|
+
json_visitor_adaptor& operator=(const json_visitor_adaptor&) = delete;
|
588
|
+
public:
|
589
|
+
json_visitor_adaptor(To& visitor)
|
590
|
+
: supertype(visitor)
|
591
|
+
{
|
592
|
+
}
|
593
|
+
|
594
|
+
// moveable
|
595
|
+
json_visitor_adaptor(json_visitor_adaptor&&) = default;
|
596
|
+
json_visitor_adaptor& operator=(json_visitor_adaptor&&) = default;
|
597
|
+
|
598
|
+
private:
|
599
|
+
|
600
|
+
bool visit_key(const string_view_type& name,
|
601
|
+
const ser_context& context,
|
602
|
+
std::error_code& ec) override
|
603
|
+
{
|
604
|
+
std::basic_string<typename To::char_type> target;
|
605
|
+
auto result = unicode_traits::convert(name.data(), name.size(), target, unicode_traits::conv_flags::strict);
|
606
|
+
if (result.ec != unicode_traits::conv_errc())
|
607
|
+
{
|
608
|
+
ec = result.ec;
|
609
|
+
}
|
610
|
+
return destination().key(target, context, ec);
|
611
|
+
}
|
612
|
+
|
613
|
+
bool visit_string(const string_view_type& value,
|
614
|
+
semantic_tag tag,
|
615
|
+
const ser_context& context,
|
616
|
+
std::error_code& ec) override
|
617
|
+
{
|
618
|
+
std::basic_string<typename To::char_type> target;
|
619
|
+
auto result = unicode_traits::convert(value.data(), value.size(),
|
620
|
+
target,unicode_traits::conv_flags::strict);
|
621
|
+
if (result.ec != unicode_traits::conv_errc())
|
622
|
+
{
|
623
|
+
JSONCONS_THROW(ser_error(result.ec));
|
624
|
+
}
|
625
|
+
return destination().string_value(target, tag, context, ec);
|
626
|
+
}
|
627
|
+
};
|
628
|
+
|
629
|
+
template <class From,class To>
|
630
|
+
json_visitor_adaptor<From,To> make_json_visitor_adaptor(To& to)
|
631
|
+
{
|
632
|
+
return json_visitor_adaptor<From, To>(to);
|
633
|
+
}
|
634
|
+
|
635
|
+
using json_filter = basic_json_filter<char>;
|
636
|
+
using wjson_filter = basic_json_filter<wchar_t>;
|
637
|
+
using rename_object_key_filter = basic_rename_object_key_filter<char>;
|
638
|
+
using wrename_object_key_filter = basic_rename_object_key_filter<wchar_t>;
|
639
|
+
|
640
|
+
#if !defined(JSONCONS_NO_DEPRECATED)
|
641
|
+
template <class CharT>
|
642
|
+
using basic_json_content_filter = basic_json_filter<CharT>;
|
643
|
+
JSONCONS_DEPRECATED_MSG("Instead, use json_filter") typedef basic_json_filter<char> json_content_filter;
|
644
|
+
JSONCONS_DEPRECATED_MSG("Instead, use wjson_filter") typedef basic_json_filter<wchar_t> wjson_content_filter;
|
645
|
+
JSONCONS_DEPRECATED_MSG("Instead, use rename_object_key_filter") typedef basic_rename_object_key_filter<char> rename_name_filter;
|
646
|
+
JSONCONS_DEPRECATED_MSG("Instead, use wrename_object_key_filter") typedef basic_rename_object_key_filter<wchar_t> wrename_name_filter;
|
647
|
+
JSONCONS_DEPRECATED_MSG("Instead, use rename_object_key_filter") typedef basic_rename_object_key_filter<char> rename_object_member_filter;
|
648
|
+
JSONCONS_DEPRECATED_MSG("Instead, use wrename_object_key_filter") typedef basic_rename_object_key_filter<wchar_t> wrename_object_member_filter;
|
649
|
+
#endif
|
650
|
+
|
651
|
+
}
|
652
|
+
|
653
|
+
#endif
|
@@ -0,0 +1,23 @@
|
|
1
|
+
// Copyright 2013 Daniel Parker
|
2
|
+
// Distributed under the Boost license, Version 1.0.
|
3
|
+
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
4
|
+
|
5
|
+
// See https://github.com/danielaparker/jsoncons for latest version
|
6
|
+
|
7
|
+
#ifndef JSONCONS_JSON_FWD_HPP
|
8
|
+
#define JSONCONS_JSON_FWD_HPP
|
9
|
+
|
10
|
+
#include <memory> // std::allocator
|
11
|
+
|
12
|
+
namespace jsoncons {
|
13
|
+
|
14
|
+
struct sorted_policy;
|
15
|
+
|
16
|
+
template <class CharT,
|
17
|
+
class ImplementationPolicy = sorted_policy,
|
18
|
+
class Allocator = std::allocator<CharT>>
|
19
|
+
class basic_json;
|
20
|
+
|
21
|
+
}
|
22
|
+
|
23
|
+
#endif
|