mirror of
https://github.com/simdjson/simdjson
synced 2026-06-08 17:27:07 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 235dbc5369 | |||
| 2b9c8977af |
+1
-1
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.14)
|
||||
project(
|
||||
simdjson
|
||||
# The version number is modified by tools/release.py
|
||||
VERSION 4.2.0
|
||||
VERSION 4.2.1
|
||||
DESCRIPTION "Parsing gigabytes of JSON per second"
|
||||
HOMEPAGE_URL "https://simdjson.org/"
|
||||
LANGUAGES CXX C
|
||||
|
||||
@@ -38,7 +38,7 @@ PROJECT_NAME = simdjson
|
||||
# could be handy for archiving the generated documentation or if some version
|
||||
# control system is used.
|
||||
|
||||
PROJECT_NUMBER = "4.2.0"
|
||||
PROJECT_NUMBER = "4.2.1"
|
||||
|
||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||
# for a project that appears at the top of each page and should give viewer a
|
||||
|
||||
+3
-2
@@ -1,6 +1,7 @@
|
||||
The Basics
|
||||
==========
|
||||
|
||||
|
||||
An overview of what you need to know to use simdjson to parse JSON documents, with examples.
|
||||
[Our documentation regarding the generation (serialization) of JSON documents is in a
|
||||
separate document](https://github.com/simdjson/simdjson/blob/master/doc/builder.md).
|
||||
@@ -477,7 +478,7 @@ support for users who avoid exceptions. See [the simdjson error handling documen
|
||||
> unlike `key()`, it has to determine the location of the final quote character.
|
||||
>
|
||||
> ```cpp
|
||||
> auto json = R"({"k\u0065y": 1})"_padded;
|
||||
> auto json = R"({"k\u0065y": 1})"_padded; // R"( ... )" is a C++ raw string literal.
|
||||
> ondemand::parser parser;
|
||||
> auto doc = parser.iterate(json);
|
||||
> ondemand::object object = doc.get_object();
|
||||
@@ -502,7 +503,7 @@ support for users who avoid exceptions. See [the simdjson error handling documen
|
||||
>
|
||||
> ```cpp
|
||||
> ondemand::parser parser;
|
||||
> auto json = R"( { "x": 1, "y": 2 } )"_padded;
|
||||
> auto json = R"( { "x": 1, "y": 2 } )"_padded; // R"( ... )" is a C++ raw string literal.
|
||||
> auto doc = parser.iterate(json);
|
||||
> double y = doc.find_field("y"); // The cursor is now after the 2 (at })
|
||||
> double x = doc.find_field("x"); // This fails, because there are no more fields after "y"
|
||||
|
||||
+20
-5
@@ -53,15 +53,22 @@ Suppose you want to parse the following JSON document:
|
||||
}
|
||||
```
|
||||
|
||||
**Reminder**: In C++, `R"( )"` allows us to write multi-line strings with unescaped quotes.
|
||||
|
||||
|
||||
You can do so, at compile-time, as follows:
|
||||
|
||||
|
||||
```cpp
|
||||
constexpr auto cfg = simdjson::compile_time::parse_json<R"({
|
||||
constexpr auto cfg = R"(
|
||||
|
||||
{
|
||||
"port": 8080,
|
||||
"host": "localhost",
|
||||
"debug": true
|
||||
})">();
|
||||
}
|
||||
|
||||
)"_json;
|
||||
|
||||
// cfg.port == 8080
|
||||
// std::string_view(cfg.host) == "localhost"
|
||||
@@ -71,12 +78,16 @@ constexpr auto cfg = simdjson::compile_time::parse_json<R"({
|
||||
You can nest objects and arrays:
|
||||
|
||||
```cpp
|
||||
constexpr auto data = simdjson::compile_time::parse_json<R"({
|
||||
constexpr auto data = R"(
|
||||
|
||||
{
|
||||
"servers": [
|
||||
{"host": "s1", "port": 3000},
|
||||
{"host": "s2", "port": 3001}
|
||||
]
|
||||
})">();
|
||||
}
|
||||
|
||||
)"_json;
|
||||
|
||||
|
||||
// data.servers.size() == 2
|
||||
@@ -86,7 +97,11 @@ constexpr auto data = simdjson::compile_time::parse_json<R"({
|
||||
Top-level arrays are allowed:
|
||||
|
||||
```cpp
|
||||
constexpr auto arr = simdjson::compile_time::parse_json<R"([1, 2, 3])">();
|
||||
constexpr auto arr = R"(
|
||||
|
||||
[1, 2, 3]
|
||||
|
||||
)"_json;
|
||||
static_assert(arr.size() == 3);
|
||||
static_assert(arr[1] == 2);
|
||||
```
|
||||
|
||||
@@ -40,6 +40,7 @@ struct User {
|
||||
std::vector<std::string> emails;
|
||||
};
|
||||
|
||||
// R"( ... )" is a C++ raw string literal.
|
||||
const padded_string json = R"({
|
||||
"name": "Alice",
|
||||
"age": 30,
|
||||
|
||||
@@ -119,6 +119,7 @@ Once you have an element, you can navigate it with idiomatic C++ iterators, oper
|
||||
`dom::object` and `dom::array`) and pass it by reference to `get()` which gives you back an error code: e.g.,
|
||||
```cpp
|
||||
simdjson::error_code error;
|
||||
// _padded returns an simdjson::padded_string instance
|
||||
simdjson::padded_string numberstring = "1.2"_padded; // our JSON input ("1.2")
|
||||
simdjson::dom::parser parser;
|
||||
double value; // variable where we store the value to be parsed
|
||||
@@ -153,6 +154,7 @@ Once you have an element, you can navigate it with idiomatic C++ iterators, oper
|
||||
The following code illustrates all of the above:
|
||||
|
||||
```cpp
|
||||
// R"( ... )" is a C++ raw string literal.
|
||||
auto cars_json = R"( [
|
||||
{ "make": "Toyota", "model": "Camry", "year": 2018, "tire_pressure": [ 40.1, 39.9, 37.7, 40.4 ] },
|
||||
{ "make": "Kia", "model": "Soul", "year": 2012, "tire_pressure": [ 30.1, 31.0, 28.6, 28.7 ] },
|
||||
|
||||
@@ -141,7 +141,9 @@ API
|
||||
Example:
|
||||
|
||||
```cpp
|
||||
// R"( ... )" is a C++ raw string literal.
|
||||
auto json = R"({ "foo": 1 } { "foo": 2 } { "foo": 3 } )"_padded;
|
||||
// _padded returns an simdjson::padded_string instance
|
||||
ondemand::parser parser;
|
||||
ondemand::document_stream docs = parser.iterate_many(json);
|
||||
for (auto doc : docs) {
|
||||
|
||||
@@ -672,7 +672,9 @@ in production systems:
|
||||
|
||||
```cpp
|
||||
ondemand::parser parser;
|
||||
// R"( ... )" is a C++ raw string literal.
|
||||
const padded_string json = R"({ "parent": {"child1": {"name": "John"} , "child2": {"name": "Daniel"}} })"_padded;
|
||||
// _padded returns an simdjson padded_string instance
|
||||
auto doc = parser.iterate(json);
|
||||
ondemand::object parent = doc["parent"];
|
||||
// parent owns the focus
|
||||
|
||||
@@ -65,5 +65,11 @@ template <constevalutil::fixed_string json_str> consteval auto parse_json();
|
||||
} // namespace compile_time
|
||||
} // namespace simdjson
|
||||
|
||||
|
||||
template <simdjson::constevalutil::fixed_string str>
|
||||
consteval auto operator ""_json() {
|
||||
return simdjson::compile_time::parse_json<str>();
|
||||
}
|
||||
|
||||
#endif // SIMDJSON_STATIC_REFLECTION
|
||||
#endif // SIMDJSON_GENERIC_COMPILE_TIME_JSON_H
|
||||
|
||||
@@ -167,7 +167,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index]);
|
||||
#else
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index]);
|
||||
@@ -205,7 +205,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index + 1]);
|
||||
#else
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index + 1]);
|
||||
|
||||
@@ -53,7 +53,7 @@ extern SIMDJSON_DLLIMPORTEXPORT const double power_of_ten[];
|
||||
// The mantissa is truncated to 128 bits, and
|
||||
// never rounded up. Uses about 10KB.
|
||||
// We use the template trick to allow inclusion in multiple translation units.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
template <typename unused = void> struct powers_template {
|
||||
constexpr static uint64_t power_of_five_128[651*2]= {
|
||||
0xeef453d6923bd65a,0x113faa2906a13b3f,
|
||||
@@ -708,7 +708,7 @@ constexpr static uint64_t power_of_five_128[651*2]= {
|
||||
0xe3d8f9e563a198e5,0x58180fddd97723a6,
|
||||
0x8e679c2f5e44ff8f,0x570f09eaa7ea7648,};
|
||||
};
|
||||
#endif // SIMDJSON_CPLUSPLUS26
|
||||
#endif // SIMDJSON_STATIC_REFLECTION
|
||||
|
||||
extern SIMDJSON_DLLIMPORTEXPORT const uint64_t power_of_five_128[651*2];
|
||||
} // namespace internal
|
||||
|
||||
@@ -192,7 +192,7 @@ inline simdjson::padded_string operator ""_padded(const char *str, size_t len) {
|
||||
}
|
||||
#ifdef __cpp_char8_t
|
||||
inline simdjson::padded_string operator ""_padded(const char8_t *str, size_t len) {
|
||||
return simdjson::padded_string(reinterpret_cast<const char8_t *>(str), len);
|
||||
return simdjson::padded_string(reinterpret_cast<const char *>(str), len);
|
||||
}
|
||||
#endif
|
||||
#endif // SIMDJSON_PADDED_STRING_INL_H
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#define SIMDJSON_SIMDJSON_VERSION_H
|
||||
|
||||
/** The version of simdjson being used (major.minor.revision) */
|
||||
#define SIMDJSON_VERSION "4.2.0"
|
||||
#define SIMDJSON_VERSION "4.2.1"
|
||||
|
||||
namespace simdjson {
|
||||
enum {
|
||||
@@ -19,7 +19,7 @@ enum {
|
||||
/**
|
||||
* The revision (major.minor.REVISION) of simdjson being used.
|
||||
*/
|
||||
SIMDJSON_VERSION_REVISION = 0
|
||||
SIMDJSON_VERSION_REVISION = 1
|
||||
};
|
||||
} // namespace simdjson
|
||||
|
||||
|
||||
+19
-19
@@ -1,4 +1,4 @@
|
||||
/* auto-generated on 2025-11-02 11:53:56 -0500. version 4.2.0 Do not edit! */
|
||||
/* auto-generated on 2025-11-03 11:03:21 -0500. version 4.2.1 Do not edit! */
|
||||
/* including simdjson.cpp: */
|
||||
/* begin file simdjson.cpp */
|
||||
#define SIMDJSON_SRC_SIMDJSON_CPP
|
||||
@@ -5357,7 +5357,7 @@ extern SIMDJSON_DLLIMPORTEXPORT const double power_of_ten[];
|
||||
// The mantissa is truncated to 128 bits, and
|
||||
// never rounded up. Uses about 10KB.
|
||||
// We use the template trick to allow inclusion in multiple translation units.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
template <typename unused = void> struct powers_template {
|
||||
constexpr static uint64_t power_of_five_128[651*2]= {
|
||||
0xeef453d6923bd65a,0x113faa2906a13b3f,
|
||||
@@ -6012,7 +6012,7 @@ constexpr static uint64_t power_of_five_128[651*2]= {
|
||||
0xe3d8f9e563a198e5,0x58180fddd97723a6,
|
||||
0x8e679c2f5e44ff8f,0x570f09eaa7ea7648,};
|
||||
};
|
||||
#endif // SIMDJSON_CPLUSPLUS26
|
||||
#endif // SIMDJSON_STATIC_REFLECTION
|
||||
|
||||
extern SIMDJSON_DLLIMPORTEXPORT const uint64_t power_of_five_128[651*2];
|
||||
} // namespace internal
|
||||
@@ -10287,7 +10287,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index]);
|
||||
#else
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index]);
|
||||
@@ -10325,7 +10325,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index + 1]);
|
||||
#else
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index + 1]);
|
||||
@@ -16782,7 +16782,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index]);
|
||||
#else
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index]);
|
||||
@@ -16820,7 +16820,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index + 1]);
|
||||
#else
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index + 1]);
|
||||
@@ -23132,7 +23132,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index]);
|
||||
#else
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index]);
|
||||
@@ -23170,7 +23170,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index + 1]);
|
||||
#else
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index + 1]);
|
||||
@@ -29639,7 +29639,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index]);
|
||||
#else
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index]);
|
||||
@@ -29677,7 +29677,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index + 1]);
|
||||
#else
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index + 1]);
|
||||
@@ -36505,7 +36505,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index]);
|
||||
#else
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index]);
|
||||
@@ -36543,7 +36543,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index + 1]);
|
||||
#else
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index + 1]);
|
||||
@@ -43193,7 +43193,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index]);
|
||||
#else
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index]);
|
||||
@@ -43231,7 +43231,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index + 1]);
|
||||
#else
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index + 1]);
|
||||
@@ -49327,7 +49327,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index]);
|
||||
#else
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index]);
|
||||
@@ -49365,7 +49365,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index + 1]);
|
||||
#else
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index + 1]);
|
||||
@@ -55053,7 +55053,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index]);
|
||||
#else
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index]);
|
||||
@@ -55091,7 +55091,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index + 1]);
|
||||
#else
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index + 1]);
|
||||
|
||||
+28
-22
@@ -1,4 +1,4 @@
|
||||
/* auto-generated on 2025-11-02 11:53:56 -0500. version 4.2.0 Do not edit! */
|
||||
/* auto-generated on 2025-11-03 11:03:21 -0500. version 4.2.1 Do not edit! */
|
||||
/* including simdjson.h: */
|
||||
/* begin file simdjson.h */
|
||||
#ifndef SIMDJSON_H
|
||||
@@ -2513,7 +2513,7 @@ namespace std {
|
||||
#define SIMDJSON_SIMDJSON_VERSION_H
|
||||
|
||||
/** The version of simdjson being used (major.minor.revision) */
|
||||
#define SIMDJSON_VERSION "4.2.0"
|
||||
#define SIMDJSON_VERSION "4.2.1"
|
||||
|
||||
namespace simdjson {
|
||||
enum {
|
||||
@@ -2528,7 +2528,7 @@ enum {
|
||||
/**
|
||||
* The revision (major.minor.REVISION) of simdjson being used.
|
||||
*/
|
||||
SIMDJSON_VERSION_REVISION = 0
|
||||
SIMDJSON_VERSION_REVISION = 1
|
||||
};
|
||||
} // namespace simdjson
|
||||
|
||||
@@ -4660,7 +4660,7 @@ inline simdjson::padded_string operator ""_padded(const char *str, size_t len) {
|
||||
}
|
||||
#ifdef __cpp_char8_t
|
||||
inline simdjson::padded_string operator ""_padded(const char8_t *str, size_t len) {
|
||||
return simdjson::padded_string(reinterpret_cast<const char8_t *>(str), len);
|
||||
return simdjson::padded_string(reinterpret_cast<const char *>(str), len);
|
||||
}
|
||||
#endif
|
||||
#endif // SIMDJSON_PADDED_STRING_INL_H
|
||||
@@ -10615,7 +10615,7 @@ extern SIMDJSON_DLLIMPORTEXPORT const double power_of_ten[];
|
||||
// The mantissa is truncated to 128 bits, and
|
||||
// never rounded up. Uses about 10KB.
|
||||
// We use the template trick to allow inclusion in multiple translation units.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
template <typename unused = void> struct powers_template {
|
||||
constexpr static uint64_t power_of_five_128[651*2]= {
|
||||
0xeef453d6923bd65a,0x113faa2906a13b3f,
|
||||
@@ -11270,7 +11270,7 @@ constexpr static uint64_t power_of_five_128[651*2]= {
|
||||
0xe3d8f9e563a198e5,0x58180fddd97723a6,
|
||||
0x8e679c2f5e44ff8f,0x570f09eaa7ea7648,};
|
||||
};
|
||||
#endif // SIMDJSON_CPLUSPLUS26
|
||||
#endif // SIMDJSON_STATIC_REFLECTION
|
||||
|
||||
extern SIMDJSON_DLLIMPORTEXPORT const uint64_t power_of_five_128[651*2];
|
||||
} // namespace internal
|
||||
@@ -13178,7 +13178,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index]);
|
||||
#else
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index]);
|
||||
@@ -13216,7 +13216,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index + 1]);
|
||||
#else
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index + 1]);
|
||||
@@ -15373,7 +15373,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index]);
|
||||
#else
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index]);
|
||||
@@ -15411,7 +15411,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index + 1]);
|
||||
#else
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index + 1]);
|
||||
@@ -18067,7 +18067,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index]);
|
||||
#else
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index]);
|
||||
@@ -18105,7 +18105,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index + 1]);
|
||||
#else
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index + 1]);
|
||||
@@ -20761,7 +20761,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index]);
|
||||
#else
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index]);
|
||||
@@ -20799,7 +20799,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index + 1]);
|
||||
#else
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index + 1]);
|
||||
@@ -23570,7 +23570,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index]);
|
||||
#else
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index]);
|
||||
@@ -23608,7 +23608,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index + 1]);
|
||||
#else
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index + 1]);
|
||||
@@ -26695,7 +26695,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index]);
|
||||
#else
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index]);
|
||||
@@ -26733,7 +26733,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index + 1]);
|
||||
#else
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index + 1]);
|
||||
@@ -29297,7 +29297,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index]);
|
||||
#else
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index]);
|
||||
@@ -29335,7 +29335,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index + 1]);
|
||||
#else
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index + 1]);
|
||||
@@ -31912,7 +31912,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index]);
|
||||
#else
|
||||
simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index]);
|
||||
@@ -31950,7 +31950,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
|
||||
// with a returned value of type value128 with a "low component" corresponding to the
|
||||
// 64-bit least significant bits of the product and with a "high component" corresponding
|
||||
// to the 64-bit most significant bits of the product.
|
||||
#if SIMDJSON_CPLUSPLUS26
|
||||
#if SIMDJSON_STATIC_REFLECTION
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index + 1]);
|
||||
#else
|
||||
simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index + 1]);
|
||||
@@ -153374,6 +153374,12 @@ template <constevalutil::fixed_string json_str> consteval auto parse_json();
|
||||
} // namespace compile_time
|
||||
} // namespace simdjson
|
||||
|
||||
|
||||
template <simdjson::constevalutil::fixed_string str>
|
||||
consteval auto operator ""_json() {
|
||||
return simdjson::compile_time::parse_json<str>();
|
||||
}
|
||||
|
||||
#endif // SIMDJSON_STATIC_REFLECTION
|
||||
#endif // SIMDJSON_GENERIC_COMPILE_TIME_JSON_H
|
||||
/* end file simdjson/compile_time_json.h */
|
||||
|
||||
Binary file not shown.
@@ -8,8 +8,8 @@
|
||||
|
||||
#include <print>
|
||||
|
||||
using namespace simdjson;
|
||||
using namespace std::string_view_literals;
|
||||
using namespace simdjson;
|
||||
|
||||
namespace compile_time_json_tests {
|
||||
/**
|
||||
@@ -479,6 +479,124 @@ bool array_of_objects() {
|
||||
TEST_SUCCEED();
|
||||
}
|
||||
|
||||
|
||||
bool test_complex_mixed_str() {
|
||||
TEST_START();
|
||||
auto f= "fds"_padded;
|
||||
|
||||
constexpr auto config = R"(
|
||||
{
|
||||
"app": "myapp",
|
||||
"version": 1.0,
|
||||
"config": {
|
||||
"ports": [8080, 8081, 8082],
|
||||
"enabled": true
|
||||
},
|
||||
"servers": [
|
||||
{"host": "server1", "port": 3000},
|
||||
{"host": "server2", "port": 3001}
|
||||
]
|
||||
}
|
||||
|
||||
)"_json;
|
||||
|
||||
static_assert(std::string_view(config.app) == "myapp");
|
||||
static_assert(config.version == 1.0);
|
||||
static_assert(config.config.ports[0] == 8080);
|
||||
static_assert(config.config.enabled == true);
|
||||
static_assert(std::string_view(config.servers[0].host) == "server1");
|
||||
static_assert(config.servers[1].port == 3001);
|
||||
|
||||
ASSERT_EQUAL(std::string_view(config.app), "myapp"sv);
|
||||
ASSERT_EQUAL(config.config.ports[0], 8080);
|
||||
ASSERT_EQUAL(std::string_view(config.servers[0].host), "server1"sv);
|
||||
ASSERT_EQUAL(config.servers[1].port, 3001);
|
||||
|
||||
TEST_SUCCEED();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test: User config example - basic object with primitives
|
||||
*/
|
||||
bool test_user_config_example() {
|
||||
TEST_START();
|
||||
|
||||
constexpr auto cfg = R"(
|
||||
|
||||
{
|
||||
"port": 8080,
|
||||
"host": "localhost",
|
||||
"debug": true
|
||||
}
|
||||
|
||||
)"_json;
|
||||
|
||||
static_assert(cfg.port == 8080);
|
||||
static_assert(std::string_view(cfg.host) == "localhost");
|
||||
static_assert(cfg.debug == true);
|
||||
|
||||
ASSERT_EQUAL(cfg.port, 8080);
|
||||
ASSERT_EQUAL(std::string_view(cfg.host), "localhost"sv);
|
||||
ASSERT_TRUE(cfg.debug);
|
||||
|
||||
TEST_SUCCEED();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test: Nested objects and arrays example
|
||||
*/
|
||||
bool test_nested_servers_example() {
|
||||
TEST_START();
|
||||
|
||||
constexpr auto data = R"(
|
||||
|
||||
{
|
||||
"servers": [
|
||||
{"host": "s1", "port": 3000},
|
||||
{"host": "s2", "port": 3001}
|
||||
]
|
||||
}
|
||||
|
||||
)"_json;
|
||||
|
||||
static_assert(data.servers.size() == 2);
|
||||
static_assert(std::string_view(data.servers[0].host) == "s1");
|
||||
static_assert(data.servers[0].port == 3000);
|
||||
static_assert(std::string_view(data.servers[1].host) == "s2");
|
||||
static_assert(data.servers[1].port == 3001);
|
||||
|
||||
ASSERT_EQUAL(data.servers.size(), 2);
|
||||
ASSERT_EQUAL(std::string_view(data.servers[0].host), "s1"sv);
|
||||
ASSERT_EQUAL(data.servers[0].port, 3000);
|
||||
ASSERT_EQUAL(std::string_view(data.servers[1].host), "s2"sv);
|
||||
ASSERT_EQUAL(data.servers[1].port, 3001);
|
||||
|
||||
TEST_SUCCEED();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test: Top-level array example
|
||||
*/
|
||||
bool test_top_level_array_example() {
|
||||
TEST_START();
|
||||
|
||||
constexpr auto arr = R"(
|
||||
[1, 2, 3]
|
||||
)"_json;
|
||||
|
||||
static_assert(arr.size() == 3);
|
||||
static_assert(arr[0] == 1);
|
||||
static_assert(arr[1] == 2);
|
||||
static_assert(arr[2] == 3);
|
||||
|
||||
ASSERT_EQUAL(arr.size(), 3);
|
||||
ASSERT_EQUAL(arr[0], 1);
|
||||
ASSERT_EQUAL(arr[1], 2);
|
||||
ASSERT_EQUAL(arr[2], 3);
|
||||
|
||||
TEST_SUCCEED();
|
||||
}
|
||||
|
||||
bool run() {
|
||||
return test_basic_object() &&
|
||||
test_nested_objects() &&
|
||||
@@ -498,7 +616,11 @@ bool run() {
|
||||
test_simple_object_str_with_obj() &&
|
||||
test_empty_arrays() &&
|
||||
simple_array() &&
|
||||
array_of_objects();
|
||||
test_complex_mixed_str() &&
|
||||
array_of_objects() &&
|
||||
test_user_config_example() &&
|
||||
test_nested_servers_example() &&
|
||||
test_top_level_array_example();
|
||||
}
|
||||
|
||||
} // namespace compile_time_json_tests
|
||||
|
||||
Reference in New Issue
Block a user