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,862 @@
|
|
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_OPTIONS_HPP
|
8
|
+
#define JSONCONS_JSON_OPTIONS_HPP
|
9
|
+
|
10
|
+
#include <string>
|
11
|
+
#include <limits> // std::numeric_limits
|
12
|
+
#include <cwchar>
|
13
|
+
#include <jsoncons/json_exception.hpp>
|
14
|
+
#include <jsoncons/traits_extension.hpp>
|
15
|
+
|
16
|
+
namespace jsoncons {
|
17
|
+
|
18
|
+
enum class float_chars_format : uint8_t {general,fixed,scientific,hex};
|
19
|
+
|
20
|
+
#if !defined(JSONCONS_NO_DEPRECATED)
|
21
|
+
JSONCONS_DEPRECATED_MSG("Instead, use float_chars_format") typedef float_chars_format chars_format;
|
22
|
+
#endif
|
23
|
+
|
24
|
+
enum class indenting : uint8_t {no_indent = 0, indent = 1};
|
25
|
+
|
26
|
+
enum class line_split_kind : uint8_t {same_line,new_line,multi_line};
|
27
|
+
|
28
|
+
enum class bigint_chars_format : uint8_t {number, base10, base64, base64url
|
29
|
+
#if !defined(JSONCONS_NO_DEPRECATED)
|
30
|
+
,integer = number
|
31
|
+
#endif
|
32
|
+
};
|
33
|
+
|
34
|
+
#if !defined(JSONCONS_NO_DEPRECATED)
|
35
|
+
JSONCONS_DEPRECATED_MSG("Instead, use bigint_chars_format") typedef bigint_chars_format bignum_chars_format;
|
36
|
+
JSONCONS_DEPRECATED_MSG("Instead, use bigint_chars_format") typedef bigint_chars_format big_integer_chars_format;
|
37
|
+
#endif
|
38
|
+
|
39
|
+
enum class byte_string_chars_format : uint8_t {none=0,base16,base64,base64url};
|
40
|
+
|
41
|
+
enum class spaces_option : uint8_t {no_spaces=0,space_after,space_before,space_before_and_after};
|
42
|
+
|
43
|
+
template <class CharT>
|
44
|
+
class basic_json_options;
|
45
|
+
|
46
|
+
template <class CharT>
|
47
|
+
class basic_json_options_common
|
48
|
+
{
|
49
|
+
friend class basic_json_options<CharT>;
|
50
|
+
public:
|
51
|
+
using char_type = CharT;
|
52
|
+
using string_type = std::basic_string<CharT>;
|
53
|
+
private:
|
54
|
+
#if !defined(JSONCONS_NO_DEPRECATED)
|
55
|
+
bool can_read_nan_replacement_;
|
56
|
+
bool can_read_pos_inf_replacement_;
|
57
|
+
bool can_read_neg_inf_replacement_;
|
58
|
+
string_type nan_replacement_;
|
59
|
+
string_type pos_inf_replacement_;
|
60
|
+
string_type neg_inf_replacement_;
|
61
|
+
#endif
|
62
|
+
|
63
|
+
bool enable_nan_to_num_:1;
|
64
|
+
bool enable_inf_to_num_:1;
|
65
|
+
bool enable_neginf_to_num_:1;
|
66
|
+
bool enable_nan_to_str_:1;
|
67
|
+
bool enable_inf_to_str_:1;
|
68
|
+
bool enable_neginf_to_str_:1;
|
69
|
+
bool enable_str_to_nan_:1;
|
70
|
+
bool enable_str_to_inf_:1;
|
71
|
+
bool enable_str_to_neginf_:1;
|
72
|
+
|
73
|
+
string_type nan_to_num_;
|
74
|
+
string_type inf_to_num_;
|
75
|
+
string_type neginf_to_num_;
|
76
|
+
string_type nan_to_str_;
|
77
|
+
string_type inf_to_str_;
|
78
|
+
string_type neginf_to_str_;
|
79
|
+
int max_nesting_depth_;
|
80
|
+
|
81
|
+
protected:
|
82
|
+
basic_json_options_common()
|
83
|
+
:
|
84
|
+
#if !defined(JSONCONS_NO_DEPRECATED)
|
85
|
+
can_read_nan_replacement_(false),
|
86
|
+
can_read_pos_inf_replacement_(false),
|
87
|
+
can_read_neg_inf_replacement_(false),
|
88
|
+
#endif
|
89
|
+
enable_nan_to_num_(false),
|
90
|
+
enable_inf_to_num_(false),
|
91
|
+
enable_neginf_to_num_(false),
|
92
|
+
enable_nan_to_str_(false),
|
93
|
+
enable_inf_to_str_(false),
|
94
|
+
enable_neginf_to_str_(false),
|
95
|
+
enable_str_to_nan_(false),
|
96
|
+
enable_str_to_inf_(false),
|
97
|
+
enable_str_to_neginf_(false),
|
98
|
+
max_nesting_depth_(1024)
|
99
|
+
{}
|
100
|
+
|
101
|
+
virtual ~basic_json_options_common() noexcept = default;
|
102
|
+
|
103
|
+
basic_json_options_common(const basic_json_options_common&) = default;
|
104
|
+
basic_json_options_common& operator=(const basic_json_options_common&) = default;
|
105
|
+
basic_json_options_common(basic_json_options_common&&) = default;
|
106
|
+
basic_json_options_common& operator=(basic_json_options_common&&) = default;
|
107
|
+
|
108
|
+
public:
|
109
|
+
|
110
|
+
bool enable_nan_to_num() const
|
111
|
+
{
|
112
|
+
return enable_nan_to_num_;
|
113
|
+
}
|
114
|
+
|
115
|
+
bool enable_inf_to_num() const
|
116
|
+
{
|
117
|
+
return enable_inf_to_num_;
|
118
|
+
}
|
119
|
+
|
120
|
+
bool enable_neginf_to_num() const
|
121
|
+
{
|
122
|
+
return enable_neginf_to_num_ || enable_inf_to_num_;
|
123
|
+
}
|
124
|
+
|
125
|
+
bool enable_nan_to_str() const
|
126
|
+
{
|
127
|
+
return enable_nan_to_str_;
|
128
|
+
}
|
129
|
+
|
130
|
+
bool enable_str_to_nan() const
|
131
|
+
{
|
132
|
+
return enable_str_to_nan_;
|
133
|
+
}
|
134
|
+
|
135
|
+
bool enable_inf_to_str() const
|
136
|
+
{
|
137
|
+
return enable_inf_to_str_;
|
138
|
+
}
|
139
|
+
|
140
|
+
bool enable_str_to_inf() const
|
141
|
+
{
|
142
|
+
return enable_str_to_inf_;
|
143
|
+
}
|
144
|
+
|
145
|
+
bool enable_neginf_to_str() const
|
146
|
+
{
|
147
|
+
return enable_neginf_to_str_ || enable_inf_to_str_;
|
148
|
+
}
|
149
|
+
|
150
|
+
bool enable_str_to_neginf() const
|
151
|
+
{
|
152
|
+
return enable_str_to_neginf_ || enable_str_to_inf_;
|
153
|
+
}
|
154
|
+
|
155
|
+
string_type nan_to_num() const
|
156
|
+
{
|
157
|
+
if (enable_nan_to_num_)
|
158
|
+
{
|
159
|
+
return nan_to_num_;
|
160
|
+
}
|
161
|
+
#if !defined(JSONCONS_NO_DEPRECATED)
|
162
|
+
else if (!can_read_nan_replacement_) // not string
|
163
|
+
{
|
164
|
+
return nan_replacement_;
|
165
|
+
}
|
166
|
+
#endif
|
167
|
+
else
|
168
|
+
{
|
169
|
+
return nan_to_num_; // empty string
|
170
|
+
}
|
171
|
+
}
|
172
|
+
|
173
|
+
string_type inf_to_num() const
|
174
|
+
{
|
175
|
+
if (enable_inf_to_num_)
|
176
|
+
{
|
177
|
+
return inf_to_num_;
|
178
|
+
}
|
179
|
+
#if !defined(JSONCONS_NO_DEPRECATED)
|
180
|
+
else if (!can_read_pos_inf_replacement_) // not string
|
181
|
+
{
|
182
|
+
return pos_inf_replacement_;
|
183
|
+
}
|
184
|
+
#endif
|
185
|
+
else
|
186
|
+
{
|
187
|
+
return inf_to_num_; // empty string
|
188
|
+
}
|
189
|
+
}
|
190
|
+
|
191
|
+
string_type neginf_to_num() const
|
192
|
+
{
|
193
|
+
if (enable_neginf_to_num_)
|
194
|
+
{
|
195
|
+
return neginf_to_num_;
|
196
|
+
}
|
197
|
+
else if (enable_inf_to_num_)
|
198
|
+
{
|
199
|
+
string_type s;
|
200
|
+
s.push_back('-');
|
201
|
+
s.append(inf_to_num_);
|
202
|
+
return s;
|
203
|
+
}
|
204
|
+
#if !defined(JSONCONS_NO_DEPRECATED)
|
205
|
+
else if (!can_read_neg_inf_replacement_) // not string
|
206
|
+
{
|
207
|
+
return neg_inf_replacement_;
|
208
|
+
}
|
209
|
+
#endif
|
210
|
+
else
|
211
|
+
{
|
212
|
+
return neginf_to_num_; // empty string
|
213
|
+
}
|
214
|
+
}
|
215
|
+
|
216
|
+
string_type nan_to_str() const
|
217
|
+
{
|
218
|
+
if (enable_nan_to_str_)
|
219
|
+
{
|
220
|
+
return nan_to_str_;
|
221
|
+
}
|
222
|
+
#if !defined(JSONCONS_NO_DEPRECATED)
|
223
|
+
else if (can_read_nan_replacement_ && nan_replacement_.size() >= 2) // string
|
224
|
+
{
|
225
|
+
return nan_replacement_.substr(1, nan_replacement_.size() - 2); // Remove quotes
|
226
|
+
}
|
227
|
+
#endif
|
228
|
+
else
|
229
|
+
{
|
230
|
+
return nan_to_str_; // empty string
|
231
|
+
}
|
232
|
+
}
|
233
|
+
|
234
|
+
string_type inf_to_str() const
|
235
|
+
{
|
236
|
+
if (enable_inf_to_str_)
|
237
|
+
{
|
238
|
+
return inf_to_str_;
|
239
|
+
}
|
240
|
+
#if !defined(JSONCONS_NO_DEPRECATED)
|
241
|
+
else if (can_read_pos_inf_replacement_ && pos_inf_replacement_.size() >= 2) // string
|
242
|
+
{
|
243
|
+
return pos_inf_replacement_.substr(1, pos_inf_replacement_.size() - 2); // Strip quotes
|
244
|
+
}
|
245
|
+
#endif
|
246
|
+
else
|
247
|
+
{
|
248
|
+
return inf_to_str_; // empty string
|
249
|
+
}
|
250
|
+
}
|
251
|
+
|
252
|
+
string_type neginf_to_str() const
|
253
|
+
{
|
254
|
+
if (enable_neginf_to_str_)
|
255
|
+
{
|
256
|
+
return neginf_to_str_;
|
257
|
+
}
|
258
|
+
else if (enable_inf_to_str_)
|
259
|
+
{
|
260
|
+
string_type s;
|
261
|
+
s.push_back('-');
|
262
|
+
s.append(inf_to_str_);
|
263
|
+
return s;
|
264
|
+
}
|
265
|
+
#if !defined(JSONCONS_NO_DEPRECATED)
|
266
|
+
else if (can_read_neg_inf_replacement_ && neg_inf_replacement_.size() >= 2) // string
|
267
|
+
{
|
268
|
+
return neg_inf_replacement_.substr(1, neg_inf_replacement_.size() - 2); // Strip quotes
|
269
|
+
}
|
270
|
+
#endif
|
271
|
+
else
|
272
|
+
{
|
273
|
+
return neginf_to_str_; // empty string
|
274
|
+
}
|
275
|
+
}
|
276
|
+
|
277
|
+
int max_nesting_depth() const
|
278
|
+
{
|
279
|
+
return max_nesting_depth_;
|
280
|
+
}
|
281
|
+
|
282
|
+
#if !defined(JSONCONS_NO_DEPRECATED)
|
283
|
+
JSONCONS_DEPRECATED_MSG("Instead, use enable_nan_to_num() or enable_nan_to_str()")
|
284
|
+
bool can_read_nan_replacement() const { return can_read_nan_replacement_; }
|
285
|
+
|
286
|
+
JSONCONS_DEPRECATED_MSG("Instead, use enable_inf_to_num() or enable_inf_to_str()")
|
287
|
+
bool can_read_pos_inf_replacement() const { return can_read_pos_inf_replacement_; }
|
288
|
+
|
289
|
+
JSONCONS_DEPRECATED_MSG("Instead, use enable_neginf_to_num() or enable_neginf_to_str()")
|
290
|
+
bool can_read_neg_inf_replacement() const { return can_read_neg_inf_replacement_; }
|
291
|
+
|
292
|
+
bool can_write_nan_replacement() const { return !nan_replacement_.empty(); }
|
293
|
+
|
294
|
+
bool can_write_pos_inf_replacement() const { return !pos_inf_replacement_.empty(); }
|
295
|
+
|
296
|
+
bool can_write_neg_inf_replacement() const { return !neg_inf_replacement_.empty(); }
|
297
|
+
|
298
|
+
JSONCONS_DEPRECATED_MSG("Instead, use nan_to_num() or nan_to_str()")
|
299
|
+
const string_type& nan_replacement() const
|
300
|
+
{
|
301
|
+
return nan_replacement_;
|
302
|
+
}
|
303
|
+
|
304
|
+
JSONCONS_DEPRECATED_MSG("Instead, use inf_to_num() or inf_to_str()")
|
305
|
+
const string_type& pos_inf_replacement() const
|
306
|
+
{
|
307
|
+
return pos_inf_replacement_;
|
308
|
+
}
|
309
|
+
|
310
|
+
JSONCONS_DEPRECATED_MSG("Instead, use neginf_to_num() or neginf_to_str()")
|
311
|
+
const string_type& neg_inf_replacement() const
|
312
|
+
{
|
313
|
+
return neg_inf_replacement_;
|
314
|
+
}
|
315
|
+
#endif
|
316
|
+
};
|
317
|
+
|
318
|
+
template <class CharT>
|
319
|
+
class basic_json_decode_options : public virtual basic_json_options_common<CharT>
|
320
|
+
{
|
321
|
+
friend class basic_json_options<CharT>;
|
322
|
+
using super_type = basic_json_options_common<CharT>;
|
323
|
+
public:
|
324
|
+
using typename super_type::char_type;
|
325
|
+
using typename super_type::string_type;
|
326
|
+
private:
|
327
|
+
bool lossless_number_:1;
|
328
|
+
public:
|
329
|
+
basic_json_decode_options()
|
330
|
+
: lossless_number_(false)
|
331
|
+
{
|
332
|
+
}
|
333
|
+
|
334
|
+
basic_json_decode_options(const basic_json_decode_options&) = default;
|
335
|
+
|
336
|
+
basic_json_decode_options(basic_json_decode_options&& other)
|
337
|
+
: super_type(std::forward<basic_json_decode_options>(other)),
|
338
|
+
lossless_number_(other.lossless_number_)
|
339
|
+
{
|
340
|
+
}
|
341
|
+
|
342
|
+
basic_json_decode_options& operator=(const basic_json_decode_options&) = default;
|
343
|
+
|
344
|
+
bool lossless_number() const
|
345
|
+
{
|
346
|
+
return lossless_number_;
|
347
|
+
}
|
348
|
+
|
349
|
+
#if !defined(JSONCONS_NO_DEPRECATED)
|
350
|
+
JSONCONS_DEPRECATED_MSG("Instead, use lossless_number()")
|
351
|
+
bool dec_to_str() const
|
352
|
+
{
|
353
|
+
return lossless_number_;
|
354
|
+
}
|
355
|
+
#endif
|
356
|
+
};
|
357
|
+
|
358
|
+
template <class CharT>
|
359
|
+
class basic_json_encode_options : public virtual basic_json_options_common<CharT>
|
360
|
+
{
|
361
|
+
friend class basic_json_options<CharT>;
|
362
|
+
using super_type = basic_json_options_common<CharT>;
|
363
|
+
public:
|
364
|
+
using typename super_type::char_type;
|
365
|
+
using typename super_type::string_type;
|
366
|
+
|
367
|
+
static constexpr uint8_t indent_size_default = 4;
|
368
|
+
static constexpr size_t line_length_limit_default = 120;
|
369
|
+
private:
|
370
|
+
bool escape_all_non_ascii_:1;
|
371
|
+
bool escape_solidus_:1;
|
372
|
+
bool pad_inside_object_braces_:1;
|
373
|
+
bool pad_inside_array_brackets_:1;
|
374
|
+
float_chars_format float_format_;
|
375
|
+
byte_string_chars_format byte_string_format_;
|
376
|
+
bigint_chars_format bigint_format_;
|
377
|
+
line_split_kind object_object_line_splits_;
|
378
|
+
line_split_kind object_array_line_splits_;
|
379
|
+
line_split_kind array_array_line_splits_;
|
380
|
+
line_split_kind array_object_line_splits_;
|
381
|
+
spaces_option spaces_around_colon_;
|
382
|
+
spaces_option spaces_around_comma_;
|
383
|
+
int8_t precision_;
|
384
|
+
uint8_t indent_size_;
|
385
|
+
std::size_t line_length_limit_;
|
386
|
+
string_type new_line_chars_;
|
387
|
+
public:
|
388
|
+
basic_json_encode_options()
|
389
|
+
: escape_all_non_ascii_(false),
|
390
|
+
escape_solidus_(false),
|
391
|
+
pad_inside_object_braces_(false),
|
392
|
+
pad_inside_array_brackets_(false),
|
393
|
+
float_format_(float_chars_format::general),
|
394
|
+
byte_string_format_(byte_string_chars_format::none),
|
395
|
+
bigint_format_(bigint_chars_format::base10),
|
396
|
+
object_object_line_splits_(line_split_kind::multi_line),
|
397
|
+
object_array_line_splits_(line_split_kind::same_line),
|
398
|
+
array_array_line_splits_(line_split_kind::new_line),
|
399
|
+
array_object_line_splits_(line_split_kind::multi_line),
|
400
|
+
spaces_around_colon_(spaces_option::space_after),
|
401
|
+
spaces_around_comma_(spaces_option::space_after),
|
402
|
+
precision_(0),
|
403
|
+
indent_size_(indent_size_default),
|
404
|
+
line_length_limit_(line_length_limit_default)
|
405
|
+
{
|
406
|
+
new_line_chars_.push_back('\n');
|
407
|
+
}
|
408
|
+
|
409
|
+
basic_json_encode_options(const basic_json_encode_options&) = default;
|
410
|
+
|
411
|
+
basic_json_encode_options(basic_json_encode_options&& other)
|
412
|
+
: super_type(std::forward<basic_json_encode_options>(other)),
|
413
|
+
escape_all_non_ascii_(other.escape_all_non_ascii_),
|
414
|
+
escape_solidus_(other.escape_solidus_),
|
415
|
+
pad_inside_object_braces_(other.pad_inside_object_braces_),
|
416
|
+
pad_inside_array_brackets_(other.pad_inside_array_brackets_),
|
417
|
+
float_format_(other.float_format_),
|
418
|
+
byte_string_format_(other.byte_string_format_),
|
419
|
+
bigint_format_(other.bigint_format_),
|
420
|
+
object_object_line_splits_(other.object_object_line_splits_),
|
421
|
+
object_array_line_splits_(other.object_array_line_splits_),
|
422
|
+
array_array_line_splits_(other.array_array_line_splits_),
|
423
|
+
array_object_line_splits_(other.array_object_line_splits_),
|
424
|
+
spaces_around_colon_(other.spaces_around_colon_),
|
425
|
+
spaces_around_comma_(other.spaces_around_comma_),
|
426
|
+
precision_(other.precision_),
|
427
|
+
indent_size_(other.indent_size_),
|
428
|
+
line_length_limit_(other.line_length_limit_),
|
429
|
+
new_line_chars_(std::move(other.new_line_chars_))
|
430
|
+
{
|
431
|
+
}
|
432
|
+
|
433
|
+
basic_json_encode_options& operator=(const basic_json_encode_options&) = default;
|
434
|
+
|
435
|
+
byte_string_chars_format byte_string_format() const {return byte_string_format_;}
|
436
|
+
|
437
|
+
bigint_chars_format bigint_format() const {return bigint_format_;}
|
438
|
+
|
439
|
+
line_split_kind object_object_line_splits() const {return object_object_line_splits_;}
|
440
|
+
|
441
|
+
line_split_kind array_object_line_splits() const {return array_object_line_splits_;}
|
442
|
+
|
443
|
+
line_split_kind object_array_line_splits() const {return object_array_line_splits_;}
|
444
|
+
|
445
|
+
line_split_kind array_array_line_splits() const {return array_array_line_splits_;}
|
446
|
+
|
447
|
+
uint8_t indent_size() const
|
448
|
+
{
|
449
|
+
return indent_size_;
|
450
|
+
}
|
451
|
+
|
452
|
+
spaces_option spaces_around_colon() const
|
453
|
+
{
|
454
|
+
return spaces_around_colon_;
|
455
|
+
}
|
456
|
+
|
457
|
+
spaces_option spaces_around_comma() const
|
458
|
+
{
|
459
|
+
return spaces_around_comma_;
|
460
|
+
}
|
461
|
+
|
462
|
+
bool pad_inside_object_braces() const
|
463
|
+
{
|
464
|
+
return pad_inside_object_braces_;
|
465
|
+
}
|
466
|
+
|
467
|
+
bool pad_inside_array_brackets() const
|
468
|
+
{
|
469
|
+
return pad_inside_array_brackets_;
|
470
|
+
}
|
471
|
+
|
472
|
+
string_type new_line_chars() const
|
473
|
+
{
|
474
|
+
return new_line_chars_;
|
475
|
+
}
|
476
|
+
|
477
|
+
std::size_t line_length_limit() const
|
478
|
+
{
|
479
|
+
return line_length_limit_;
|
480
|
+
}
|
481
|
+
|
482
|
+
float_chars_format float_format() const
|
483
|
+
{
|
484
|
+
return float_format_;
|
485
|
+
}
|
486
|
+
|
487
|
+
int8_t precision() const
|
488
|
+
{
|
489
|
+
return precision_;
|
490
|
+
}
|
491
|
+
|
492
|
+
bool escape_all_non_ascii() const
|
493
|
+
{
|
494
|
+
return escape_all_non_ascii_;
|
495
|
+
}
|
496
|
+
|
497
|
+
bool escape_solidus() const
|
498
|
+
{
|
499
|
+
return escape_solidus_;
|
500
|
+
}
|
501
|
+
|
502
|
+
#if !defined(JSONCONS_NO_DEPRECATED)
|
503
|
+
JSONCONS_DEPRECATED_MSG("Instead, use bigint_format()")
|
504
|
+
bigint_chars_format bignum_format() const {return bigint_format_;}
|
505
|
+
|
506
|
+
JSONCONS_DEPRECATED_MSG("Instead, use indent_size()")
|
507
|
+
uint8_t indent() const
|
508
|
+
{
|
509
|
+
return indent_size();
|
510
|
+
}
|
511
|
+
|
512
|
+
JSONCONS_DEPRECATED_MSG("Instead, use object_object_line_splits()")
|
513
|
+
line_split_kind object_object_split_lines() const {return object_object_line_splits_;}
|
514
|
+
|
515
|
+
JSONCONS_DEPRECATED_MSG("Instead, use array_object_line_splits()")
|
516
|
+
line_split_kind array_object_split_lines() const {return array_object_line_splits_;}
|
517
|
+
|
518
|
+
JSONCONS_DEPRECATED_MSG("Instead, use object_array_line_splits()")
|
519
|
+
line_split_kind object_array_split_lines() const {return object_array_line_splits_;}
|
520
|
+
|
521
|
+
JSONCONS_DEPRECATED_MSG("Instead, use array_array_line_splits()")
|
522
|
+
line_split_kind array_array_split_lines() const {return array_array_line_splits_;}
|
523
|
+
#endif
|
524
|
+
};
|
525
|
+
|
526
|
+
template <class CharT>
|
527
|
+
class basic_json_options final: public basic_json_decode_options<CharT>,
|
528
|
+
public basic_json_encode_options<CharT>
|
529
|
+
{
|
530
|
+
public:
|
531
|
+
using char_type = CharT;
|
532
|
+
using string_type = std::basic_string<CharT>;
|
533
|
+
|
534
|
+
using basic_json_options_common<CharT>::max_nesting_depth;
|
535
|
+
|
536
|
+
using basic_json_decode_options<CharT>::enable_str_to_nan;
|
537
|
+
using basic_json_decode_options<CharT>::enable_str_to_inf;
|
538
|
+
using basic_json_decode_options<CharT>::enable_str_to_neginf;
|
539
|
+
using basic_json_decode_options<CharT>::nan_to_str;
|
540
|
+
using basic_json_decode_options<CharT>::inf_to_str;
|
541
|
+
using basic_json_decode_options<CharT>::neginf_to_str;
|
542
|
+
using basic_json_decode_options<CharT>::nan_to_num;
|
543
|
+
using basic_json_decode_options<CharT>::inf_to_num;
|
544
|
+
using basic_json_decode_options<CharT>::neginf_to_num;
|
545
|
+
|
546
|
+
using basic_json_decode_options<CharT>::lossless_number;
|
547
|
+
|
548
|
+
using basic_json_encode_options<CharT>::byte_string_format;
|
549
|
+
using basic_json_encode_options<CharT>::bigint_format;
|
550
|
+
using basic_json_encode_options<CharT>::object_object_line_splits;
|
551
|
+
using basic_json_encode_options<CharT>::array_object_line_splits;
|
552
|
+
using basic_json_encode_options<CharT>::object_array_line_splits;
|
553
|
+
using basic_json_encode_options<CharT>::array_array_line_splits;
|
554
|
+
using basic_json_encode_options<CharT>::indent_size;
|
555
|
+
using basic_json_encode_options<CharT>::spaces_around_colon;
|
556
|
+
using basic_json_encode_options<CharT>::spaces_around_comma;
|
557
|
+
using basic_json_encode_options<CharT>::pad_inside_object_braces;
|
558
|
+
using basic_json_encode_options<CharT>::pad_inside_array_brackets;
|
559
|
+
using basic_json_encode_options<CharT>::new_line_chars;
|
560
|
+
using basic_json_encode_options<CharT>::line_length_limit;
|
561
|
+
using basic_json_encode_options<CharT>::float_format;
|
562
|
+
using basic_json_encode_options<CharT>::precision;
|
563
|
+
using basic_json_encode_options<CharT>::escape_all_non_ascii;
|
564
|
+
using basic_json_encode_options<CharT>::escape_solidus;
|
565
|
+
public:
|
566
|
+
|
567
|
+
// Constructors
|
568
|
+
|
569
|
+
basic_json_options() = default;
|
570
|
+
basic_json_options(const basic_json_options&) = default;
|
571
|
+
basic_json_options(basic_json_options&&) = default;
|
572
|
+
basic_json_options& operator=(const basic_json_options&) = default;
|
573
|
+
basic_json_options& operator=(basic_json_options&&) = default;
|
574
|
+
|
575
|
+
basic_json_options& nan_to_num(const string_type& value)
|
576
|
+
{
|
577
|
+
this->enable_nan_to_num_ = true;
|
578
|
+
this->nan_to_str_.clear();
|
579
|
+
this->nan_to_num_ = value;
|
580
|
+
return *this;
|
581
|
+
}
|
582
|
+
|
583
|
+
basic_json_options& inf_to_num(const string_type& value)
|
584
|
+
{
|
585
|
+
this->enable_inf_to_num_ = true;
|
586
|
+
this->inf_to_str_.clear();
|
587
|
+
this->inf_to_num_ = value;
|
588
|
+
return *this;
|
589
|
+
}
|
590
|
+
|
591
|
+
basic_json_options& neginf_to_num(const string_type& value)
|
592
|
+
{
|
593
|
+
this->enable_neginf_to_num_ = true;
|
594
|
+
this->neginf_to_str_.clear();
|
595
|
+
this->neginf_to_num_ = value;
|
596
|
+
return *this;
|
597
|
+
}
|
598
|
+
|
599
|
+
basic_json_options& nan_to_str(const string_type& value, bool enable_inverse = true)
|
600
|
+
{
|
601
|
+
this->enable_nan_to_str_ = true;
|
602
|
+
this->enable_str_to_nan_ = enable_inverse;
|
603
|
+
this->nan_to_num_.clear();
|
604
|
+
this->nan_to_str_ = value;
|
605
|
+
return *this;
|
606
|
+
}
|
607
|
+
|
608
|
+
basic_json_options& inf_to_str(const string_type& value, bool enable_inverse = true)
|
609
|
+
{
|
610
|
+
this->enable_inf_to_str_ = true;
|
611
|
+
this->enable_str_to_inf_ = enable_inverse;
|
612
|
+
this->inf_to_num_.clear();
|
613
|
+
this->inf_to_str_ = value;
|
614
|
+
return *this;
|
615
|
+
}
|
616
|
+
|
617
|
+
basic_json_options& neginf_to_str(const string_type& value, bool enable_inverse = true)
|
618
|
+
{
|
619
|
+
this->enable_neginf_to_str_ = true;
|
620
|
+
this->enable_str_to_neginf_ = enable_inverse;
|
621
|
+
this->neginf_to_num_.clear();
|
622
|
+
this->neginf_to_str_ = value;
|
623
|
+
return *this;
|
624
|
+
}
|
625
|
+
|
626
|
+
JSONCONS_DEPRECATED_MSG("Instead, use inf_to_num(const string_type&) or inf_to_str(const string_type&)")
|
627
|
+
basic_json_options& replace_inf(bool replace)
|
628
|
+
{
|
629
|
+
this->can_read_pos_inf_replacement_ = replace;
|
630
|
+
this->can_read_neg_inf_replacement_ = replace;
|
631
|
+
return *this;
|
632
|
+
}
|
633
|
+
|
634
|
+
JSONCONS_DEPRECATED_MSG("Instead, use inf_to_num(const string_type&) or inf_to_str(const string_type&)")
|
635
|
+
basic_json_options& replace_pos_inf(bool replace)
|
636
|
+
{
|
637
|
+
this->can_read_pos_inf_replacement_ = replace;
|
638
|
+
return *this;
|
639
|
+
}
|
640
|
+
|
641
|
+
JSONCONS_DEPRECATED_MSG("Instead, use neginf_to_num(const string_type&) or neginf_to_str(const string_type&)")
|
642
|
+
basic_json_options& replace_neg_inf(bool replace)
|
643
|
+
{
|
644
|
+
this->can_read_neg_inf_replacement_ = replace;
|
645
|
+
return *this;
|
646
|
+
}
|
647
|
+
|
648
|
+
JSONCONS_DEPRECATED_MSG("Instead, use nan_to_num(const string_type&) or nan_to_str(const string_type&)")
|
649
|
+
basic_json_options& nan_replacement(const string_type& value)
|
650
|
+
{
|
651
|
+
this->nan_replacement_ = value;
|
652
|
+
|
653
|
+
this->can_read_nan_replacement_ = is_string(value);
|
654
|
+
|
655
|
+
return *this;
|
656
|
+
}
|
657
|
+
|
658
|
+
JSONCONS_DEPRECATED_MSG("Instead, use inf_to_num(const string_type&) or inf_to_str(const string_type&)")
|
659
|
+
basic_json_options& pos_inf_replacement(const string_type& value)
|
660
|
+
{
|
661
|
+
this->pos_inf_replacement_ = value;
|
662
|
+
this->can_read_pos_inf_replacement_ = is_string(value);
|
663
|
+
return *this;
|
664
|
+
}
|
665
|
+
|
666
|
+
JSONCONS_DEPRECATED_MSG("Instead, use neginf_to_num(const string_type&) or neginf_to_str(const string_type&)")
|
667
|
+
basic_json_options& neg_inf_replacement(const string_type& value)
|
668
|
+
{
|
669
|
+
this->neg_inf_replacement_ = value;
|
670
|
+
this->can_read_neg_inf_replacement_ = is_string(value);
|
671
|
+
return *this;
|
672
|
+
}
|
673
|
+
|
674
|
+
basic_json_options& byte_string_format(byte_string_chars_format value) {this->byte_string_format_ = value; return *this;}
|
675
|
+
|
676
|
+
basic_json_options& bigint_format(bigint_chars_format value) {this->bigint_format_ = value; return *this;}
|
677
|
+
|
678
|
+
basic_json_options& object_object_line_splits(line_split_kind value) {this->object_object_line_splits_ = value; return *this;}
|
679
|
+
|
680
|
+
basic_json_options& array_object_line_splits(line_split_kind value) {this->array_object_line_splits_ = value; return *this;}
|
681
|
+
|
682
|
+
basic_json_options& object_array_line_splits(line_split_kind value) {this->object_array_line_splits_ = value; return *this;}
|
683
|
+
|
684
|
+
basic_json_options& array_array_line_splits(line_split_kind value) {this->array_array_line_splits_ = value; return *this;}
|
685
|
+
|
686
|
+
basic_json_options& indent_size(uint8_t value)
|
687
|
+
{
|
688
|
+
this->indent_size_ = value;
|
689
|
+
return *this;
|
690
|
+
}
|
691
|
+
|
692
|
+
basic_json_options& spaces_around_colon(spaces_option value)
|
693
|
+
{
|
694
|
+
this->spaces_around_colon_ = value;
|
695
|
+
return *this;
|
696
|
+
}
|
697
|
+
|
698
|
+
basic_json_options& spaces_around_comma(spaces_option value)
|
699
|
+
{
|
700
|
+
this->spaces_around_comma_ = value;
|
701
|
+
return *this;
|
702
|
+
}
|
703
|
+
|
704
|
+
basic_json_options& pad_inside_object_braces(bool value)
|
705
|
+
{
|
706
|
+
this->pad_inside_object_braces_ = value;
|
707
|
+
return *this;
|
708
|
+
}
|
709
|
+
|
710
|
+
basic_json_options& pad_inside_array_brackets(bool value)
|
711
|
+
{
|
712
|
+
this->pad_inside_array_brackets_ = value;
|
713
|
+
return *this;
|
714
|
+
}
|
715
|
+
|
716
|
+
basic_json_options& new_line_chars(const string_type& value)
|
717
|
+
{
|
718
|
+
this->new_line_chars_ = value;
|
719
|
+
return *this;
|
720
|
+
}
|
721
|
+
|
722
|
+
basic_json_options& lossless_number(bool value)
|
723
|
+
{
|
724
|
+
this->lossless_number_ = value;
|
725
|
+
return *this;
|
726
|
+
}
|
727
|
+
|
728
|
+
basic_json_options& line_length_limit(std::size_t value)
|
729
|
+
{
|
730
|
+
this->line_length_limit_ = value;
|
731
|
+
return *this;
|
732
|
+
}
|
733
|
+
|
734
|
+
basic_json_options& float_format(float_chars_format value)
|
735
|
+
{
|
736
|
+
this->float_format_ = value;
|
737
|
+
return *this;
|
738
|
+
}
|
739
|
+
|
740
|
+
basic_json_options& precision(int8_t value)
|
741
|
+
{
|
742
|
+
this->precision_ = value;
|
743
|
+
return *this;
|
744
|
+
}
|
745
|
+
|
746
|
+
basic_json_options& escape_all_non_ascii(bool value)
|
747
|
+
{
|
748
|
+
this->escape_all_non_ascii_ = value;
|
749
|
+
return *this;
|
750
|
+
}
|
751
|
+
|
752
|
+
basic_json_options& escape_solidus(bool value)
|
753
|
+
{
|
754
|
+
this->escape_solidus_ = value;
|
755
|
+
return *this;
|
756
|
+
}
|
757
|
+
|
758
|
+
basic_json_options& max_nesting_depth(int value)
|
759
|
+
{
|
760
|
+
this->max_nesting_depth_ = value;
|
761
|
+
return *this;
|
762
|
+
}
|
763
|
+
|
764
|
+
#if !defined(JSONCONS_NO_DEPRECATED)
|
765
|
+
JSONCONS_DEPRECATED_MSG("Instead, use bigint_format(bigint_chars_format)")
|
766
|
+
basic_json_options& big_integer_format(bigint_chars_format value) {this->bigint_format_ = value; return *this;}
|
767
|
+
|
768
|
+
JSONCONS_DEPRECATED_MSG("Instead, use bigint_format(bigint_chars_format)")
|
769
|
+
basic_json_options& bignum_format(bigint_chars_format value) {this->bigint_format_ = value; return *this;}
|
770
|
+
|
771
|
+
JSONCONS_DEPRECATED_MSG("Instead, use float_format(float_chars_format)")
|
772
|
+
basic_json_options& floating_point_format(float_chars_format value)
|
773
|
+
{
|
774
|
+
this->float_format_ = value;
|
775
|
+
return *this;
|
776
|
+
}
|
777
|
+
|
778
|
+
JSONCONS_DEPRECATED_MSG("Instead, use lossless_number(bool)")
|
779
|
+
basic_json_options& dec_to_str(bool value)
|
780
|
+
{
|
781
|
+
this->lossless_number_ = value;
|
782
|
+
return *this;
|
783
|
+
}
|
784
|
+
|
785
|
+
JSONCONS_DEPRECATED_MSG("Instead, use indent_size(uint8_t_t)")
|
786
|
+
basic_json_options& indent(uint8_t value)
|
787
|
+
{
|
788
|
+
return indent_size(value);
|
789
|
+
}
|
790
|
+
|
791
|
+
JSONCONS_DEPRECATED_MSG("Instead, use object_object_line_splits(line_split_kind)")
|
792
|
+
basic_json_options& object_object_split_lines(line_split_kind value) {this->object_object_line_splits_ = value; return *this;}
|
793
|
+
|
794
|
+
JSONCONS_DEPRECATED_MSG("Instead, use array_object_line_splits(line_split_kind)")
|
795
|
+
basic_json_options& array_object_split_lines(line_split_kind value) {this->array_object_line_splits_ = value; return *this;}
|
796
|
+
|
797
|
+
JSONCONS_DEPRECATED_MSG("Instead, use object_array_line_splits(line_split_kind)")
|
798
|
+
basic_json_options& object_array_split_lines(line_split_kind value) {this->object_array_line_splits_ = value; return *this;}
|
799
|
+
|
800
|
+
JSONCONS_DEPRECATED_MSG("Instead, use array_array_line_splits(line_split_kind)")
|
801
|
+
basic_json_options& array_array_split_lines(line_split_kind value) {this->array_array_line_splits_ = value; return *this;}
|
802
|
+
#endif
|
803
|
+
private:
|
804
|
+
enum class input_state {initial,begin_quote,character,end_quote,escape,error};
|
805
|
+
bool is_string(const string_type& s) const
|
806
|
+
{
|
807
|
+
input_state state = input_state::initial;
|
808
|
+
for (char_type c : s)
|
809
|
+
{
|
810
|
+
switch (c)
|
811
|
+
{
|
812
|
+
case '\t': case ' ': case '\n': case'\r':
|
813
|
+
break;
|
814
|
+
case '\\':
|
815
|
+
state = input_state::escape;
|
816
|
+
break;
|
817
|
+
case '\"':
|
818
|
+
switch (state)
|
819
|
+
{
|
820
|
+
case input_state::initial:
|
821
|
+
state = input_state::begin_quote;
|
822
|
+
break;
|
823
|
+
case input_state::begin_quote:
|
824
|
+
state = input_state::end_quote;
|
825
|
+
break;
|
826
|
+
case input_state::character:
|
827
|
+
state = input_state::end_quote;
|
828
|
+
break;
|
829
|
+
case input_state::end_quote:
|
830
|
+
state = input_state::error;
|
831
|
+
break;
|
832
|
+
case input_state::escape:
|
833
|
+
state = input_state::character;
|
834
|
+
break;
|
835
|
+
default:
|
836
|
+
state = input_state::character;
|
837
|
+
break;
|
838
|
+
}
|
839
|
+
break;
|
840
|
+
default:
|
841
|
+
break;
|
842
|
+
}
|
843
|
+
|
844
|
+
}
|
845
|
+
return state == input_state::end_quote;
|
846
|
+
}
|
847
|
+
};
|
848
|
+
|
849
|
+
using json_options = basic_json_options<char>;
|
850
|
+
using wjson_options = basic_json_options<wchar_t>;
|
851
|
+
|
852
|
+
#if !defined(JSONCONS_NO_DEPRECATED)
|
853
|
+
JSONCONS_DEPRECATED_MSG("json_options") typedef json_options output_format;
|
854
|
+
JSONCONS_DEPRECATED_MSG("wjson_options") typedef wjson_options woutput_format;
|
855
|
+
JSONCONS_DEPRECATED_MSG("json_options") typedef json_options serialization_options;
|
856
|
+
JSONCONS_DEPRECATED_MSG("wjson_options") typedef wjson_options wserialization_options;
|
857
|
+
JSONCONS_DEPRECATED_MSG("json_options") typedef json_options json_serializing_options;
|
858
|
+
JSONCONS_DEPRECATED_MSG("wjson_options") typedef wjson_options wjson_serializing_options;
|
859
|
+
#endif
|
860
|
+
|
861
|
+
}
|
862
|
+
#endif
|