jsoncons 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +7 -0
  2. data/ext/jsoncons/extconf.rb +43 -0
  3. data/ext/jsoncons/jsoncons.cpp +161 -0
  4. data/ext/jsoncons/jsoncons.h +10 -0
  5. data/jsoncons.gemspec +44 -0
  6. data/lib/jsoncons/jsoncons/examples/input/address-book.json +13 -0
  7. data/lib/jsoncons/jsoncons/examples/input/books.json +28 -0
  8. data/lib/jsoncons/jsoncons/examples/input/countries.json +7 -0
  9. data/lib/jsoncons/jsoncons/examples/input/employees.json +30 -0
  10. data/lib/jsoncons/jsoncons/examples/input/jsonschema/name.json +15 -0
  11. data/lib/jsoncons/jsoncons/examples/input/multiple-json-objects.json +3 -0
  12. data/lib/jsoncons/jsoncons/examples/input/sales.csv +6 -0
  13. data/lib/jsoncons/jsoncons/examples/input/store.json +28 -0
  14. data/lib/jsoncons/jsoncons/examples/input/tasks.csv +6 -0
  15. data/lib/jsoncons/jsoncons/include/jsoncons/allocator_holder.hpp +38 -0
  16. data/lib/jsoncons/jsoncons/include/jsoncons/basic_json.hpp +5905 -0
  17. data/lib/jsoncons/jsoncons/include/jsoncons/bigint.hpp +1611 -0
  18. data/lib/jsoncons/jsoncons/include/jsoncons/byte_string.hpp +820 -0
  19. data/lib/jsoncons/jsoncons/include/jsoncons/config/binary_config.hpp +226 -0
  20. data/lib/jsoncons/jsoncons/include/jsoncons/config/compiler_support.hpp +375 -0
  21. data/lib/jsoncons/jsoncons/include/jsoncons/config/jsoncons_config.hpp +309 -0
  22. data/lib/jsoncons/jsoncons/include/jsoncons/config/version.hpp +40 -0
  23. data/lib/jsoncons/jsoncons/include/jsoncons/conv_error.hpp +218 -0
  24. data/lib/jsoncons/jsoncons/include/jsoncons/decode_json.hpp +209 -0
  25. data/lib/jsoncons/jsoncons/include/jsoncons/decode_traits.hpp +651 -0
  26. data/lib/jsoncons/jsoncons/include/jsoncons/detail/endian.hpp +44 -0
  27. data/lib/jsoncons/jsoncons/include/jsoncons/detail/grisu3.hpp +312 -0
  28. data/lib/jsoncons/jsoncons/include/jsoncons/detail/optional.hpp +483 -0
  29. data/lib/jsoncons/jsoncons/include/jsoncons/detail/parse_number.hpp +1133 -0
  30. data/lib/jsoncons/jsoncons/include/jsoncons/detail/span.hpp +188 -0
  31. data/lib/jsoncons/jsoncons/include/jsoncons/detail/string_view.hpp +537 -0
  32. data/lib/jsoncons/jsoncons/include/jsoncons/detail/string_wrapper.hpp +370 -0
  33. data/lib/jsoncons/jsoncons/include/jsoncons/detail/write_number.hpp +567 -0
  34. data/lib/jsoncons/jsoncons/include/jsoncons/encode_json.hpp +315 -0
  35. data/lib/jsoncons/jsoncons/include/jsoncons/encode_traits.hpp +378 -0
  36. data/lib/jsoncons/jsoncons/include/jsoncons/json.hpp +18 -0
  37. data/lib/jsoncons/jsoncons/include/jsoncons/json_array.hpp +324 -0
  38. data/lib/jsoncons/jsoncons/include/jsoncons/json_content_handler.hpp +12 -0
  39. data/lib/jsoncons/jsoncons/include/jsoncons/json_cursor.hpp +448 -0
  40. data/lib/jsoncons/jsoncons/include/jsoncons/json_decoder.hpp +420 -0
  41. data/lib/jsoncons/jsoncons/include/jsoncons/json_encoder.hpp +1587 -0
  42. data/lib/jsoncons/jsoncons/include/jsoncons/json_error.hpp +156 -0
  43. data/lib/jsoncons/jsoncons/include/jsoncons/json_exception.hpp +241 -0
  44. data/lib/jsoncons/jsoncons/include/jsoncons/json_filter.hpp +653 -0
  45. data/lib/jsoncons/jsoncons/include/jsoncons/json_fwd.hpp +23 -0
  46. data/lib/jsoncons/jsoncons/include/jsoncons/json_object.hpp +1772 -0
  47. data/lib/jsoncons/jsoncons/include/jsoncons/json_options.hpp +862 -0
  48. data/lib/jsoncons/jsoncons/include/jsoncons/json_parser.hpp +2900 -0
  49. data/lib/jsoncons/jsoncons/include/jsoncons/json_reader.hpp +731 -0
  50. data/lib/jsoncons/jsoncons/include/jsoncons/json_traits_macros.hpp +1072 -0
  51. data/lib/jsoncons/jsoncons/include/jsoncons/json_traits_macros_deprecated.hpp +144 -0
  52. data/lib/jsoncons/jsoncons/include/jsoncons/json_type.hpp +206 -0
  53. data/lib/jsoncons/jsoncons/include/jsoncons/json_type_traits.hpp +1830 -0
  54. data/lib/jsoncons/jsoncons/include/jsoncons/json_visitor.hpp +1560 -0
  55. data/lib/jsoncons/jsoncons/include/jsoncons/json_visitor2.hpp +2079 -0
  56. data/lib/jsoncons/jsoncons/include/jsoncons/pretty_print.hpp +89 -0
  57. data/lib/jsoncons/jsoncons/include/jsoncons/ser_context.hpp +62 -0
  58. data/lib/jsoncons/jsoncons/include/jsoncons/sink.hpp +289 -0
  59. data/lib/jsoncons/jsoncons/include/jsoncons/source.hpp +777 -0
  60. data/lib/jsoncons/jsoncons/include/jsoncons/source_adaptor.hpp +148 -0
  61. data/lib/jsoncons/jsoncons/include/jsoncons/staj2_cursor.hpp +1189 -0
  62. data/lib/jsoncons/jsoncons/include/jsoncons/staj_cursor.hpp +1254 -0
  63. data/lib/jsoncons/jsoncons/include/jsoncons/staj_iterator.hpp +449 -0
  64. data/lib/jsoncons/jsoncons/include/jsoncons/tag_type.hpp +245 -0
  65. data/lib/jsoncons/jsoncons/include/jsoncons/text_source_adaptor.hpp +144 -0
  66. data/lib/jsoncons/jsoncons/include/jsoncons/traits_extension.hpp +884 -0
  67. data/lib/jsoncons/jsoncons/include/jsoncons/typed_array_view.hpp +250 -0
  68. data/lib/jsoncons/jsoncons/include/jsoncons/unicode_traits.hpp +1330 -0
  69. data/lib/jsoncons/jsoncons/include/jsoncons/uri.hpp +635 -0
  70. data/lib/jsoncons/jsoncons/include/jsoncons/value_converter.hpp +340 -0
  71. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson.hpp +23 -0
  72. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_cursor.hpp +320 -0
  73. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_decimal128.hpp +865 -0
  74. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_encoder.hpp +585 -0
  75. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_error.hpp +103 -0
  76. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_oid.hpp +245 -0
  77. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_options.hpp +75 -0
  78. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_parser.hpp +645 -0
  79. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_reader.hpp +92 -0
  80. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/bson_type.hpp +44 -0
  81. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/decode_bson.hpp +201 -0
  82. data/lib/jsoncons/jsoncons/include/jsoncons_ext/bson/encode_bson.hpp +144 -0
  83. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor.hpp +26 -0
  84. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_cursor.hpp +351 -0
  85. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_cursor2.hpp +265 -0
  86. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_detail.hpp +93 -0
  87. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_encoder.hpp +1766 -0
  88. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_error.hpp +105 -0
  89. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_options.hpp +113 -0
  90. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_parser.hpp +1942 -0
  91. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/cbor_reader.hpp +116 -0
  92. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/decode_cbor.hpp +203 -0
  93. data/lib/jsoncons/jsoncons/include/jsoncons_ext/cbor/encode_cbor.hpp +151 -0
  94. data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv.hpp +17 -0
  95. data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv_cursor.hpp +358 -0
  96. data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv_encoder.hpp +954 -0
  97. data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv_error.hpp +85 -0
  98. data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv_options.hpp +973 -0
  99. data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv_parser.hpp +2099 -0
  100. data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv_reader.hpp +348 -0
  101. data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/csv_serializer.hpp +12 -0
  102. data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/decode_csv.hpp +208 -0
  103. data/lib/jsoncons/jsoncons/include/jsoncons_ext/csv/encode_csv.hpp +122 -0
  104. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jmespath/jmespath.hpp +5215 -0
  105. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jmespath/jmespath_error.hpp +215 -0
  106. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpatch/jsonpatch.hpp +579 -0
  107. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpatch/jsonpatch_error.hpp +121 -0
  108. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/expression.hpp +3329 -0
  109. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/flatten.hpp +432 -0
  110. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/json_location.hpp +445 -0
  111. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/json_query.hpp +115 -0
  112. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/jsonpath.hpp +13 -0
  113. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/jsonpath_error.hpp +240 -0
  114. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/jsonpath_expression.hpp +2612 -0
  115. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpath/jsonpath_selector.hpp +1322 -0
  116. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpointer/jsonpointer.hpp +1577 -0
  117. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonpointer/jsonpointer_error.hpp +119 -0
  118. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/format_validator.hpp +968 -0
  119. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/json_validator.hpp +120 -0
  120. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/jsonschema.hpp +13 -0
  121. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/jsonschema_error.hpp +105 -0
  122. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/jsonschema_version.hpp +18 -0
  123. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/keyword_validator.hpp +1745 -0
  124. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/keyword_validator_factory.hpp +556 -0
  125. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/schema_draft7.hpp +198 -0
  126. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/schema_location.hpp +200 -0
  127. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/schema_version.hpp +35 -0
  128. data/lib/jsoncons/jsoncons/include/jsoncons_ext/jsonschema/subschema.hpp +144 -0
  129. data/lib/jsoncons/jsoncons/include/jsoncons_ext/mergepatch/mergepatch.hpp +103 -0
  130. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/decode_msgpack.hpp +202 -0
  131. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/encode_msgpack.hpp +142 -0
  132. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack.hpp +24 -0
  133. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_cursor.hpp +343 -0
  134. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_cursor2.hpp +259 -0
  135. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_encoder.hpp +753 -0
  136. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_error.hpp +94 -0
  137. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_options.hpp +74 -0
  138. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_parser.hpp +748 -0
  139. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_reader.hpp +116 -0
  140. data/lib/jsoncons/jsoncons/include/jsoncons_ext/msgpack/msgpack_type.hpp +63 -0
  141. data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/decode_ubjson.hpp +201 -0
  142. data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/encode_ubjson.hpp +142 -0
  143. data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson.hpp +23 -0
  144. data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson_cursor.hpp +307 -0
  145. data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson_encoder.hpp +502 -0
  146. data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson_error.hpp +100 -0
  147. data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson_options.hpp +87 -0
  148. data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson_parser.hpp +880 -0
  149. data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson_reader.hpp +92 -0
  150. data/lib/jsoncons/jsoncons/include/jsoncons_ext/ubjson/ubjson_type.hpp +43 -0
  151. data/lib/jsoncons/version.rb +5 -0
  152. data/lib/jsoncons.rb +33 -0
  153. data/test/jsoncons_test.rb +108 -0
  154. data/test/test_helper.rb +7 -0
  155. metadata +268 -0
@@ -0,0 +1,240 @@
1
+ /// Copyright 2021 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_JSONPATH_JSONPATH_ERROR_HPP
8
+ #define JSONCONS_JSONPATH_JSONPATH_ERROR_HPP
9
+
10
+ #include <jsoncons/json_exception.hpp>
11
+ #include <system_error>
12
+
13
+ namespace jsoncons { namespace jsonpath {
14
+
15
+ enum class jsonpath_errc
16
+ {
17
+ success = 0,
18
+ expected_root_or_function,
19
+ expected_current_node,
20
+ expected_rparen,
21
+ expected_rbracket,
22
+ expected_separator,
23
+ expected_forward_slash,
24
+ expected_slice_start,
25
+ expected_slice_end,
26
+ expected_slice_step,
27
+ expected_bracket_specifier_or_union,
28
+ unexpected_operator,
29
+ invalid_function_name,
30
+ invalid_argument,
31
+ invalid_arity,
32
+ function_name_not_found,
33
+ parse_error_in_filter,
34
+ argument_parse_error,
35
+ unidentified_error,
36
+ unexpected_eof,
37
+ expected_colon_dot_left_bracket_comma_or_rbracket,
38
+ argument_to_unflatten_invalid,
39
+ invalid_flattened_key,
40
+ step_cannot_be_zero,
41
+ invalid_number,
42
+ illegal_escaped_character,
43
+ invalid_codepoint,
44
+ unknown_function,
45
+ invalid_type,
46
+ unbalanced_parentheses,
47
+ syntax_error,
48
+ expected_comparator,
49
+ expected_or,
50
+ expected_and,
51
+ expected_comma_or_rparen,
52
+ expected_comma_or_rbracket,
53
+ expected_relative_path
54
+ };
55
+
56
+ class jsonpath_error_category_impl
57
+ : public std::error_category
58
+ {
59
+ public:
60
+ const char* name() const noexcept override
61
+ {
62
+ return "jsoncons/jsonpath";
63
+ }
64
+ std::string message(int ev) const override
65
+ {
66
+ switch (static_cast<jsonpath_errc>(ev))
67
+ {
68
+ case jsonpath_errc::expected_root_or_function:
69
+ return "Expected '$' or function expression";
70
+ case jsonpath_errc::expected_current_node:
71
+ return "Expected @";
72
+ case jsonpath_errc::expected_rbracket:
73
+ return "Expected ]";
74
+ case jsonpath_errc::expected_rparen:
75
+ return "Expected )";
76
+ case jsonpath_errc::expected_slice_start:
77
+ return "Expected slice start";
78
+ case jsonpath_errc::expected_slice_end:
79
+ return "Expected slice end";
80
+ case jsonpath_errc::expected_slice_step:
81
+ return "Expected slice step";
82
+ case jsonpath_errc::expected_separator:
83
+ return "Expected dot or left bracket separator";
84
+ case jsonpath_errc::expected_forward_slash:
85
+ return "Invalid path filter, expected '/'";
86
+ case jsonpath_errc::expected_bracket_specifier_or_union:
87
+ return "Expected index, single or double quoted name, expression, filter, absolute ('$') path or relative ('@') path";
88
+ case jsonpath_errc::invalid_function_name:
89
+ return "Invalid function name";
90
+ case jsonpath_errc::invalid_argument:
91
+ return "Invalid argument type";
92
+ case jsonpath_errc::invalid_arity:
93
+ return "Incorrect number of arguments";
94
+ case jsonpath_errc::function_name_not_found:
95
+ return "Function name not found";
96
+ case jsonpath_errc::parse_error_in_filter:
97
+ return "Could not parse JSON expression in a JSONPath filter";
98
+ case jsonpath_errc::argument_parse_error:
99
+ return "Could not parse JSON expression passed to JSONPath function";
100
+ case jsonpath_errc::unidentified_error:
101
+ return "Unidentified error";
102
+ case jsonpath_errc::unexpected_eof:
103
+ return "Unexpected EOF while parsing jsonpath expression";
104
+ case jsonpath_errc::expected_colon_dot_left_bracket_comma_or_rbracket:
105
+ return "Expected ':', '.', '[', ',', or ']'";
106
+ case jsonpath_errc::argument_to_unflatten_invalid:
107
+ return "Argument to unflatten must be an object";
108
+ case jsonpath_errc::invalid_flattened_key:
109
+ return "Flattened key is invalid";
110
+ case jsonpath_errc::step_cannot_be_zero:
111
+ return "Slice step cannot be zero";
112
+ case jsonpath_errc::invalid_number:
113
+ return "Invalid number";
114
+ case jsonpath_errc::illegal_escaped_character:
115
+ return "Illegal escaped character";
116
+ case jsonpath_errc::invalid_codepoint:
117
+ return "Invalid codepoint";
118
+ case jsonpath_errc::unknown_function:
119
+ return "Unknown function";
120
+ case jsonpath_errc::invalid_type:
121
+ return "Invalid type";
122
+ case jsonpath_errc::unbalanced_parentheses:
123
+ return "Unbalanced parentheses";
124
+ case jsonpath_errc::syntax_error:
125
+ return "Syntax error";
126
+ case jsonpath_errc::expected_comparator:
127
+ return "Expected comparator";
128
+ case jsonpath_errc::expected_or:
129
+ return "Expected operator '||'";
130
+ case jsonpath_errc::expected_and:
131
+ return "Expected operator '&&'";
132
+ case jsonpath_errc::expected_comma_or_rparen:
133
+ return "Expected comma or right parenthesis";
134
+ case jsonpath_errc::expected_comma_or_rbracket:
135
+ return "Expected comma or right bracket";
136
+ case jsonpath_errc::expected_relative_path:
137
+ return "Expected unquoted string, or single or double quoted string, or index or '*'";
138
+ default:
139
+ return "Unknown jsonpath parser error";
140
+ }
141
+ }
142
+ };
143
+
144
+ inline
145
+ const std::error_category& jsonpath_error_category()
146
+ {
147
+ static jsonpath_error_category_impl instance;
148
+ return instance;
149
+ }
150
+
151
+ inline
152
+ std::error_code make_error_code(jsonpath_errc result)
153
+ {
154
+ return std::error_code(static_cast<int>(result),jsonpath_error_category());
155
+ }
156
+
157
+ } // jsonpath
158
+ } // jsoncons
159
+
160
+ namespace std {
161
+ template<>
162
+ struct is_error_code_enum<jsoncons::jsonpath::jsonpath_errc> : public true_type
163
+ {
164
+ };
165
+ }
166
+
167
+ namespace jsoncons { namespace jsonpath {
168
+
169
+ class jsonpath_error : public std::system_error, public virtual json_exception
170
+ {
171
+ std::size_t line_number_;
172
+ std::size_t column_number_;
173
+ mutable std::string what_;
174
+ public:
175
+ jsonpath_error(std::error_code ec)
176
+ : std::system_error(ec), line_number_(0), column_number_(0)
177
+ {
178
+ }
179
+ jsonpath_error(std::error_code ec, const std::string& what_arg)
180
+ : std::system_error(ec, what_arg), line_number_(0), column_number_(0)
181
+ {
182
+ }
183
+ jsonpath_error(std::error_code ec, std::size_t position)
184
+ : std::system_error(ec), line_number_(0), column_number_(position)
185
+ {
186
+ }
187
+ jsonpath_error(std::error_code ec, std::size_t line, std::size_t column)
188
+ : std::system_error(ec), line_number_(line), column_number_(column)
189
+ {
190
+ }
191
+ jsonpath_error(const jsonpath_error& other) = default;
192
+
193
+ jsonpath_error(jsonpath_error&& other) = default;
194
+
195
+ const char* what() const noexcept override
196
+ {
197
+ if (what_.empty())
198
+ {
199
+ JSONCONS_TRY
200
+ {
201
+ what_.append(std::system_error::what());
202
+ if (line_number_ != 0 && column_number_ != 0)
203
+ {
204
+ what_.append(" at line ");
205
+ what_.append(std::to_string(line_number_));
206
+ what_.append(" and column ");
207
+ what_.append(std::to_string(column_number_));
208
+ }
209
+ else if (column_number_ != 0)
210
+ {
211
+ what_.append(" at position ");
212
+ what_.append(std::to_string(column_number_));
213
+ }
214
+ return what_.c_str();
215
+ }
216
+ JSONCONS_CATCH(...)
217
+ {
218
+ return std::system_error::what();
219
+ }
220
+ }
221
+ else
222
+ {
223
+ return what_.c_str();
224
+ }
225
+ }
226
+
227
+ std::size_t line() const noexcept
228
+ {
229
+ return line_number_;
230
+ }
231
+
232
+ std::size_t column() const noexcept
233
+ {
234
+ return column_number_;
235
+ }
236
+ };
237
+
238
+ }}
239
+
240
+ #endif