simdjson  3.2.3
Ridiculously Fast JSON
jsonparser.h
1 // TODO Remove this -- deprecated API and files
2 
3 #ifndef SIMDJSON_DOM_JSONPARSER_H
4 #define SIMDJSON_DOM_JSONPARSER_H
5 
6 #include "simdjson/dom/base.h"
7 #include "simdjson/dom/parser.h"
8 #include "simdjson/dom/element.h"
9 
10 #include "simdjson/dom/parser-inl.h"
11 
12 namespace simdjson {
13 
14 //
15 // C API (json_parse and build_parsed_json) declarations
16 //
17 
18 #ifndef SIMDJSON_DISABLE_DEPRECATED_API
19 [[deprecated("Use parser.parse() instead")]]
20 inline int json_parse(const uint8_t *buf, size_t len, dom::parser &parser, bool realloc_if_needed = true) noexcept {
21  error_code code = parser.parse(buf, len, realloc_if_needed).error();
22  // The deprecated json_parse API is a signal that the user plans to *use* the error code / valid
23  // bits in the parser instead of heeding the result code. The normal parser unsets those in
24  // anticipation of making the error code ephemeral.
25  // Here we put the code back into the parser, until we've removed this method.
26  parser.valid = code == SUCCESS;
27  parser.error = code;
28  return code;
29 }
30 [[deprecated("Use parser.parse() instead")]]
31 inline int json_parse(const char *buf, size_t len, dom::parser &parser, bool realloc_if_needed = true) noexcept {
32  error_code code = parser.parse(buf, len, realloc_if_needed).error();
33  // The deprecated json_parse API is a signal that the user plans to *use* the error code / valid
34  // bits in the parser instead of heeding the result code. The normal parser unsets those in
35  // anticipation of making the error code ephemeral.
36  // Here we put the code back into the parser, until we've removed this method.
37  parser.valid = code == SUCCESS;
38  parser.error = code;
39  return code;
40 }
41 [[deprecated("Use parser.parse() instead")]]
42 inline int json_parse(const std::string &s, dom::parser &parser, bool realloc_if_needed = true) noexcept {
43  error_code code = parser.parse(s.data(), s.length(), realloc_if_needed).error();
44  // The deprecated json_parse API is a signal that the user plans to *use* the error code / valid
45  // bits in the parser instead of heeding the result code. The normal parser unsets those in
46  // anticipation of making the error code ephemeral.
47  // Here we put the code back into the parser, until we've removed this method.
48  parser.valid = code == SUCCESS;
49  parser.error = code;
50  return code;
51 }
52 [[deprecated("Use parser.parse() instead")]]
53 inline int json_parse(const padded_string &s, dom::parser &parser) noexcept {
54  error_code code = parser.parse(s).error();
55  // The deprecated json_parse API is a signal that the user plans to *use* the error code / valid
56  // bits in the parser instead of heeding the result code. The normal parser unsets those in
57  // anticipation of making the error code ephemeral.
58  // Here we put the code back into the parser, until we've removed this method.
59  parser.valid = code == SUCCESS;
60  parser.error = code;
61  return code;
62 }
63 
64 [[deprecated("Use parser.parse() instead")]]
65 simdjson_warn_unused inline dom::parser build_parsed_json(const uint8_t *buf, size_t len, bool realloc_if_needed = true) noexcept {
66  dom::parser parser;
67  error_code code = parser.parse(buf, len, realloc_if_needed).error();
68  // The deprecated json_parse API is a signal that the user plans to *use* the error code / valid
69  // bits in the parser instead of heeding the result code. The normal parser unsets those in
70  // anticipation of making the error code ephemeral.
71  // Here we put the code back into the parser, until we've removed this method.
72  parser.valid = code == SUCCESS;
73  parser.error = code;
74  return parser;
75 }
76 [[deprecated("Use parser.parse() instead")]]
77 simdjson_warn_unused inline dom::parser build_parsed_json(const char *buf, size_t len, bool realloc_if_needed = true) noexcept {
78  dom::parser parser;
79  error_code code = parser.parse(buf, len, realloc_if_needed).error();
80  // The deprecated json_parse API is a signal that the user plans to *use* the error code / valid
81  // bits in the parser instead of heeding the result code. The normal parser unsets those in
82  // anticipation of making the error code ephemeral.
83  // Here we put the code back into the parser, until we've removed this method.
84  parser.valid = code == SUCCESS;
85  parser.error = code;
86  return parser;
87 }
88 [[deprecated("Use parser.parse() instead")]]
89 simdjson_warn_unused inline dom::parser build_parsed_json(const std::string &s, bool realloc_if_needed = true) noexcept {
90  dom::parser parser;
91  error_code code = parser.parse(s.data(), s.length(), realloc_if_needed).error();
92  // The deprecated json_parse API is a signal that the user plans to *use* the error code / valid
93  // bits in the parser instead of heeding the result code. The normal parser unsets those in
94  // anticipation of making the error code ephemeral.
95  // Here we put the code back into the parser, until we've removed this method.
96  parser.valid = code == SUCCESS;
97  parser.error = code;
98  return parser;
99 }
100 [[deprecated("Use parser.parse() instead")]]
101 simdjson_warn_unused inline dom::parser build_parsed_json(const padded_string &s) noexcept {
102  dom::parser parser;
103  error_code code = parser.parse(s).error();
104  // The deprecated json_parse API is a signal that the user plans to *use* the error code / valid
105  // bits in the parser instead of heeding the result code. The normal parser unsets those in
106  // anticipation of making the error code ephemeral.
107  // Here we put the code back into the parser, until we've removed this method.
108  parser.valid = code == SUCCESS;
109  parser.error = code;
110  return parser;
111 }
112 #endif // SIMDJSON_DISABLE_DEPRECATED_API
113 
115 int json_parse(const char *buf, dom::parser &parser) noexcept = delete;
117 dom::parser build_parsed_json(const char *buf) noexcept = delete;
118 
119 } // namespace simdjson
120 
121 #endif // SIMDJSON_DOM_JSONPARSER_H
The top level simdjson namespace, containing everything the library provides.
Definition: base.h:8
error_code
All possible errors returned by simdjson.
Definition: error.h:19
@ SUCCESS
No error.
Definition: error.h:20