@@ -97,22 +97,24 @@ class document {
97
97
*
98
98
* The parser will allocate capacity as needed.
99
99
*/
100
- document () noexcept = default;
101
- ~document () noexcept = default ;
100
+ document () noexcept = default;
101
+ ~document () noexcept = default ;
102
102
103
103
/* *
104
104
* Take another document's buffers.
105
105
*
106
106
* @param other The document to take. Its capacity is zeroed and it is invalidated.
107
107
*/
108
108
document (document &&other) noexcept = default;
109
+ /* * @private */
109
110
document (const document &) = delete; // Disallow copying
110
111
/* *
111
112
* Take another document's buffers.
112
113
*
113
114
* @param other The document to take. Its capacity is zeroed.
114
115
*/
115
116
document &operator =(document &&other) noexcept = default ;
117
+ /* * @private */
116
118
document &operator =(const document &) = delete ; // Disallow copying
117
119
118
120
/* *
@@ -121,15 +123,19 @@ class document {
121
123
element root () const noexcept ;
122
124
123
125
/* *
124
- * Dump the raw tape for debugging.
126
+ * @private Dump the raw tape for debugging.
125
127
*
126
128
* @param os the stream to output to.
127
129
* @return false if the tape is likely wrong (e.g., you did not parse a valid JSON).
128
130
*/
129
131
bool dump_raw_tape (std::ostream &os) const noexcept ;
130
132
131
133
std::unique_ptr<uint64_t []> tape;
132
- std::unique_ptr<uint8_t []> string_buf;// should be at least byte_capacity
134
+ /* * @private String values.
135
+ *
136
+ * Should be at least byte_capacity.
137
+ */
138
+ std::unique_ptr<uint8_t []> string_buf;
133
139
134
140
private:
135
141
inline error_code set_capacity (size_t len) noexcept ;
@@ -592,6 +598,7 @@ class parser {
592
598
* DEFAULT_MAX_DEPTH.
593
599
*/
594
600
really_inline parser (size_t max_capacity = SIMDJSON_MAXSIZE_BYTES, size_t max_depth = DEFAULT_MAX_DEPTH) noexcept ;
601
+ /* * Deallocate the JSON parser. */
595
602
~parser ()=default ;
596
603
597
604
/* *
@@ -600,14 +607,14 @@ class parser {
600
607
* @param other The parser to take. Its capacity is zeroed.
601
608
*/
602
609
parser (parser &&other) = default ;
603
- parser (const parser &) = delete ; // Disallow copying
610
+ parser (const parser &) = delete ; // /< @private Disallow copying
604
611
/* *
605
612
* Take another parser's buffers and state.
606
613
*
607
614
* @param other The parser to take. Its capacity is zeroed.
608
615
*/
609
616
parser &operator =(parser &&other) = default ;
610
- parser &operator =(const parser &) = delete ; // Disallow copying
617
+ parser &operator =(const parser &) = delete ; // /< @private Disallow copying
611
618
612
619
/* *
613
620
* Load a JSON document from a file and return a reference to it.
@@ -1147,34 +1154,35 @@ class parser {
1147
1154
/* * @deprecated Use simdjson_error instead */
1148
1155
using InvalidJSON = simdjson_error;
1149
1156
1150
- // Next location to write to in the tape
1157
+ /* * @private Next location to write to in the tape */
1151
1158
uint32_t current_loc{0 };
1152
1159
1153
- // structural indices passed from stage 1 to stage 2
1160
+ /* * @private Number of structural indices passed from stage 1 to stage 2 */
1154
1161
uint32_t n_structural_indexes{0 };
1162
+ /* * @private Structural indices passed from stage 1 to stage 2 */
1155
1163
std::unique_ptr<uint32_t []> structural_indexes;
1156
1164
1157
- // location and return address of each open { or [
1165
+ /* * @private Tape location of each open { or [ */
1158
1166
std::unique_ptr<uint32_t []> containing_scope_offset;
1159
1167
#ifdef SIMDJSON_USE_COMPUTED_GOTO
1168
+ /* * @private Return address of each open { or [ */
1160
1169
std::unique_ptr<void *[]> ret_address;
1161
1170
#else
1171
+ /* * @private Return address of each open { or [ */
1162
1172
std::unique_ptr<char []> ret_address;
1163
1173
#endif
1164
1174
1165
- // Next place to write a string
1175
+ /* * @private Next write location in the string buf for stage 2 parsing */
1166
1176
uint8_t *current_string_buf_loc;
1167
1177
1178
+ /* * @deprecated Use `if (parser.parse(...).error)` instead */
1168
1179
bool valid{false };
1180
+ /* * @deprecated Use `parser.parse(...).error` instead */
1169
1181
error_code error{UNINITIALIZED};
1170
1182
1171
- // Document we're writing to
1183
+ /* * @deprecated Use `parser.parse(...).doc` instead */
1172
1184
document doc;
1173
1185
1174
- //
1175
- // TODO these are deprecated; use the results of parse instead.
1176
- //
1177
-
1178
1186
// returns true if the document parsed was valid
1179
1187
[[deprecated(" Use the result of parser.parse() instead" )]]
1180
1188
inline bool is_valid () const noexcept ;
@@ -1188,11 +1196,9 @@ class parser {
1188
1196
[[deprecated(" Use error_message() on the result of parser.parse() instead, or cout << error" )]]
1189
1197
inline std::string get_error_message () const noexcept ;
1190
1198
1191
- // print the json to std::ostream (should be valid)
1192
- // return false if the tape is likely wrong (e.g., you did not parse a valid
1193
- // JSON).
1194
1199
[[deprecated(" Use cout << on the result of parser.parse() instead" )]]
1195
1200
inline bool print_json (std::ostream &os) const noexcept ;
1201
+ /* * @private Private and deprecated: use `parser.parse(...).doc.dump_raw_tape()` instead */
1196
1202
inline bool dump_raw_tape (std::ostream &os) const noexcept ;
1197
1203
1198
1204
//
@@ -1201,54 +1207,54 @@ class parser {
1201
1207
// TODO find a way to do this without exposing the interface or crippling performance
1202
1208
//
1203
1209
1204
- // this should be called when parsing (right before writing the tapes)
1210
+ /* * @private this should be called when parsing (right before writing the tapes) */
1205
1211
inline void init_stage2 () noexcept ;
1206
- really_inline error_code on_error (error_code new_error_code) noexcept ;
1207
- really_inline error_code on_success (error_code success_code) noexcept ;
1208
- really_inline bool on_start_document (uint32_t depth) noexcept ;
1209
- really_inline bool on_start_object (uint32_t depth) noexcept ;
1210
- really_inline bool on_start_array (uint32_t depth) noexcept ;
1212
+ really_inline error_code on_error (error_code new_error_code) noexcept ; // /< @private
1213
+ really_inline error_code on_success (error_code success_code) noexcept ; // /< @private
1214
+ really_inline bool on_start_document (uint32_t depth) noexcept ; // /< @private
1215
+ really_inline bool on_start_object (uint32_t depth) noexcept ; // /< @private
1216
+ really_inline bool on_start_array (uint32_t depth) noexcept ; // /< @private
1211
1217
// TODO we're not checking this bool
1212
- really_inline bool on_end_document (uint32_t depth) noexcept ;
1213
- really_inline bool on_end_object (uint32_t depth) noexcept ;
1214
- really_inline bool on_end_array (uint32_t depth) noexcept ;
1215
- really_inline bool on_true_atom () noexcept ;
1216
- really_inline bool on_false_atom () noexcept ;
1217
- really_inline bool on_null_atom () noexcept ;
1218
- really_inline uint8_t *on_start_string () noexcept ;
1219
- really_inline bool on_end_string (uint8_t *dst) noexcept ;
1220
- really_inline bool on_number_s64 (int64_t value) noexcept ;
1221
- really_inline bool on_number_u64 (uint64_t value) noexcept ;
1222
- really_inline bool on_number_double (double value) noexcept ;
1218
+ really_inline bool on_end_document (uint32_t depth) noexcept ; // /< @private
1219
+ really_inline bool on_end_object (uint32_t depth) noexcept ; // /< @private
1220
+ really_inline bool on_end_array (uint32_t depth) noexcept ; // /< @private
1221
+ really_inline bool on_true_atom () noexcept ; // /< @private
1222
+ really_inline bool on_false_atom () noexcept ; // /< @private
1223
+ really_inline bool on_null_atom () noexcept ; // /< @private
1224
+ really_inline uint8_t *on_start_string () noexcept ; // /< @private
1225
+ really_inline bool on_end_string (uint8_t *dst) noexcept ; // /< @private
1226
+ really_inline bool on_number_s64 (int64_t value) noexcept ; // /< @private
1227
+ really_inline bool on_number_u64 (uint64_t value) noexcept ; // /< @private
1228
+ really_inline bool on_number_double (double value) noexcept ; // /< @private
1223
1229
1224
1230
private:
1225
- //
1226
- // The maximum document length this parser supports.
1227
- //
1228
- // Buffers are large enough to handle any document up to this length.
1229
- / /
1231
+ /* *
1232
+ * The maximum document length this parser supports.
1233
+ *
1234
+ * Buffers are large enough to handle any document up to this length.
1235
+ * /
1230
1236
size_t _capacity{0 };
1231
1237
1232
- //
1233
- // The maximum document length this parser will automatically support.
1234
- //
1235
- // The parser will not be automatically allocated above this amount.
1236
- / /
1238
+ /* *
1239
+ * The maximum document length this parser will automatically support.
1240
+ *
1241
+ * The parser will not be automatically allocated above this amount.
1242
+ * /
1237
1243
size_t _max_capacity;
1238
1244
1239
- //
1240
- // The maximum depth (number of nested objects and arrays) supported by this parser.
1241
- //
1242
- // Defaults to DEFAULT_MAX_DEPTH.
1243
- / /
1245
+ /* *
1246
+ * The maximum depth (number of nested objects and arrays) supported by this parser.
1247
+ *
1248
+ * Defaults to DEFAULT_MAX_DEPTH.
1249
+ * /
1244
1250
size_t _max_depth;
1245
1251
1246
- //
1247
- // The loaded buffer (reused each time load() is called)
1248
- / /
1252
+ /* *
1253
+ * The loaded buffer (reused each time load() is called)
1254
+ * /
1249
1255
std::unique_ptr<char [], decltype(&aligned_free_char)> loaded_bytes;
1250
1256
1251
- // Capacity of loaded_bytes buffer.
1257
+ /* * Capacity of loaded_bytes buffer. */
1252
1258
size_t _loaded_bytes_capacity{0 };
1253
1259
1254
1260
// all nodes are stored on the doc.tape using a 64-bit word.
@@ -1268,13 +1274,13 @@ class parser {
1268
1274
inline void write_tape (uint64_t val, internal::tape_type t) noexcept ;
1269
1275
inline void annotate_previous_loc (uint32_t saved_loc, uint64_t val) noexcept ;
1270
1276
1271
- // Ensure we have enough capacity to handle at least desired_capacity bytes,
1272
- // and auto-allocate if not.
1277
+ /* *
1278
+ * Ensure we have enough capacity to handle at least desired_capacity bytes,
1279
+ * and auto-allocate if not.
1280
+ */
1273
1281
inline error_code ensure_capacity (size_t desired_capacity) noexcept ;
1274
1282
1275
- //
1276
- // Read the file into loaded_bytes
1277
- //
1283
+ /* * Read the file into loaded_bytes */
1278
1284
inline simdjson_result<size_t > read_file (const std::string &path) noexcept ;
1279
1285
1280
1286
friend class parser ::Iterator;
0 commit comments