1
- /* auto-generated on Tue Jun 23 09:15:19 PDT 2020 . Do not edit! */
1
+ /* auto-generated on Tue 23 Jun 2020 20:51:12 EDT . Do not edit! */
2
2
/* begin file include/simdjson.h */
3
3
#ifndef SIMDJSON_H
4
4
#define SIMDJSON_H
@@ -389,6 +389,7 @@ constexpr size_t DEFAULT_MAX_DEPTH = 1024;
389
389
SIMDJSON_DISABLE_GCC_WARNING(-Wextra) \
390
390
SIMDJSON_DISABLE_GCC_WARNING(-Wattributes) \
391
391
SIMDJSON_DISABLE_GCC_WARNING(-Wimplicit-fallthrough) \
392
+ SIMDJSON_DISABLE_GCC_WARNING(-Wnon-virtual-dtor) \
392
393
SIMDJSON_DISABLE_GCC_WARNING(-Wreturn-type) \
393
394
SIMDJSON_DISABLE_GCC_WARNING(-Wshadow) \
394
395
SIMDJSON_DISABLE_GCC_WARNING(-Wunused-parameter) \
@@ -2017,7 +2018,7 @@ SIMDJSON_DISABLE_UNDESIRED_WARNINGS
2017
2018
#define SIMDJSON_SIMDJSON_VERSION_H
2018
2019
2019
2020
/** The version of simdjson being used (major.minor.revision) */
2020
- #define SIMDJSON_VERSION 0.3.1
2021
+ #define SIMDJSON_VERSION 0.4.0
2021
2022
2022
2023
namespace simdjson {
2023
2024
enum {
@@ -2028,11 +2029,11 @@ enum {
2028
2029
/**
2029
2030
* The minor version (major.MINOR.revision) of simdjson being used.
2030
2031
*/
2031
- SIMDJSON_VERSION_MINOR = 3 ,
2032
+ SIMDJSON_VERSION_MINOR = 4 ,
2032
2033
/**
2033
2034
* The revision (major.minor.REVISION) of simdjson being used.
2034
2035
*/
2035
- SIMDJSON_VERSION_REVISION = 1
2036
+ SIMDJSON_VERSION_REVISION = 0
2036
2037
};
2037
2038
} // namespace simdjson
2038
2039
@@ -2082,7 +2083,8 @@ enum error_code {
2082
2083
* Get the error message for the given error code.
2083
2084
*
2084
2085
* dom::parser parser;
2085
- * auto [doc, error] = parser.parse(" foo" );
2086
+ * dom::element doc;
2087
+ * auto error = parser.parse(" foo" ).get(doc);
2086
2088
* if (error) { printf(" Error: %s\n" , error_message(error)); }
2087
2089
*
2088
2090
* @return The error message.
@@ -2335,7 +2337,7 @@ struct padded_string final {
2335
2337
/**
2336
2338
* Create a new padded string by copying the given input.
2337
2339
*
2338
- * @param str_ the string to copy
2340
+ * @param sv_ the string to copy
2339
2341
*/
2340
2342
inline padded_string(std::string_view sv_) noexcept;
2341
2343
/**
@@ -3095,7 +3097,7 @@ class array {
3095
3097
* Get the value associated with the given JSON pointer.
3096
3098
*
3097
3099
* dom::parser parser;
3098
- * array a = parser.parse(R"([ { "foo": { "a": [ 10, 20, 30 ] }} ])");
3100
+ * array a = parser.parse(R"([ { "foo": { "a": [ 10, 20, 30 ] }} ])"_padded );
3099
3101
* a.at("0/foo/a/1") == 20
3100
3102
* a.at("0")["foo"]["a"].at(1) == 20
3101
3103
*
@@ -3434,9 +3436,13 @@ class parser {
3434
3436
* the same interface, requiring you to check the error before using the document:
3435
3437
*
3436
3438
* dom::parser parser;
3437
- * for (auto [doc, error] : parser.load_many(path)) {
3438
- * if (error) { cerr << error << endl; exit(1); }
3439
- * cout << std::string(doc["title"]) << endl;
3439
+ * dom::document_stream docs;
3440
+ * auto error = parser.load_many(path).get(docs);
3441
+ * if (error) { cerr << error << endl; exit(1); }
3442
+ * for (auto doc : docs) {
3443
+ * std::string_view title;
3444
+ * if ((error = doc["title"].get(title)) { cerr << error << endl; exit(1); }
3445
+ * cout << title << endl;
3440
3446
* }
3441
3447
*
3442
3448
* ### Threads
@@ -3449,7 +3455,7 @@ class parser {
3449
3455
* If the parser's current capacity is less than batch_size, it will allocate enough capacity
3450
3456
* to handle it (up to max_capacity).
3451
3457
*
3452
- * @param s The concatenated JSON to parse. Must have at least len + SIMDJSON_PADDING allocated bytes.
3458
+ * @param path File name pointing at the concatenated JSON to parse.
3453
3459
* @param batch_size The batch size to use. MUST be larger than the largest document. The sweet
3454
3460
* spot is cache-related: small enough to fit in cache, yet big enough to
3455
3461
* parse as many documents as possible in one tight loop.
@@ -3494,9 +3500,13 @@ class parser {
3494
3500
* the same interface, requiring you to check the error before using the document:
3495
3501
*
3496
3502
* dom::parser parser;
3497
- * for (auto [doc, error] : parser.parse_many(buf, len)) {
3498
- * if (error) { cerr << error << endl; exit(1); }
3499
- * cout << std::string(doc["title"]) << endl;
3503
+ * dom::document_stream docs;
3504
+ * auto error = parser.load_many(path).get(docs);
3505
+ * if (error) { cerr << error << endl; exit(1); }
3506
+ * for (auto doc : docs) {
3507
+ * std::string_view title;
3508
+ * if ((error = doc["title"].get(title)) { cerr << error << endl; exit(1); }
3509
+ * cout << title << endl;
3500
3510
* }
3501
3511
*
3502
3512
* ### REQUIRED: Buffer Padding
@@ -4120,7 +4130,6 @@ class element {
4120
4130
* - Object: dom::object
4121
4131
*
4122
4132
* @tparam T bool, double, uint64_t, int64_t, std::string_view, const char *, dom::array, dom::object
4123
- * @returns true if the value can be cast to the given type, false if not.
4124
4133
*/
4125
4134
template <typename T>
4126
4135
really_inline bool is () const noexcept ;
@@ -4273,8 +4282,8 @@ class element {
4273
4282
* The key will be matched against **unescaped** JSON:
4274
4283
*
4275
4284
* dom::parser parser;
4276
- * parser.parse(R"({ "a\n": 1 })")["a\n"].get<uint64_t>().value == 1
4277
- * parser.parse(R"({ "a\n": 1 })")["a\\n"].get<uint64_t>().error == NO_SUCH_FIELD
4285
+ * parser.parse(R"({ "a\n": 1 })"_padded )["a\n"].get<uint64_t>().first == 1
4286
+ * parser.parse(R"({ "a\n": 1 })"_padded )["a\\n"].get<uint64_t>().error() == NO_SUCH_FIELD
4278
4287
*
4279
4288
* @return The value associated with this field, or:
4280
4289
* - NO_SUCH_FIELD if the field does not exist in the object
@@ -4288,8 +4297,8 @@ class element {
4288
4297
* The key will be matched against **unescaped** JSON:
4289
4298
*
4290
4299
* dom::parser parser;
4291
- * parser.parse(R"({ "a\n": 1 })")["a\n"].get<uint64_t>().value == 1
4292
- * parser.parse(R"({ "a\n": 1 })")["a\\n"].get<uint64_t>().error == NO_SUCH_FIELD
4300
+ * parser.parse(R"({ "a\n": 1 })"_padded )["a\n"].get<uint64_t>().first == 1
4301
+ * parser.parse(R"({ "a\n": 1 })"_padded )["a\\n"].get<uint64_t>().error() == NO_SUCH_FIELD
4293
4302
*
4294
4303
* @return The value associated with this field, or:
4295
4304
* - NO_SUCH_FIELD if the field does not exist in the object
@@ -4301,7 +4310,7 @@ class element {
4301
4310
* Get the value associated with the given JSON pointer.
4302
4311
*
4303
4312
* dom::parser parser;
4304
- * element doc = parser.parse(R"({ "foo": { "a": [ 10, 20, 30 ] }})");
4313
+ * element doc = parser.parse(R"({ "foo": { "a": [ 10, 20, 30 ] }})"_padded );
4305
4314
* doc.at("/foo/a/1") == 20
4306
4315
* doc.at("/")["foo"]["a"].at(1) == 20
4307
4316
* doc.at("")["foo"]["a"].at(1) == 20
@@ -4328,8 +4337,8 @@ class element {
4328
4337
* The key will be matched against **unescaped** JSON:
4329
4338
*
4330
4339
* dom::parser parser;
4331
- * parser.parse(R"({ "a\n": 1 })")["a\n"].get<uint64_t>().value == 1
4332
- * parser.parse(R"({ "a\n": 1 })")["a\\n"].get<uint64_t>().error == NO_SUCH_FIELD
4340
+ * parser.parse(R"({ "a\n": 1 })"_padded )["a\n"].get<uint64_t>().first == 1
4341
+ * parser.parse(R"({ "a\n": 1 })"_padded )["a\\n"].get<uint64_t>().error() == NO_SUCH_FIELD
4333
4342
*
4334
4343
* @return The value associated with this field, or:
4335
4344
* - NO_SUCH_FIELD if the field does not exist in the object
@@ -4557,8 +4566,8 @@ class object {
4557
4566
* The key will be matched against **unescaped** JSON:
4558
4567
*
4559
4568
* dom::parser parser;
4560
- * parser.parse(R"({ "a\n": 1 })")["a\n"].get<uint64_t>().value == 1
4561
- * parser.parse(R"({ "a\n": 1 })")["a\\n"].get<uint64_t>().error == NO_SUCH_FIELD
4569
+ * parser.parse(R"({ "a\n": 1 })"_padded )["a\n"].get<uint64_t>().first == 1
4570
+ * parser.parse(R"({ "a\n": 1 })"_padded )["a\\n"].get<uint64_t>().error() == NO_SUCH_FIELD
4562
4571
*
4563
4572
* This function has linear-time complexity: the keys are checked one by one.
4564
4573
*
@@ -4574,8 +4583,8 @@ class object {
4574
4583
* The key will be matched against **unescaped** JSON:
4575
4584
*
4576
4585
* dom::parser parser;
4577
- * parser.parse(R"({ "a\n": 1 })")["a\n"].get<uint64_t>().value == 1
4578
- * parser.parse(R"({ "a\n": 1 })")["a\\n"].get<uint64_t>().error == NO_SUCH_FIELD
4586
+ * parser.parse(R"({ "a\n": 1 })"_padded )["a\n"].get<uint64_t>().first == 1
4587
+ * parser.parse(R"({ "a\n": 1 })"_padded )["a\\n"].get<uint64_t>().error() == NO_SUCH_FIELD
4579
4588
*
4580
4589
* This function has linear-time complexity: the keys are checked one by one.
4581
4590
*
@@ -4589,7 +4598,7 @@ class object {
4589
4598
* Get the value associated with the given JSON pointer.
4590
4599
*
4591
4600
* dom::parser parser;
4592
- * object obj = parser.parse(R"({ "foo": { "a": [ 10, 20, 30 ] }})");
4601
+ * object obj = parser.parse(R"({ "foo": { "a": [ 10, 20, 30 ] }})"_padded );
4593
4602
* obj.at("foo/a/1") == 20
4594
4603
* obj.at("foo")["a"].at(1) == 20
4595
4604
*
@@ -4607,8 +4616,8 @@ class object {
4607
4616
* The key will be matched against **unescaped** JSON:
4608
4617
*
4609
4618
* dom::parser parser;
4610
- * parser.parse(R"({ "a\n": 1 })")["a\n"].get<uint64_t>().value == 1
4611
- * parser.parse(R"({ "a\n": 1 })")["a\\n"].get<uint64_t>().error == NO_SUCH_FIELD
4619
+ * parser.parse(R"({ "a\n": 1 })"_padded )["a\n"].get<uint64_t>().first == 1
4620
+ * parser.parse(R"({ "a\n": 1 })"_padded )["a\\n"].get<uint64_t>().error() == NO_SUCH_FIELD
4612
4621
*
4613
4622
* This function has linear-time complexity: the keys are checked one by one.
4614
4623
*
@@ -4646,7 +4655,9 @@ class object {
4646
4655
*/
4647
4656
class key_value_pair {
4648
4657
public:
4658
+ /* * key in the key-value pair **/
4649
4659
std::string_view key;
4660
+ /* * value in the key-value pair **/
4650
4661
element value;
4651
4662
4652
4663
private:
@@ -4956,6 +4967,7 @@ inline std::ostream& operator<<(std::ostream& out, const escape_json_string &une
4956
4967
4957
4968
namespace simdjson {
4958
4969
4970
+ /* * @private **/
4959
4971
class [[deprecated(" Use the new DOM navigation API instead (see doc/basics.md)" )]] dom::parser::Iterator {
4960
4972
public:
4961
4973
inline Iterator (const dom::parser &parser) noexcept (false );
@@ -5044,11 +5056,11 @@ class [[deprecated("Use the new DOM navigation API instead (see doc/basics.md)")
5044
5056
5045
5057
inline bool is_string () const { return get_type () == ' "' ; }
5046
5058
5047
- // Returns true if the current type of node is an signed integer.
5059
+ // Returns true if the current type of the node is an signed integer.
5048
5060
// You can get its value with `get_integer()`.
5049
5061
inline bool is_integer () const { return get_type () == ' l' ; }
5050
5062
5051
- // Returns true if the current type of node is an unsigned integer.
5063
+ // Returns true if the current type of the node is an unsigned integer.
5052
5064
// You can get its value with `get_unsigned_integer()`.
5053
5065
//
5054
5066
// NOTE:
@@ -5057,19 +5069,19 @@ class [[deprecated("Use the new DOM navigation API instead (see doc/basics.md)")
5057
5069
// positive integer, such as 1, 42, or 1000000, is as a signed node.
5058
5070
// Be aware this function returns false for a signed node.
5059
5071
inline bool is_unsigned_integer () const { return get_type () == ' u' ; }
5060
-
5072
+ // Returns true if the current type of the node is a double floating-point number.
5061
5073
inline bool is_double () const { return get_type () == ' d' ; }
5062
-
5074
+ // Returns true if the current type of the node is a number (integer or floating-point).
5063
5075
inline bool is_number () const {
5064
5076
return is_integer () || is_unsigned_integer () || is_double ();
5065
5077
}
5066
-
5078
+ // Returns true if the current type of the node is a bool with true value.
5067
5079
inline bool is_true () const { return get_type () == ' t' ; }
5068
-
5080
+ // Returns true if the current type of the node is a bool with false value.
5069
5081
inline bool is_false () const { return get_type () == ' f' ; }
5070
-
5082
+ // Returns true if the current type of the node is null.
5071
5083
inline bool is_null () const { return get_type () == ' n' ; }
5072
-
5084
+ // Returns true if the type byte represents an object of an array
5073
5085
static bool is_object_or_array (uint8_t type) {
5074
5086
return ((type == ' [' ) || (type == ' {' ));
5075
5087
}
@@ -5183,15 +5195,10 @@ class [[deprecated("Use the new DOM navigation API instead (see doc/basics.md)")
5183
5195
;
5184
5196
}
5185
5197
5186
- // void to_end_scope(); // move us to
5187
- // the start of our current scope; always succeeds
5198
+
5188
5199
5189
5200
// print the node we are currently pointing at
5190
5201
inline bool print (std::ostream &os, bool escape_strings = true ) const ;
5191
- typedef struct {
5192
- size_t start_of_scope;
5193
- uint8_t scope_type;
5194
- } scopeindex_t ;
5195
5202
5196
5203
private:
5197
5204
const document &doc;
@@ -5201,6 +5208,11 @@ class [[deprecated("Use the new DOM navigation API instead (see doc/basics.md)")
5201
5208
size_t tape_length{};
5202
5209
uint8_t current_type{};
5203
5210
uint64_t current_val{};
5211
+ typedef struct {
5212
+ size_t start_of_scope;
5213
+ uint8_t scope_type;
5214
+ } scopeindex_t ;
5215
+
5204
5216
scopeindex_t *depth_index{};
5205
5217
};
5206
5218
0 commit comments