mirror of
https://github.com/simdjson/simdjson
synced 2026-06-08 17:27:07 +00:00
Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 57699bfed8 | |||
| 648303b26a | |||
| 9008960e36 | |||
| 8a9e8a1792 | |||
| ba33e9e78f | |||
| d98b351eef | |||
| 5488dca126 | |||
| 7712ecf164 | |||
| 2803ca3093 | |||
| e7f2463920 | |||
| 5bfa0b098c | |||
| f7ba9cb11b | |||
| d4bf0cc7ec | |||
| 2fbbea0b15 | |||
| c16486f702 | |||
| f615112093 | |||
| 6bbcbfbb95 | |||
| e6578fea39 | |||
| 6fb050d04e |
@@ -1,9 +1,8 @@
|
||||
name: Doxygen GitHub Pages
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
release:
|
||||
types: [created]
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ jobs:
|
||||
implementations: haswell westmere fallback
|
||||
UBSAN_OPTIONS: halt_on_error=1
|
||||
MAXLEN: -max_len=4000
|
||||
CLANGVERSION: 15
|
||||
CLANGVERSION: 19
|
||||
# which optimization level to use for the sanitizer build (see build_fuzzer.variants.sh)
|
||||
OPTLEVEL: -O3
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ jobs:
|
||||
- msystem: "MINGW64"
|
||||
install: mingw-w64-x86_64-libxml2 mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-clang
|
||||
type: Debug
|
||||
- msystem: "MINGW64"
|
||||
- msystem: "MINGW64"
|
||||
install: mingw-w64-x86_64-libxml2 mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-clang
|
||||
type: RelWithDebInfo
|
||||
env:
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.14)
|
||||
project(
|
||||
simdjson
|
||||
# The version number is modified by tools/release.py
|
||||
VERSION 3.11.0
|
||||
VERSION 3.11.5
|
||||
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 = "3.11.0"
|
||||
PROJECT_NUMBER = "3.11.5"
|
||||
|
||||
# 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
|
||||
|
||||
+11
-6
@@ -48,7 +48,7 @@ Requirements
|
||||
------------------
|
||||
|
||||
- A recent compiler (LLVM clang 6 or better, GNU GCC 7.4 or better, Xcode 11 or better) on a 64-bit (PPC, ARM or x64 Intel/AMD) POSIX systems such as macOS, freeBSD or Linux. We require that the compiler supports the C++11 standard or better.
|
||||
- Visual Studio 2017 or better under 64-bit Windows. Users should target a 64-bit build (x64 or ARM64) instead of a 32-bit build (x86). We support the LLVM clang compiler under Visual Studio (clangcl) as well as as the regular Visual Studio compiler. We also support MinGW 64-bit under Windows.
|
||||
- Visual Studio 2017 or better under 64-bit Windows. Users should target a 64-bit build (x64 or ARM64) instead of a 32-bit build (x86). We support the LLVM clang compiler under Visual Studio (clang-cl) as well as as the regular Visual Studio compiler. For better release performance (both compile time and execution time), we recommend Visual Studio users adopt LLVM (clang-cl). We also support MinGW 64-bit under Windows.
|
||||
|
||||
|
||||
Support for AVX-512 require a processor with AVX512-VBMI2 support (Ice Lake or better, AMD Zen 4 or better) under a 64-bit system and a recent compiler (LLVM clang 6 or better, GCC 8 or better, Visual Studio 2019 or better). You need a correspondingly recent assembler such as gas (2.30+) or nasm (2.14+): recent compilers usually come with recent assemblers. If you mix a recent compiler with an incompatible/old assembler (e.g., when using a recent compiler with an old Linux distribution), you may get errors at build time because the compiler produces instructions that the assembler does not recognize: you should update your assembler to match your compiler (e.g., upgrade binutils to version 2.30 or better under Linux) or use an older compiler matching the capabilities of your assembler.
|
||||
@@ -422,9 +422,13 @@ support for users who avoid exceptions. See [the simdjson error handling documen
|
||||
of the object: to warn you, an OUT_OF_ORDER_ITERATION error is generated [when development checks](#avoiding-pitfalls-enable-development-checks) are active. If you need to access an object more
|
||||
than once, you may call `reset()` on it although we discourage this practice. Keep in mind that
|
||||
you should consume each value at most once.
|
||||
|
||||
When you are iterating through an object, you are advancing through its keys and values. You should not also access the object or other objects. E.g. within a loop over `myobject`, you should not be accessing `myobject`. The following is an anti-pattern: `for(auto value: myobject) {myobject["mykey"]}`.
|
||||
|
||||
You should never reset an object as you are iterating through it. The following is an anti-pattern: `for(auto value: myobject) {myobject.reset()}`.
|
||||
* **Array Index:** Because it is forward-only, you cannot look up an array element by index by index. Instead,
|
||||
you should iterate through the array and keep an index yourself. Exceptionally, if need a single value
|
||||
out of the array, you may use an array access (e.g., `array[1]`).
|
||||
out of the array, you may use an array access (e.g., `array[1]`). You should never reset an array as you are iterating through it. The following is an anti-pattern: `for(auto value: myarray) {myarray.reset()}`.
|
||||
* **Field Access:** To get the value of the "foo" field in an object, use `object["foo"]`. This will
|
||||
scan through the object looking for the field with the matching string, doing a character-by-character
|
||||
comparison. It may generate the error `simdjson::NO_SUCH_FIELD` if there is no such key in the object, it may throw an exception (see [Error handling](#error-handling)). For efficiency reason, you should avoid looking up the same field repeatedly: e.g., do
|
||||
@@ -557,7 +561,7 @@ support for users who avoid exceptions. See [the simdjson error handling documen
|
||||
For this purpose, `array` instances have a `count_elements` method. Users should be
|
||||
aware that the `count_elements` method can be costly since it requires scanning the
|
||||
whole array. You should only call `count_elements` as a last resort as it may
|
||||
require scanning the document twice or more. In the spirit of On-Demand, the `count_elements` function does not validate the values in the array. You may use it as follows if your document is itself an array:
|
||||
require scanning the document twice or more. You should never use the `count_elements` as part of an attempt to iterate through the array: use a `for` loop to iterate through arrays. In the spirit of On-Demand, the `count_elements` function does not validate the values in the array: they are validated when they are consumed. You may use it as follows if your document is itself an array:
|
||||
|
||||
```C++
|
||||
auto cars_json = R"( [ 40.1, 39.9, 37.7, 40.4 ] )"_padded;
|
||||
@@ -1625,7 +1629,7 @@ The following is a similar example where one wants to get the id of the first tw
|
||||
triggering exceptions. To do this, we use `["statuses"].at(0)["id"]`. We break that expression down:
|
||||
|
||||
- Get the list of tweets (the `"statuses"` key of the document) using `["statuses"]`). The result is expected to be an array.
|
||||
- Get the first tweet using `.at(0)`. The result is expected to be an object.
|
||||
- Get the first tweet using `.at(0)`. The result is expected to be an object. Observe that the `at` method can only be called once on an array (it cannot be used for iteration).
|
||||
- Get the id of the tweet using ["id"]. We expect the value to be a non-negative integer.
|
||||
|
||||
Observe how we use the `at` method when querying an index into an array, and not the bracket operator.
|
||||
@@ -1650,8 +1654,8 @@ int main(void) {
|
||||
}
|
||||
```
|
||||
|
||||
The `at` method can only be called once on an array. It cannot be used
|
||||
to iterate through the values of an array.
|
||||
*Important remark*: The `at` method can only be called once on an array. It cannot be used
|
||||
to iterate through the values of an array. We deliberately forbid this usage to avoid performance antipatterns. If you need to iterate through the values of an array, you should use a `for` loop.
|
||||
|
||||
### Error handling examples without exceptions
|
||||
|
||||
@@ -1970,6 +1974,7 @@ to the document `rewind()` method, except that it does not rewind the
|
||||
internal string buffer. Thus you should consume values only once
|
||||
even if you can iterate through the array or object more than once.
|
||||
If you unescape a string within an array more than once, you have unsafe code.
|
||||
You must not call `reset()` on an object or an array as you are iterating through it.
|
||||
|
||||
|
||||
Newline-Delimited JSON (ndjson) and JSON lines
|
||||
|
||||
@@ -102,7 +102,7 @@ or indexing (`object["key"]`). In some cases, the values are even deserialized d
|
||||
maps.
|
||||
|
||||
The DOM approach is conceptually simple and "programmer friendly". Using the
|
||||
DOM tree is often easy enough that many users use the DOM as-is instead of creating
|
||||
DOM tree is often easy enough that many users process the DOM as-is instead of creating
|
||||
their own custom data structures.
|
||||
|
||||
The DOM approach was the only way to parse JSON documents up to version 0.6 of the simdjson library.
|
||||
|
||||
+3
-1
@@ -158,7 +158,9 @@ On Intel and AMD Windows platforms, Microsoft Visual Studio enables programmers
|
||||
|
||||
When compiling with Visual Studio, we recommend the flags `/Ob2 /O2` or better. We do not recommend that you compile simdjson with architecture-specific flags such as `arch:AVX2`. The simdjson library automatically selects the best execution kernel at runtime.
|
||||
|
||||
Recent versions of Microsoft Visual Studio on Windows provides support for the LLVM Clang compiler. You only need to install the "Clang compiler" optional component (ClangCL). You may also get a copy of the 64-bit LLVM CLang compiler for [Windows directly from LLVM](https://releases.llvm.org/download.html). The simdjson library fully supports the LLVM Clang compiler under Windows. In fact, you may get better performance out of simdjson with the LLVM Clang compiler than with the regular Visual Studio compiler. Meanwhile the [LLVM CLang compiler is binary compatible with Visual Studio](https://clang.llvm.org/docs/MSVCCompatibility.html) which means that you can combine their binaries (executables and libraries).
|
||||
Recent versions of Microsoft Visual Studio on Windows provides support for the LLVM Clang compiler. You only need to install the "Clang compiler" optional component (clang-cl). You may also get a copy of the 64-bit LLVM CLang compiler for [Windows directly from LLVM](https://releases.llvm.org/download.html). The simdjson library fully supports the LLVM Clang compiler under Windows. In fact, you may get better performance out of simdjson with the LLVM Clang compiler than with the regular Visual Studio compiler. Meanwhile the [LLVM CLang compiler is binary compatible with Visual Studio](https://clang.llvm.org/docs/MSVCCompatibility.html) which means that you can combine their binaries (executables and libraries).
|
||||
|
||||
We recommend Visual Studio users prefer LLVM (clang-cl). It compiles to faster release binaries. Furthermore, it compilers faster in release mode.
|
||||
|
||||
Under Windows, we also support the GNU GCC compiler via MSYS2. The performance of 64-bit MSYS2 under Windows is excellent (on par with Linux).
|
||||
|
||||
|
||||
@@ -56,10 +56,22 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cpp_concepts
|
||||
#if defined(__apple_build_version__)
|
||||
#if __apple_build_version__ < 14000000
|
||||
#define SIMDJSON_CONCEPT_DISABLED 1 // apple-clang/13 doesn't support std::convertible_to
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__cpp_concepts) && !defined(SIMDJSON_CONCEPT_DISABLED)
|
||||
#if __cpp_concepts >= 201907L
|
||||
#include <utility>
|
||||
#define SIMDJSON_SUPPORTS_DESERIALIZATION 1
|
||||
#else // __cpp_concepts
|
||||
#else
|
||||
#define SIMDJSON_SUPPORTS_DESERIALIZATION 0
|
||||
#endif
|
||||
#else // defined(__cpp_concepts) && !defined(SIMDJSON_CONCEPT_DISABLED)
|
||||
#define SIMDJSON_SUPPORTS_DESERIALIZATION 0
|
||||
#endif // defined(__cpp_concepts) && !defined(SIMDJSON_CONCEPT_DISABLED)
|
||||
|
||||
#endif // SIMDJSON_COMPILER_CHECK_H
|
||||
|
||||
@@ -20,14 +20,14 @@ namespace details {
|
||||
}; \
|
||||
};
|
||||
|
||||
SIMDJSON_IMPL_CONCEPT(emplace_back, emplace_back);
|
||||
SIMDJSON_IMPL_CONCEPT(emplace, emplace);
|
||||
SIMDJSON_IMPL_CONCEPT(push_back, push_back);
|
||||
SIMDJSON_IMPL_CONCEPT(add, add);
|
||||
SIMDJSON_IMPL_CONCEPT(push, push);
|
||||
SIMDJSON_IMPL_CONCEPT(append, append);
|
||||
SIMDJSON_IMPL_CONCEPT(insert, insert);
|
||||
SIMDJSON_IMPL_CONCEPT(op_append, operator+=);
|
||||
SIMDJSON_IMPL_CONCEPT(emplace_back, emplace_back)
|
||||
SIMDJSON_IMPL_CONCEPT(emplace, emplace)
|
||||
SIMDJSON_IMPL_CONCEPT(push_back, push_back)
|
||||
SIMDJSON_IMPL_CONCEPT(add, add)
|
||||
SIMDJSON_IMPL_CONCEPT(push, push)
|
||||
SIMDJSON_IMPL_CONCEPT(append, append)
|
||||
SIMDJSON_IMPL_CONCEPT(insert, insert)
|
||||
SIMDJSON_IMPL_CONCEPT(op_append, operator+=)
|
||||
|
||||
#undef SIMDJSON_IMPL_CONCEPT
|
||||
} // namespace details
|
||||
|
||||
@@ -86,7 +86,7 @@ struct simdjson_error : public std::exception {
|
||||
*/
|
||||
simdjson_error(error_code error) noexcept : _error{error} { }
|
||||
/** The error message */
|
||||
const char *what() const noexcept { return error_message(error()); }
|
||||
const char *what() const noexcept override { return error_message(error()); }
|
||||
/** The error code */
|
||||
error_code error() const noexcept { return _error; }
|
||||
private:
|
||||
|
||||
@@ -246,7 +246,14 @@ simdjson_inline simdjson_result<value> document::operator[](const char *key) & n
|
||||
}
|
||||
|
||||
simdjson_inline error_code document::consume() noexcept {
|
||||
auto error = iter.skip_child(0);
|
||||
bool scalar = false;
|
||||
auto error = is_scalar().get(scalar);
|
||||
if(error) { return error; }
|
||||
if(scalar) {
|
||||
iter.return_current_and_advance();
|
||||
return SUCCESS;
|
||||
}
|
||||
error = iter.skip_child(0);
|
||||
if(error) { iter.abandon(); }
|
||||
return error;
|
||||
}
|
||||
@@ -268,6 +275,8 @@ simdjson_inline simdjson_result<json_type> document::type() noexcept {
|
||||
}
|
||||
|
||||
simdjson_inline simdjson_result<bool> document::is_scalar() noexcept {
|
||||
// For more speed, we could do:
|
||||
// return iter.is_single_token();
|
||||
json_type this_type;
|
||||
auto error = type().get(this_type);
|
||||
if(error) { return error; }
|
||||
|
||||
@@ -20,36 +20,39 @@ simdjson_inline const char * raw_json_string::raw() const noexcept { return rein
|
||||
|
||||
simdjson_inline bool raw_json_string::is_free_from_unescaped_quote(std::string_view target) noexcept {
|
||||
size_t pos{0};
|
||||
// if the content has no escape character, just scan through it quickly!
|
||||
for(;pos < target.size() && target[pos] != '\\';pos++) {}
|
||||
// slow path may begin.
|
||||
bool escaping{false};
|
||||
for(;pos < target.size();pos++) {
|
||||
if((target[pos] == '"') && !escaping) {
|
||||
return false;
|
||||
} else if(target[pos] == '\\') {
|
||||
escaping = !escaping;
|
||||
} else {
|
||||
escaping = false;
|
||||
while(pos < target.size()) {
|
||||
pos = target.find('"', pos);
|
||||
if(pos == std::string_view::npos) { return true; }
|
||||
if(pos != 0 && target[pos-1] != '\\') { return false; }
|
||||
if(pos > 1 && target[pos-2] == '\\') {
|
||||
size_t backslash_count{2};
|
||||
for(size_t i = 3; i <= pos; i++) {
|
||||
if(target[pos-i] == '\\') { backslash_count++; }
|
||||
else { break; }
|
||||
}
|
||||
if(backslash_count % 2 == 0) { return false; }
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
simdjson_inline bool raw_json_string::is_free_from_unescaped_quote(const char* target) noexcept {
|
||||
size_t pos{0};
|
||||
// if the content has no escape character, just scan through it quickly!
|
||||
for(;target[pos] && target[pos] != '\\';pos++) {}
|
||||
// slow path may begin.
|
||||
bool escaping{false};
|
||||
for(;target[pos];pos++) {
|
||||
if((target[pos] == '"') && !escaping) {
|
||||
return false;
|
||||
} else if(target[pos] == '\\') {
|
||||
escaping = !escaping;
|
||||
} else {
|
||||
escaping = false;
|
||||
while(target[pos]) {
|
||||
const char * result = strchr(target+pos, '"');
|
||||
if(result == nullptr) { return true; }
|
||||
pos = result - target;
|
||||
if(pos != 0 && target[pos-1] != '\\') { return false; }
|
||||
if(pos > 1 && target[pos-2] == '\\') {
|
||||
size_t backslash_count{2};
|
||||
for(size_t i = 3; i <= pos; i++) {
|
||||
if(target[pos-i] == '\\') { backslash_count++; }
|
||||
else { break; }
|
||||
}
|
||||
if(backslash_count % 2 == 0) { return false; }
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -61,7 +64,7 @@ simdjson_inline bool raw_json_string::unsafe_is_equal(size_t length, std::string
|
||||
}
|
||||
|
||||
simdjson_inline bool raw_json_string::unsafe_is_equal(std::string_view target) const noexcept {
|
||||
// Assumptions: does not contain unescaped quote characters, and
|
||||
// Assumptions: does not contain unescaped quote characters("), and
|
||||
// the raw content is quote terminated within a valid JSON string.
|
||||
if(target.size() <= SIMDJSON_PADDING) {
|
||||
return (raw()[target.size()] == '"') && !memcmp(raw(), target.data(), target.size());
|
||||
|
||||
@@ -187,11 +187,11 @@ inline simdjson_result<padded_string> padded_string::load(std::string_view filen
|
||||
|
||||
} // namespace simdjson
|
||||
|
||||
inline simdjson::padded_string operator "" _padded(const char *str, size_t len) {
|
||||
inline simdjson::padded_string operator ""_padded(const char *str, size_t len) {
|
||||
return simdjson::padded_string(str, len);
|
||||
}
|
||||
#ifdef __cpp_char8_t
|
||||
inline simdjson::padded_string operator "" _padded(const char8_t *str, size_t len) {
|
||||
inline simdjson::padded_string operator ""_padded(const char8_t *str, size_t len) {
|
||||
return simdjson::padded_string(reinterpret_cast<const char8_t *>(str), len);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -161,9 +161,9 @@ inline std::ostream& operator<<(std::ostream& out, simdjson_result<padded_string
|
||||
} // namespace simdjson
|
||||
|
||||
// This is deliberately outside of simdjson so that people get it without having to use the namespace
|
||||
inline simdjson::padded_string operator "" _padded(const char *str, size_t len);
|
||||
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);
|
||||
inline simdjson::padded_string operator ""_padded(const char8_t *str, size_t len);
|
||||
#endif
|
||||
|
||||
namespace simdjson {
|
||||
|
||||
@@ -6,11 +6,15 @@
|
||||
#include <cstdlib>
|
||||
#include <cfloat>
|
||||
#include <cassert>
|
||||
#include <climits>
|
||||
#ifndef _WIN32
|
||||
// strcasecmp, strncasecmp
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
static_assert(CHAR_BIT == 8, "simdjson requires 8-bit bytes");
|
||||
|
||||
|
||||
// We are using size_t without namespace std:: throughout the project
|
||||
using std::size_t;
|
||||
|
||||
@@ -44,6 +48,7 @@ using std::size_t;
|
||||
#elif defined(__loongarch_lp64)
|
||||
#define SIMDJSON_IS_LOONGARCH64 1
|
||||
#elif defined(__PPC64__) || defined(_M_PPC64)
|
||||
#define SIMDJSON_IS_PPC64 1
|
||||
#if defined(__ALTIVEC__)
|
||||
#define SIMDJSON_IS_PPC64_VMX 1
|
||||
#endif // defined(__ALTIVEC__)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#define SIMDJSON_SIMDJSON_VERSION_H
|
||||
|
||||
/** The version of simdjson being used (major.minor.revision) */
|
||||
#define SIMDJSON_VERSION "3.11.0"
|
||||
#define SIMDJSON_VERSION "3.11.5"
|
||||
|
||||
namespace simdjson {
|
||||
enum {
|
||||
@@ -19,7 +19,7 @@ enum {
|
||||
/**
|
||||
* The revision (major.minor.REVISION) of simdjson being used.
|
||||
*/
|
||||
SIMDJSON_VERSION_REVISION = 0
|
||||
SIMDJSON_VERSION_REVISION = 5
|
||||
};
|
||||
} // namespace simdjson
|
||||
|
||||
|
||||
+37
-12
@@ -1,4 +1,4 @@
|
||||
/* auto-generated on 2024-12-02 20:24:24 -0500. Do not edit! */
|
||||
/* auto-generated on 2025-01-08 21:29:11 -0500. Do not edit! */
|
||||
/* including simdjson.cpp: */
|
||||
/* begin file simdjson.cpp */
|
||||
#define SIMDJSON_SRC_SIMDJSON_CPP
|
||||
@@ -83,12 +83,24 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cpp_concepts
|
||||
#if defined(__apple_build_version__)
|
||||
#if __apple_build_version__ < 14000000
|
||||
#define SIMDJSON_CONCEPT_DISABLED 1 // apple-clang/13 doesn't support std::convertible_to
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__cpp_concepts) && !defined(SIMDJSON_CONCEPT_DISABLED)
|
||||
#if __cpp_concepts >= 201907L
|
||||
#include <utility>
|
||||
#define SIMDJSON_SUPPORTS_DESERIALIZATION 1
|
||||
#else // __cpp_concepts
|
||||
#else
|
||||
#define SIMDJSON_SUPPORTS_DESERIALIZATION 0
|
||||
#endif
|
||||
#else // defined(__cpp_concepts) && !defined(SIMDJSON_CONCEPT_DISABLED)
|
||||
#define SIMDJSON_SUPPORTS_DESERIALIZATION 0
|
||||
#endif // defined(__cpp_concepts) && !defined(SIMDJSON_CONCEPT_DISABLED)
|
||||
|
||||
#endif // SIMDJSON_COMPILER_CHECK_H
|
||||
/* end file simdjson/compiler_check.h */
|
||||
/* including simdjson/portability.h: #include "simdjson/portability.h" */
|
||||
@@ -101,11 +113,15 @@
|
||||
#include <cstdlib>
|
||||
#include <cfloat>
|
||||
#include <cassert>
|
||||
#include <climits>
|
||||
#ifndef _WIN32
|
||||
// strcasecmp, strncasecmp
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
static_assert(CHAR_BIT == 8, "simdjson requires 8-bit bytes");
|
||||
|
||||
|
||||
// We are using size_t without namespace std:: throughout the project
|
||||
using std::size_t;
|
||||
|
||||
@@ -139,6 +155,7 @@ using std::size_t;
|
||||
#elif defined(__loongarch_lp64)
|
||||
#define SIMDJSON_IS_LOONGARCH64 1
|
||||
#elif defined(__PPC64__) || defined(_M_PPC64)
|
||||
#define SIMDJSON_IS_PPC64 1
|
||||
#if defined(__ALTIVEC__)
|
||||
#define SIMDJSON_IS_PPC64_VMX 1
|
||||
#endif // defined(__ALTIVEC__)
|
||||
@@ -2480,7 +2497,7 @@ struct simdjson_error : public std::exception {
|
||||
*/
|
||||
simdjson_error(error_code error) noexcept : _error{error} { }
|
||||
/** The error message */
|
||||
const char *what() const noexcept { return error_message(error()); }
|
||||
const char *what() const noexcept override { return error_message(error()); }
|
||||
/** The error code */
|
||||
error_code error() const noexcept { return _error; }
|
||||
private:
|
||||
@@ -2736,14 +2753,14 @@ namespace details {
|
||||
}; \
|
||||
};
|
||||
|
||||
SIMDJSON_IMPL_CONCEPT(emplace_back, emplace_back);
|
||||
SIMDJSON_IMPL_CONCEPT(emplace, emplace);
|
||||
SIMDJSON_IMPL_CONCEPT(push_back, push_back);
|
||||
SIMDJSON_IMPL_CONCEPT(add, add);
|
||||
SIMDJSON_IMPL_CONCEPT(push, push);
|
||||
SIMDJSON_IMPL_CONCEPT(append, append);
|
||||
SIMDJSON_IMPL_CONCEPT(insert, insert);
|
||||
SIMDJSON_IMPL_CONCEPT(op_append, operator+=);
|
||||
SIMDJSON_IMPL_CONCEPT(emplace_back, emplace_back)
|
||||
SIMDJSON_IMPL_CONCEPT(emplace, emplace)
|
||||
SIMDJSON_IMPL_CONCEPT(push_back, push_back)
|
||||
SIMDJSON_IMPL_CONCEPT(add, add)
|
||||
SIMDJSON_IMPL_CONCEPT(push, push)
|
||||
SIMDJSON_IMPL_CONCEPT(append, append)
|
||||
SIMDJSON_IMPL_CONCEPT(insert, insert)
|
||||
SIMDJSON_IMPL_CONCEPT(op_append, operator+=)
|
||||
|
||||
#undef SIMDJSON_IMPL_CONCEPT
|
||||
} // namespace details
|
||||
@@ -14165,6 +14182,7 @@ simdjson_warn_unused error_code dom_parser_implementation::stage2_next(dom::docu
|
||||
return stage2::tape_builder::parse_document<true>(*this, _doc);
|
||||
}
|
||||
|
||||
SIMDJSON_NO_SANITIZE_MEMORY
|
||||
simdjson_warn_unused uint8_t *dom_parser_implementation::parse_string(const uint8_t *src, uint8_t *dst, bool allow_replacement) const noexcept {
|
||||
return arm64::stringparsing::parse_string(src, dst, allow_replacement);
|
||||
}
|
||||
@@ -20392,6 +20410,7 @@ simdjson_warn_unused error_code dom_parser_implementation::stage2_next(dom::docu
|
||||
return stage2::tape_builder::parse_document<true>(*this, _doc);
|
||||
}
|
||||
|
||||
SIMDJSON_NO_SANITIZE_MEMORY
|
||||
simdjson_warn_unused uint8_t *dom_parser_implementation::parse_string(const uint8_t *src, uint8_t *dst, bool replacement_char) const noexcept {
|
||||
return haswell::stringparsing::parse_string(src, dst, replacement_char);
|
||||
}
|
||||
@@ -26646,6 +26665,7 @@ simdjson_warn_unused error_code dom_parser_implementation::stage2_next(dom::docu
|
||||
return stage2::tape_builder::parse_document<true>(*this, _doc);
|
||||
}
|
||||
|
||||
SIMDJSON_NO_SANITIZE_MEMORY
|
||||
simdjson_warn_unused uint8_t *dom_parser_implementation::parse_string(const uint8_t *src, uint8_t *dst, bool replacement_char) const noexcept {
|
||||
return icelake::stringparsing::parse_string(src, dst, replacement_char);
|
||||
}
|
||||
@@ -33070,6 +33090,7 @@ simdjson_warn_unused error_code dom_parser_implementation::stage2_next(dom::docu
|
||||
return stage2::tape_builder::parse_document<true>(*this, _doc);
|
||||
}
|
||||
|
||||
SIMDJSON_NO_SANITIZE_MEMORY
|
||||
simdjson_warn_unused uint8_t *dom_parser_implementation::parse_string(const uint8_t *src, uint8_t *dst, bool replacement_char) const noexcept {
|
||||
return ppc64::stringparsing::parse_string(src, dst, replacement_char);
|
||||
}
|
||||
@@ -40158,6 +40179,7 @@ simdjson_warn_unused error_code dom_parser_implementation::stage2_next(dom::docu
|
||||
return stage2::tape_builder::parse_document<true>(*this, _doc);
|
||||
}
|
||||
|
||||
SIMDJSON_NO_SANITIZE_MEMORY
|
||||
simdjson_warn_unused uint8_t *dom_parser_implementation::parse_string(const uint8_t *src, uint8_t *dst, bool replacement_char) const noexcept {
|
||||
return westmere::stringparsing::parse_string(src, dst, replacement_char);
|
||||
}
|
||||
@@ -46155,6 +46177,7 @@ simdjson_warn_unused error_code dom_parser_implementation::stage2_next(dom::docu
|
||||
return stage2::tape_builder::parse_document<true>(*this, _doc);
|
||||
}
|
||||
|
||||
SIMDJSON_NO_SANITIZE_MEMORY
|
||||
simdjson_warn_unused uint8_t *dom_parser_implementation::parse_string(const uint8_t *src, uint8_t *dst, bool allow_replacement) const noexcept {
|
||||
return lsx::stringparsing::parse_string(src, dst, allow_replacement);
|
||||
}
|
||||
@@ -52177,6 +52200,7 @@ simdjson_warn_unused error_code dom_parser_implementation::stage2_next(dom::docu
|
||||
return stage2::tape_builder::parse_document<true>(*this, _doc);
|
||||
}
|
||||
|
||||
SIMDJSON_NO_SANITIZE_MEMORY
|
||||
simdjson_warn_unused uint8_t *dom_parser_implementation::parse_string(const uint8_t *src, uint8_t *dst, bool allow_replacement) const noexcept {
|
||||
return lasx::stringparsing::parse_string(src, dst, allow_replacement);
|
||||
}
|
||||
@@ -56150,6 +56174,7 @@ simdjson_warn_unused error_code dom_parser_implementation::stage2_next(dom::docu
|
||||
return stage2::tape_builder::parse_document<true>(*this, _doc);
|
||||
}
|
||||
|
||||
SIMDJSON_NO_SANITIZE_MEMORY
|
||||
simdjson_warn_unused uint8_t *dom_parser_implementation::parse_string(const uint8_t *src, uint8_t *dst, bool replacement_char) const noexcept {
|
||||
return fallback::stringparsing::parse_string(src, dst, replacement_char);
|
||||
}
|
||||
|
||||
+323
-210
@@ -1,4 +1,4 @@
|
||||
/* auto-generated on 2024-12-02 20:24:24 -0500. Do not edit! */
|
||||
/* auto-generated on 2025-01-08 21:29:11 -0500. Do not edit! */
|
||||
/* including simdjson.h: */
|
||||
/* begin file simdjson.h */
|
||||
#ifndef SIMDJSON_H
|
||||
@@ -103,12 +103,24 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cpp_concepts
|
||||
#if defined(__apple_build_version__)
|
||||
#if __apple_build_version__ < 14000000
|
||||
#define SIMDJSON_CONCEPT_DISABLED 1 // apple-clang/13 doesn't support std::convertible_to
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__cpp_concepts) && !defined(SIMDJSON_CONCEPT_DISABLED)
|
||||
#if __cpp_concepts >= 201907L
|
||||
#include <utility>
|
||||
#define SIMDJSON_SUPPORTS_DESERIALIZATION 1
|
||||
#else // __cpp_concepts
|
||||
#else
|
||||
#define SIMDJSON_SUPPORTS_DESERIALIZATION 0
|
||||
#endif
|
||||
#else // defined(__cpp_concepts) && !defined(SIMDJSON_CONCEPT_DISABLED)
|
||||
#define SIMDJSON_SUPPORTS_DESERIALIZATION 0
|
||||
#endif // defined(__cpp_concepts) && !defined(SIMDJSON_CONCEPT_DISABLED)
|
||||
|
||||
#endif // SIMDJSON_COMPILER_CHECK_H
|
||||
/* end file simdjson/compiler_check.h */
|
||||
/* including simdjson/portability.h: #include "simdjson/portability.h" */
|
||||
@@ -121,11 +133,15 @@
|
||||
#include <cstdlib>
|
||||
#include <cfloat>
|
||||
#include <cassert>
|
||||
#include <climits>
|
||||
#ifndef _WIN32
|
||||
// strcasecmp, strncasecmp
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
static_assert(CHAR_BIT == 8, "simdjson requires 8-bit bytes");
|
||||
|
||||
|
||||
// We are using size_t without namespace std:: throughout the project
|
||||
using std::size_t;
|
||||
|
||||
@@ -159,6 +175,7 @@ using std::size_t;
|
||||
#elif defined(__loongarch_lp64)
|
||||
#define SIMDJSON_IS_LOONGARCH64 1
|
||||
#elif defined(__PPC64__) || defined(_M_PPC64)
|
||||
#define SIMDJSON_IS_PPC64 1
|
||||
#if defined(__ALTIVEC__)
|
||||
#define SIMDJSON_IS_PPC64_VMX 1
|
||||
#endif // defined(__ALTIVEC__)
|
||||
@@ -2420,7 +2437,7 @@ namespace std {
|
||||
#define SIMDJSON_SIMDJSON_VERSION_H
|
||||
|
||||
/** The version of simdjson being used (major.minor.revision) */
|
||||
#define SIMDJSON_VERSION "3.11.0"
|
||||
#define SIMDJSON_VERSION "3.11.5"
|
||||
|
||||
namespace simdjson {
|
||||
enum {
|
||||
@@ -2435,7 +2452,7 @@ enum {
|
||||
/**
|
||||
* The revision (major.minor.REVISION) of simdjson being used.
|
||||
*/
|
||||
SIMDJSON_VERSION_REVISION = 0
|
||||
SIMDJSON_VERSION_REVISION = 5
|
||||
};
|
||||
} // namespace simdjson
|
||||
|
||||
@@ -2543,7 +2560,7 @@ struct simdjson_error : public std::exception {
|
||||
*/
|
||||
simdjson_error(error_code error) noexcept : _error{error} { }
|
||||
/** The error message */
|
||||
const char *what() const noexcept { return error_message(error()); }
|
||||
const char *what() const noexcept override { return error_message(error()); }
|
||||
/** The error code */
|
||||
error_code error() const noexcept { return _error; }
|
||||
private:
|
||||
@@ -2799,14 +2816,14 @@ namespace details {
|
||||
}; \
|
||||
};
|
||||
|
||||
SIMDJSON_IMPL_CONCEPT(emplace_back, emplace_back);
|
||||
SIMDJSON_IMPL_CONCEPT(emplace, emplace);
|
||||
SIMDJSON_IMPL_CONCEPT(push_back, push_back);
|
||||
SIMDJSON_IMPL_CONCEPT(add, add);
|
||||
SIMDJSON_IMPL_CONCEPT(push, push);
|
||||
SIMDJSON_IMPL_CONCEPT(append, append);
|
||||
SIMDJSON_IMPL_CONCEPT(insert, insert);
|
||||
SIMDJSON_IMPL_CONCEPT(op_append, operator+=);
|
||||
SIMDJSON_IMPL_CONCEPT(emplace_back, emplace_back)
|
||||
SIMDJSON_IMPL_CONCEPT(emplace, emplace)
|
||||
SIMDJSON_IMPL_CONCEPT(push_back, push_back)
|
||||
SIMDJSON_IMPL_CONCEPT(add, add)
|
||||
SIMDJSON_IMPL_CONCEPT(push, push)
|
||||
SIMDJSON_IMPL_CONCEPT(append, append)
|
||||
SIMDJSON_IMPL_CONCEPT(insert, insert)
|
||||
SIMDJSON_IMPL_CONCEPT(op_append, operator+=)
|
||||
|
||||
#undef SIMDJSON_IMPL_CONCEPT
|
||||
} // namespace details
|
||||
@@ -3821,9 +3838,9 @@ inline std::ostream& operator<<(std::ostream& out, simdjson_result<padded_string
|
||||
} // namespace simdjson
|
||||
|
||||
// This is deliberately outside of simdjson so that people get it without having to use the namespace
|
||||
inline simdjson::padded_string operator "" _padded(const char *str, size_t len);
|
||||
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);
|
||||
inline simdjson::padded_string operator ""_padded(const char8_t *str, size_t len);
|
||||
#endif
|
||||
|
||||
namespace simdjson {
|
||||
@@ -4225,11 +4242,11 @@ inline simdjson_result<padded_string> padded_string::load(std::string_view filen
|
||||
|
||||
} // namespace simdjson
|
||||
|
||||
inline simdjson::padded_string operator "" _padded(const char *str, size_t len) {
|
||||
inline simdjson::padded_string operator ""_padded(const char *str, size_t len) {
|
||||
return simdjson::padded_string(str, len);
|
||||
}
|
||||
#ifdef __cpp_char8_t
|
||||
inline simdjson::padded_string operator "" _padded(const char8_t *str, size_t len) {
|
||||
inline simdjson::padded_string operator ""_padded(const char8_t *str, size_t len) {
|
||||
return simdjson::padded_string(reinterpret_cast<const char8_t *>(str), len);
|
||||
}
|
||||
#endif
|
||||
@@ -38216,7 +38233,14 @@ simdjson_inline simdjson_result<value> document::operator[](const char *key) & n
|
||||
}
|
||||
|
||||
simdjson_inline error_code document::consume() noexcept {
|
||||
auto error = iter.skip_child(0);
|
||||
bool scalar = false;
|
||||
auto error = is_scalar().get(scalar);
|
||||
if(error) { return error; }
|
||||
if(scalar) {
|
||||
iter.return_current_and_advance();
|
||||
return SUCCESS;
|
||||
}
|
||||
error = iter.skip_child(0);
|
||||
if(error) { iter.abandon(); }
|
||||
return error;
|
||||
}
|
||||
@@ -38238,6 +38262,8 @@ simdjson_inline simdjson_result<json_type> document::type() noexcept {
|
||||
}
|
||||
|
||||
simdjson_inline simdjson_result<bool> document::is_scalar() noexcept {
|
||||
// For more speed, we could do:
|
||||
// return iter.is_single_token();
|
||||
json_type this_type;
|
||||
auto error = type().get(this_type);
|
||||
if(error) { return error; }
|
||||
@@ -40939,36 +40965,39 @@ simdjson_inline const char * raw_json_string::raw() const noexcept { return rein
|
||||
|
||||
simdjson_inline bool raw_json_string::is_free_from_unescaped_quote(std::string_view target) noexcept {
|
||||
size_t pos{0};
|
||||
// if the content has no escape character, just scan through it quickly!
|
||||
for(;pos < target.size() && target[pos] != '\\';pos++) {}
|
||||
// slow path may begin.
|
||||
bool escaping{false};
|
||||
for(;pos < target.size();pos++) {
|
||||
if((target[pos] == '"') && !escaping) {
|
||||
return false;
|
||||
} else if(target[pos] == '\\') {
|
||||
escaping = !escaping;
|
||||
} else {
|
||||
escaping = false;
|
||||
while(pos < target.size()) {
|
||||
pos = target.find('"', pos);
|
||||
if(pos == std::string_view::npos) { return true; }
|
||||
if(pos != 0 && target[pos-1] != '\\') { return false; }
|
||||
if(pos > 1 && target[pos-2] == '\\') {
|
||||
size_t backslash_count{2};
|
||||
for(size_t i = 3; i <= pos; i++) {
|
||||
if(target[pos-i] == '\\') { backslash_count++; }
|
||||
else { break; }
|
||||
}
|
||||
if(backslash_count % 2 == 0) { return false; }
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
simdjson_inline bool raw_json_string::is_free_from_unescaped_quote(const char* target) noexcept {
|
||||
size_t pos{0};
|
||||
// if the content has no escape character, just scan through it quickly!
|
||||
for(;target[pos] && target[pos] != '\\';pos++) {}
|
||||
// slow path may begin.
|
||||
bool escaping{false};
|
||||
for(;target[pos];pos++) {
|
||||
if((target[pos] == '"') && !escaping) {
|
||||
return false;
|
||||
} else if(target[pos] == '\\') {
|
||||
escaping = !escaping;
|
||||
} else {
|
||||
escaping = false;
|
||||
while(target[pos]) {
|
||||
const char * result = strchr(target+pos, '"');
|
||||
if(result == nullptr) { return true; }
|
||||
pos = result - target;
|
||||
if(pos != 0 && target[pos-1] != '\\') { return false; }
|
||||
if(pos > 1 && target[pos-2] == '\\') {
|
||||
size_t backslash_count{2};
|
||||
for(size_t i = 3; i <= pos; i++) {
|
||||
if(target[pos-i] == '\\') { backslash_count++; }
|
||||
else { break; }
|
||||
}
|
||||
if(backslash_count % 2 == 0) { return false; }
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -40980,7 +41009,7 @@ simdjson_inline bool raw_json_string::unsafe_is_equal(size_t length, std::string
|
||||
}
|
||||
|
||||
simdjson_inline bool raw_json_string::unsafe_is_equal(std::string_view target) const noexcept {
|
||||
// Assumptions: does not contain unescaped quote characters, and
|
||||
// Assumptions: does not contain unescaped quote characters("), and
|
||||
// the raw content is quote terminated within a valid JSON string.
|
||||
if(target.size() <= SIMDJSON_PADDING) {
|
||||
return (raw()[target.size()] == '"') && !memcmp(raw(), target.data(), target.size());
|
||||
@@ -49180,7 +49209,14 @@ simdjson_inline simdjson_result<value> document::operator[](const char *key) & n
|
||||
}
|
||||
|
||||
simdjson_inline error_code document::consume() noexcept {
|
||||
auto error = iter.skip_child(0);
|
||||
bool scalar = false;
|
||||
auto error = is_scalar().get(scalar);
|
||||
if(error) { return error; }
|
||||
if(scalar) {
|
||||
iter.return_current_and_advance();
|
||||
return SUCCESS;
|
||||
}
|
||||
error = iter.skip_child(0);
|
||||
if(error) { iter.abandon(); }
|
||||
return error;
|
||||
}
|
||||
@@ -49202,6 +49238,8 @@ simdjson_inline simdjson_result<json_type> document::type() noexcept {
|
||||
}
|
||||
|
||||
simdjson_inline simdjson_result<bool> document::is_scalar() noexcept {
|
||||
// For more speed, we could do:
|
||||
// return iter.is_single_token();
|
||||
json_type this_type;
|
||||
auto error = type().get(this_type);
|
||||
if(error) { return error; }
|
||||
@@ -51903,36 +51941,39 @@ simdjson_inline const char * raw_json_string::raw() const noexcept { return rein
|
||||
|
||||
simdjson_inline bool raw_json_string::is_free_from_unescaped_quote(std::string_view target) noexcept {
|
||||
size_t pos{0};
|
||||
// if the content has no escape character, just scan through it quickly!
|
||||
for(;pos < target.size() && target[pos] != '\\';pos++) {}
|
||||
// slow path may begin.
|
||||
bool escaping{false};
|
||||
for(;pos < target.size();pos++) {
|
||||
if((target[pos] == '"') && !escaping) {
|
||||
return false;
|
||||
} else if(target[pos] == '\\') {
|
||||
escaping = !escaping;
|
||||
} else {
|
||||
escaping = false;
|
||||
while(pos < target.size()) {
|
||||
pos = target.find('"', pos);
|
||||
if(pos == std::string_view::npos) { return true; }
|
||||
if(pos != 0 && target[pos-1] != '\\') { return false; }
|
||||
if(pos > 1 && target[pos-2] == '\\') {
|
||||
size_t backslash_count{2};
|
||||
for(size_t i = 3; i <= pos; i++) {
|
||||
if(target[pos-i] == '\\') { backslash_count++; }
|
||||
else { break; }
|
||||
}
|
||||
if(backslash_count % 2 == 0) { return false; }
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
simdjson_inline bool raw_json_string::is_free_from_unescaped_quote(const char* target) noexcept {
|
||||
size_t pos{0};
|
||||
// if the content has no escape character, just scan through it quickly!
|
||||
for(;target[pos] && target[pos] != '\\';pos++) {}
|
||||
// slow path may begin.
|
||||
bool escaping{false};
|
||||
for(;target[pos];pos++) {
|
||||
if((target[pos] == '"') && !escaping) {
|
||||
return false;
|
||||
} else if(target[pos] == '\\') {
|
||||
escaping = !escaping;
|
||||
} else {
|
||||
escaping = false;
|
||||
while(target[pos]) {
|
||||
const char * result = strchr(target+pos, '"');
|
||||
if(result == nullptr) { return true; }
|
||||
pos = result - target;
|
||||
if(pos != 0 && target[pos-1] != '\\') { return false; }
|
||||
if(pos > 1 && target[pos-2] == '\\') {
|
||||
size_t backslash_count{2};
|
||||
for(size_t i = 3; i <= pos; i++) {
|
||||
if(target[pos-i] == '\\') { backslash_count++; }
|
||||
else { break; }
|
||||
}
|
||||
if(backslash_count % 2 == 0) { return false; }
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -51944,7 +51985,7 @@ simdjson_inline bool raw_json_string::unsafe_is_equal(size_t length, std::string
|
||||
}
|
||||
|
||||
simdjson_inline bool raw_json_string::unsafe_is_equal(std::string_view target) const noexcept {
|
||||
// Assumptions: does not contain unescaped quote characters, and
|
||||
// Assumptions: does not contain unescaped quote characters("), and
|
||||
// the raw content is quote terminated within a valid JSON string.
|
||||
if(target.size() <= SIMDJSON_PADDING) {
|
||||
return (raw()[target.size()] == '"') && !memcmp(raw(), target.data(), target.size());
|
||||
@@ -60636,7 +60677,14 @@ simdjson_inline simdjson_result<value> document::operator[](const char *key) & n
|
||||
}
|
||||
|
||||
simdjson_inline error_code document::consume() noexcept {
|
||||
auto error = iter.skip_child(0);
|
||||
bool scalar = false;
|
||||
auto error = is_scalar().get(scalar);
|
||||
if(error) { return error; }
|
||||
if(scalar) {
|
||||
iter.return_current_and_advance();
|
||||
return SUCCESS;
|
||||
}
|
||||
error = iter.skip_child(0);
|
||||
if(error) { iter.abandon(); }
|
||||
return error;
|
||||
}
|
||||
@@ -60658,6 +60706,8 @@ simdjson_inline simdjson_result<json_type> document::type() noexcept {
|
||||
}
|
||||
|
||||
simdjson_inline simdjson_result<bool> document::is_scalar() noexcept {
|
||||
// For more speed, we could do:
|
||||
// return iter.is_single_token();
|
||||
json_type this_type;
|
||||
auto error = type().get(this_type);
|
||||
if(error) { return error; }
|
||||
@@ -63359,36 +63409,39 @@ simdjson_inline const char * raw_json_string::raw() const noexcept { return rein
|
||||
|
||||
simdjson_inline bool raw_json_string::is_free_from_unescaped_quote(std::string_view target) noexcept {
|
||||
size_t pos{0};
|
||||
// if the content has no escape character, just scan through it quickly!
|
||||
for(;pos < target.size() && target[pos] != '\\';pos++) {}
|
||||
// slow path may begin.
|
||||
bool escaping{false};
|
||||
for(;pos < target.size();pos++) {
|
||||
if((target[pos] == '"') && !escaping) {
|
||||
return false;
|
||||
} else if(target[pos] == '\\') {
|
||||
escaping = !escaping;
|
||||
} else {
|
||||
escaping = false;
|
||||
while(pos < target.size()) {
|
||||
pos = target.find('"', pos);
|
||||
if(pos == std::string_view::npos) { return true; }
|
||||
if(pos != 0 && target[pos-1] != '\\') { return false; }
|
||||
if(pos > 1 && target[pos-2] == '\\') {
|
||||
size_t backslash_count{2};
|
||||
for(size_t i = 3; i <= pos; i++) {
|
||||
if(target[pos-i] == '\\') { backslash_count++; }
|
||||
else { break; }
|
||||
}
|
||||
if(backslash_count % 2 == 0) { return false; }
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
simdjson_inline bool raw_json_string::is_free_from_unescaped_quote(const char* target) noexcept {
|
||||
size_t pos{0};
|
||||
// if the content has no escape character, just scan through it quickly!
|
||||
for(;target[pos] && target[pos] != '\\';pos++) {}
|
||||
// slow path may begin.
|
||||
bool escaping{false};
|
||||
for(;target[pos];pos++) {
|
||||
if((target[pos] == '"') && !escaping) {
|
||||
return false;
|
||||
} else if(target[pos] == '\\') {
|
||||
escaping = !escaping;
|
||||
} else {
|
||||
escaping = false;
|
||||
while(target[pos]) {
|
||||
const char * result = strchr(target+pos, '"');
|
||||
if(result == nullptr) { return true; }
|
||||
pos = result - target;
|
||||
if(pos != 0 && target[pos-1] != '\\') { return false; }
|
||||
if(pos > 1 && target[pos-2] == '\\') {
|
||||
size_t backslash_count{2};
|
||||
for(size_t i = 3; i <= pos; i++) {
|
||||
if(target[pos-i] == '\\') { backslash_count++; }
|
||||
else { break; }
|
||||
}
|
||||
if(backslash_count % 2 == 0) { return false; }
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -63400,7 +63453,7 @@ simdjson_inline bool raw_json_string::unsafe_is_equal(size_t length, std::string
|
||||
}
|
||||
|
||||
simdjson_inline bool raw_json_string::unsafe_is_equal(std::string_view target) const noexcept {
|
||||
// Assumptions: does not contain unescaped quote characters, and
|
||||
// Assumptions: does not contain unescaped quote characters("), and
|
||||
// the raw content is quote terminated within a valid JSON string.
|
||||
if(target.size() <= SIMDJSON_PADDING) {
|
||||
return (raw()[target.size()] == '"') && !memcmp(raw(), target.data(), target.size());
|
||||
@@ -72085,7 +72138,14 @@ simdjson_inline simdjson_result<value> document::operator[](const char *key) & n
|
||||
}
|
||||
|
||||
simdjson_inline error_code document::consume() noexcept {
|
||||
auto error = iter.skip_child(0);
|
||||
bool scalar = false;
|
||||
auto error = is_scalar().get(scalar);
|
||||
if(error) { return error; }
|
||||
if(scalar) {
|
||||
iter.return_current_and_advance();
|
||||
return SUCCESS;
|
||||
}
|
||||
error = iter.skip_child(0);
|
||||
if(error) { iter.abandon(); }
|
||||
return error;
|
||||
}
|
||||
@@ -72107,6 +72167,8 @@ simdjson_inline simdjson_result<json_type> document::type() noexcept {
|
||||
}
|
||||
|
||||
simdjson_inline simdjson_result<bool> document::is_scalar() noexcept {
|
||||
// For more speed, we could do:
|
||||
// return iter.is_single_token();
|
||||
json_type this_type;
|
||||
auto error = type().get(this_type);
|
||||
if(error) { return error; }
|
||||
@@ -74808,36 +74870,39 @@ simdjson_inline const char * raw_json_string::raw() const noexcept { return rein
|
||||
|
||||
simdjson_inline bool raw_json_string::is_free_from_unescaped_quote(std::string_view target) noexcept {
|
||||
size_t pos{0};
|
||||
// if the content has no escape character, just scan through it quickly!
|
||||
for(;pos < target.size() && target[pos] != '\\';pos++) {}
|
||||
// slow path may begin.
|
||||
bool escaping{false};
|
||||
for(;pos < target.size();pos++) {
|
||||
if((target[pos] == '"') && !escaping) {
|
||||
return false;
|
||||
} else if(target[pos] == '\\') {
|
||||
escaping = !escaping;
|
||||
} else {
|
||||
escaping = false;
|
||||
while(pos < target.size()) {
|
||||
pos = target.find('"', pos);
|
||||
if(pos == std::string_view::npos) { return true; }
|
||||
if(pos != 0 && target[pos-1] != '\\') { return false; }
|
||||
if(pos > 1 && target[pos-2] == '\\') {
|
||||
size_t backslash_count{2};
|
||||
for(size_t i = 3; i <= pos; i++) {
|
||||
if(target[pos-i] == '\\') { backslash_count++; }
|
||||
else { break; }
|
||||
}
|
||||
if(backslash_count % 2 == 0) { return false; }
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
simdjson_inline bool raw_json_string::is_free_from_unescaped_quote(const char* target) noexcept {
|
||||
size_t pos{0};
|
||||
// if the content has no escape character, just scan through it quickly!
|
||||
for(;target[pos] && target[pos] != '\\';pos++) {}
|
||||
// slow path may begin.
|
||||
bool escaping{false};
|
||||
for(;target[pos];pos++) {
|
||||
if((target[pos] == '"') && !escaping) {
|
||||
return false;
|
||||
} else if(target[pos] == '\\') {
|
||||
escaping = !escaping;
|
||||
} else {
|
||||
escaping = false;
|
||||
while(target[pos]) {
|
||||
const char * result = strchr(target+pos, '"');
|
||||
if(result == nullptr) { return true; }
|
||||
pos = result - target;
|
||||
if(pos != 0 && target[pos-1] != '\\') { return false; }
|
||||
if(pos > 1 && target[pos-2] == '\\') {
|
||||
size_t backslash_count{2};
|
||||
for(size_t i = 3; i <= pos; i++) {
|
||||
if(target[pos-i] == '\\') { backslash_count++; }
|
||||
else { break; }
|
||||
}
|
||||
if(backslash_count % 2 == 0) { return false; }
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -74849,7 +74914,7 @@ simdjson_inline bool raw_json_string::unsafe_is_equal(size_t length, std::string
|
||||
}
|
||||
|
||||
simdjson_inline bool raw_json_string::unsafe_is_equal(std::string_view target) const noexcept {
|
||||
// Assumptions: does not contain unescaped quote characters, and
|
||||
// Assumptions: does not contain unescaped quote characters("), and
|
||||
// the raw content is quote terminated within a valid JSON string.
|
||||
if(target.size() <= SIMDJSON_PADDING) {
|
||||
return (raw()[target.size()] == '"') && !memcmp(raw(), target.data(), target.size());
|
||||
@@ -83655,7 +83720,14 @@ simdjson_inline simdjson_result<value> document::operator[](const char *key) & n
|
||||
}
|
||||
|
||||
simdjson_inline error_code document::consume() noexcept {
|
||||
auto error = iter.skip_child(0);
|
||||
bool scalar = false;
|
||||
auto error = is_scalar().get(scalar);
|
||||
if(error) { return error; }
|
||||
if(scalar) {
|
||||
iter.return_current_and_advance();
|
||||
return SUCCESS;
|
||||
}
|
||||
error = iter.skip_child(0);
|
||||
if(error) { iter.abandon(); }
|
||||
return error;
|
||||
}
|
||||
@@ -83677,6 +83749,8 @@ simdjson_inline simdjson_result<json_type> document::type() noexcept {
|
||||
}
|
||||
|
||||
simdjson_inline simdjson_result<bool> document::is_scalar() noexcept {
|
||||
// For more speed, we could do:
|
||||
// return iter.is_single_token();
|
||||
json_type this_type;
|
||||
auto error = type().get(this_type);
|
||||
if(error) { return error; }
|
||||
@@ -86378,36 +86452,39 @@ simdjson_inline const char * raw_json_string::raw() const noexcept { return rein
|
||||
|
||||
simdjson_inline bool raw_json_string::is_free_from_unescaped_quote(std::string_view target) noexcept {
|
||||
size_t pos{0};
|
||||
// if the content has no escape character, just scan through it quickly!
|
||||
for(;pos < target.size() && target[pos] != '\\';pos++) {}
|
||||
// slow path may begin.
|
||||
bool escaping{false};
|
||||
for(;pos < target.size();pos++) {
|
||||
if((target[pos] == '"') && !escaping) {
|
||||
return false;
|
||||
} else if(target[pos] == '\\') {
|
||||
escaping = !escaping;
|
||||
} else {
|
||||
escaping = false;
|
||||
while(pos < target.size()) {
|
||||
pos = target.find('"', pos);
|
||||
if(pos == std::string_view::npos) { return true; }
|
||||
if(pos != 0 && target[pos-1] != '\\') { return false; }
|
||||
if(pos > 1 && target[pos-2] == '\\') {
|
||||
size_t backslash_count{2};
|
||||
for(size_t i = 3; i <= pos; i++) {
|
||||
if(target[pos-i] == '\\') { backslash_count++; }
|
||||
else { break; }
|
||||
}
|
||||
if(backslash_count % 2 == 0) { return false; }
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
simdjson_inline bool raw_json_string::is_free_from_unescaped_quote(const char* target) noexcept {
|
||||
size_t pos{0};
|
||||
// if the content has no escape character, just scan through it quickly!
|
||||
for(;target[pos] && target[pos] != '\\';pos++) {}
|
||||
// slow path may begin.
|
||||
bool escaping{false};
|
||||
for(;target[pos];pos++) {
|
||||
if((target[pos] == '"') && !escaping) {
|
||||
return false;
|
||||
} else if(target[pos] == '\\') {
|
||||
escaping = !escaping;
|
||||
} else {
|
||||
escaping = false;
|
||||
while(target[pos]) {
|
||||
const char * result = strchr(target+pos, '"');
|
||||
if(result == nullptr) { return true; }
|
||||
pos = result - target;
|
||||
if(pos != 0 && target[pos-1] != '\\') { return false; }
|
||||
if(pos > 1 && target[pos-2] == '\\') {
|
||||
size_t backslash_count{2};
|
||||
for(size_t i = 3; i <= pos; i++) {
|
||||
if(target[pos-i] == '\\') { backslash_count++; }
|
||||
else { break; }
|
||||
}
|
||||
if(backslash_count % 2 == 0) { return false; }
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -86419,7 +86496,7 @@ simdjson_inline bool raw_json_string::unsafe_is_equal(size_t length, std::string
|
||||
}
|
||||
|
||||
simdjson_inline bool raw_json_string::unsafe_is_equal(std::string_view target) const noexcept {
|
||||
// Assumptions: does not contain unescaped quote characters, and
|
||||
// Assumptions: does not contain unescaped quote characters("), and
|
||||
// the raw content is quote terminated within a valid JSON string.
|
||||
if(target.size() <= SIMDJSON_PADDING) {
|
||||
return (raw()[target.size()] == '"') && !memcmp(raw(), target.data(), target.size());
|
||||
@@ -95542,7 +95619,14 @@ simdjson_inline simdjson_result<value> document::operator[](const char *key) & n
|
||||
}
|
||||
|
||||
simdjson_inline error_code document::consume() noexcept {
|
||||
auto error = iter.skip_child(0);
|
||||
bool scalar = false;
|
||||
auto error = is_scalar().get(scalar);
|
||||
if(error) { return error; }
|
||||
if(scalar) {
|
||||
iter.return_current_and_advance();
|
||||
return SUCCESS;
|
||||
}
|
||||
error = iter.skip_child(0);
|
||||
if(error) { iter.abandon(); }
|
||||
return error;
|
||||
}
|
||||
@@ -95564,6 +95648,8 @@ simdjson_inline simdjson_result<json_type> document::type() noexcept {
|
||||
}
|
||||
|
||||
simdjson_inline simdjson_result<bool> document::is_scalar() noexcept {
|
||||
// For more speed, we could do:
|
||||
// return iter.is_single_token();
|
||||
json_type this_type;
|
||||
auto error = type().get(this_type);
|
||||
if(error) { return error; }
|
||||
@@ -98265,36 +98351,39 @@ simdjson_inline const char * raw_json_string::raw() const noexcept { return rein
|
||||
|
||||
simdjson_inline bool raw_json_string::is_free_from_unescaped_quote(std::string_view target) noexcept {
|
||||
size_t pos{0};
|
||||
// if the content has no escape character, just scan through it quickly!
|
||||
for(;pos < target.size() && target[pos] != '\\';pos++) {}
|
||||
// slow path may begin.
|
||||
bool escaping{false};
|
||||
for(;pos < target.size();pos++) {
|
||||
if((target[pos] == '"') && !escaping) {
|
||||
return false;
|
||||
} else if(target[pos] == '\\') {
|
||||
escaping = !escaping;
|
||||
} else {
|
||||
escaping = false;
|
||||
while(pos < target.size()) {
|
||||
pos = target.find('"', pos);
|
||||
if(pos == std::string_view::npos) { return true; }
|
||||
if(pos != 0 && target[pos-1] != '\\') { return false; }
|
||||
if(pos > 1 && target[pos-2] == '\\') {
|
||||
size_t backslash_count{2};
|
||||
for(size_t i = 3; i <= pos; i++) {
|
||||
if(target[pos-i] == '\\') { backslash_count++; }
|
||||
else { break; }
|
||||
}
|
||||
if(backslash_count % 2 == 0) { return false; }
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
simdjson_inline bool raw_json_string::is_free_from_unescaped_quote(const char* target) noexcept {
|
||||
size_t pos{0};
|
||||
// if the content has no escape character, just scan through it quickly!
|
||||
for(;target[pos] && target[pos] != '\\';pos++) {}
|
||||
// slow path may begin.
|
||||
bool escaping{false};
|
||||
for(;target[pos];pos++) {
|
||||
if((target[pos] == '"') && !escaping) {
|
||||
return false;
|
||||
} else if(target[pos] == '\\') {
|
||||
escaping = !escaping;
|
||||
} else {
|
||||
escaping = false;
|
||||
while(target[pos]) {
|
||||
const char * result = strchr(target+pos, '"');
|
||||
if(result == nullptr) { return true; }
|
||||
pos = result - target;
|
||||
if(pos != 0 && target[pos-1] != '\\') { return false; }
|
||||
if(pos > 1 && target[pos-2] == '\\') {
|
||||
size_t backslash_count{2};
|
||||
for(size_t i = 3; i <= pos; i++) {
|
||||
if(target[pos-i] == '\\') { backslash_count++; }
|
||||
else { break; }
|
||||
}
|
||||
if(backslash_count % 2 == 0) { return false; }
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -98306,7 +98395,7 @@ simdjson_inline bool raw_json_string::unsafe_is_equal(size_t length, std::string
|
||||
}
|
||||
|
||||
simdjson_inline bool raw_json_string::unsafe_is_equal(std::string_view target) const noexcept {
|
||||
// Assumptions: does not contain unescaped quote characters, and
|
||||
// Assumptions: does not contain unescaped quote characters("), and
|
||||
// the raw content is quote terminated within a valid JSON string.
|
||||
if(target.size() <= SIMDJSON_PADDING) {
|
||||
return (raw()[target.size()] == '"') && !memcmp(raw(), target.data(), target.size());
|
||||
@@ -106906,7 +106995,14 @@ simdjson_inline simdjson_result<value> document::operator[](const char *key) & n
|
||||
}
|
||||
|
||||
simdjson_inline error_code document::consume() noexcept {
|
||||
auto error = iter.skip_child(0);
|
||||
bool scalar = false;
|
||||
auto error = is_scalar().get(scalar);
|
||||
if(error) { return error; }
|
||||
if(scalar) {
|
||||
iter.return_current_and_advance();
|
||||
return SUCCESS;
|
||||
}
|
||||
error = iter.skip_child(0);
|
||||
if(error) { iter.abandon(); }
|
||||
return error;
|
||||
}
|
||||
@@ -106928,6 +107024,8 @@ simdjson_inline simdjson_result<json_type> document::type() noexcept {
|
||||
}
|
||||
|
||||
simdjson_inline simdjson_result<bool> document::is_scalar() noexcept {
|
||||
// For more speed, we could do:
|
||||
// return iter.is_single_token();
|
||||
json_type this_type;
|
||||
auto error = type().get(this_type);
|
||||
if(error) { return error; }
|
||||
@@ -109629,36 +109727,39 @@ simdjson_inline const char * raw_json_string::raw() const noexcept { return rein
|
||||
|
||||
simdjson_inline bool raw_json_string::is_free_from_unescaped_quote(std::string_view target) noexcept {
|
||||
size_t pos{0};
|
||||
// if the content has no escape character, just scan through it quickly!
|
||||
for(;pos < target.size() && target[pos] != '\\';pos++) {}
|
||||
// slow path may begin.
|
||||
bool escaping{false};
|
||||
for(;pos < target.size();pos++) {
|
||||
if((target[pos] == '"') && !escaping) {
|
||||
return false;
|
||||
} else if(target[pos] == '\\') {
|
||||
escaping = !escaping;
|
||||
} else {
|
||||
escaping = false;
|
||||
while(pos < target.size()) {
|
||||
pos = target.find('"', pos);
|
||||
if(pos == std::string_view::npos) { return true; }
|
||||
if(pos != 0 && target[pos-1] != '\\') { return false; }
|
||||
if(pos > 1 && target[pos-2] == '\\') {
|
||||
size_t backslash_count{2};
|
||||
for(size_t i = 3; i <= pos; i++) {
|
||||
if(target[pos-i] == '\\') { backslash_count++; }
|
||||
else { break; }
|
||||
}
|
||||
if(backslash_count % 2 == 0) { return false; }
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
simdjson_inline bool raw_json_string::is_free_from_unescaped_quote(const char* target) noexcept {
|
||||
size_t pos{0};
|
||||
// if the content has no escape character, just scan through it quickly!
|
||||
for(;target[pos] && target[pos] != '\\';pos++) {}
|
||||
// slow path may begin.
|
||||
bool escaping{false};
|
||||
for(;target[pos];pos++) {
|
||||
if((target[pos] == '"') && !escaping) {
|
||||
return false;
|
||||
} else if(target[pos] == '\\') {
|
||||
escaping = !escaping;
|
||||
} else {
|
||||
escaping = false;
|
||||
while(target[pos]) {
|
||||
const char * result = strchr(target+pos, '"');
|
||||
if(result == nullptr) { return true; }
|
||||
pos = result - target;
|
||||
if(pos != 0 && target[pos-1] != '\\') { return false; }
|
||||
if(pos > 1 && target[pos-2] == '\\') {
|
||||
size_t backslash_count{2};
|
||||
for(size_t i = 3; i <= pos; i++) {
|
||||
if(target[pos-i] == '\\') { backslash_count++; }
|
||||
else { break; }
|
||||
}
|
||||
if(backslash_count % 2 == 0) { return false; }
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -109670,7 +109771,7 @@ simdjson_inline bool raw_json_string::unsafe_is_equal(size_t length, std::string
|
||||
}
|
||||
|
||||
simdjson_inline bool raw_json_string::unsafe_is_equal(std::string_view target) const noexcept {
|
||||
// Assumptions: does not contain unescaped quote characters, and
|
||||
// Assumptions: does not contain unescaped quote characters("), and
|
||||
// the raw content is quote terminated within a valid JSON string.
|
||||
if(target.size() <= SIMDJSON_PADDING) {
|
||||
return (raw()[target.size()] == '"') && !memcmp(raw(), target.data(), target.size());
|
||||
@@ -118283,7 +118384,14 @@ simdjson_inline simdjson_result<value> document::operator[](const char *key) & n
|
||||
}
|
||||
|
||||
simdjson_inline error_code document::consume() noexcept {
|
||||
auto error = iter.skip_child(0);
|
||||
bool scalar = false;
|
||||
auto error = is_scalar().get(scalar);
|
||||
if(error) { return error; }
|
||||
if(scalar) {
|
||||
iter.return_current_and_advance();
|
||||
return SUCCESS;
|
||||
}
|
||||
error = iter.skip_child(0);
|
||||
if(error) { iter.abandon(); }
|
||||
return error;
|
||||
}
|
||||
@@ -118305,6 +118413,8 @@ simdjson_inline simdjson_result<json_type> document::type() noexcept {
|
||||
}
|
||||
|
||||
simdjson_inline simdjson_result<bool> document::is_scalar() noexcept {
|
||||
// For more speed, we could do:
|
||||
// return iter.is_single_token();
|
||||
json_type this_type;
|
||||
auto error = type().get(this_type);
|
||||
if(error) { return error; }
|
||||
@@ -121006,36 +121116,39 @@ simdjson_inline const char * raw_json_string::raw() const noexcept { return rein
|
||||
|
||||
simdjson_inline bool raw_json_string::is_free_from_unescaped_quote(std::string_view target) noexcept {
|
||||
size_t pos{0};
|
||||
// if the content has no escape character, just scan through it quickly!
|
||||
for(;pos < target.size() && target[pos] != '\\';pos++) {}
|
||||
// slow path may begin.
|
||||
bool escaping{false};
|
||||
for(;pos < target.size();pos++) {
|
||||
if((target[pos] == '"') && !escaping) {
|
||||
return false;
|
||||
} else if(target[pos] == '\\') {
|
||||
escaping = !escaping;
|
||||
} else {
|
||||
escaping = false;
|
||||
while(pos < target.size()) {
|
||||
pos = target.find('"', pos);
|
||||
if(pos == std::string_view::npos) { return true; }
|
||||
if(pos != 0 && target[pos-1] != '\\') { return false; }
|
||||
if(pos > 1 && target[pos-2] == '\\') {
|
||||
size_t backslash_count{2};
|
||||
for(size_t i = 3; i <= pos; i++) {
|
||||
if(target[pos-i] == '\\') { backslash_count++; }
|
||||
else { break; }
|
||||
}
|
||||
if(backslash_count % 2 == 0) { return false; }
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
simdjson_inline bool raw_json_string::is_free_from_unescaped_quote(const char* target) noexcept {
|
||||
size_t pos{0};
|
||||
// if the content has no escape character, just scan through it quickly!
|
||||
for(;target[pos] && target[pos] != '\\';pos++) {}
|
||||
// slow path may begin.
|
||||
bool escaping{false};
|
||||
for(;target[pos];pos++) {
|
||||
if((target[pos] == '"') && !escaping) {
|
||||
return false;
|
||||
} else if(target[pos] == '\\') {
|
||||
escaping = !escaping;
|
||||
} else {
|
||||
escaping = false;
|
||||
while(target[pos]) {
|
||||
const char * result = strchr(target+pos, '"');
|
||||
if(result == nullptr) { return true; }
|
||||
pos = result - target;
|
||||
if(pos != 0 && target[pos-1] != '\\') { return false; }
|
||||
if(pos > 1 && target[pos-2] == '\\') {
|
||||
size_t backslash_count{2};
|
||||
for(size_t i = 3; i <= pos; i++) {
|
||||
if(target[pos-i] == '\\') { backslash_count++; }
|
||||
else { break; }
|
||||
}
|
||||
if(backslash_count % 2 == 0) { return false; }
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -121047,7 +121160,7 @@ simdjson_inline bool raw_json_string::unsafe_is_equal(size_t length, std::string
|
||||
}
|
||||
|
||||
simdjson_inline bool raw_json_string::unsafe_is_equal(std::string_view target) const noexcept {
|
||||
// Assumptions: does not contain unescaped quote characters, and
|
||||
// Assumptions: does not contain unescaped quote characters("), and
|
||||
// the raw content is quote terminated within a valid JSON string.
|
||||
if(target.size() <= SIMDJSON_PADDING) {
|
||||
return (raw()[target.size()] == '"') && !memcmp(raw(), target.data(), target.size());
|
||||
|
||||
@@ -150,6 +150,7 @@ simdjson_warn_unused error_code dom_parser_implementation::stage2_next(dom::docu
|
||||
return stage2::tape_builder::parse_document<true>(*this, _doc);
|
||||
}
|
||||
|
||||
SIMDJSON_NO_SANITIZE_MEMORY
|
||||
simdjson_warn_unused uint8_t *dom_parser_implementation::parse_string(const uint8_t *src, uint8_t *dst, bool allow_replacement) const noexcept {
|
||||
return arm64::stringparsing::parse_string(src, dst, allow_replacement);
|
||||
}
|
||||
|
||||
@@ -388,6 +388,7 @@ simdjson_warn_unused error_code dom_parser_implementation::stage2_next(dom::docu
|
||||
return stage2::tape_builder::parse_document<true>(*this, _doc);
|
||||
}
|
||||
|
||||
SIMDJSON_NO_SANITIZE_MEMORY
|
||||
simdjson_warn_unused uint8_t *dom_parser_implementation::parse_string(const uint8_t *src, uint8_t *dst, bool replacement_char) const noexcept {
|
||||
return fallback::stringparsing::parse_string(src, dst, replacement_char);
|
||||
}
|
||||
|
||||
@@ -147,6 +147,7 @@ simdjson_warn_unused error_code dom_parser_implementation::stage2_next(dom::docu
|
||||
return stage2::tape_builder::parse_document<true>(*this, _doc);
|
||||
}
|
||||
|
||||
SIMDJSON_NO_SANITIZE_MEMORY
|
||||
simdjson_warn_unused uint8_t *dom_parser_implementation::parse_string(const uint8_t *src, uint8_t *dst, bool replacement_char) const noexcept {
|
||||
return haswell::stringparsing::parse_string(src, dst, replacement_char);
|
||||
}
|
||||
|
||||
@@ -193,6 +193,7 @@ simdjson_warn_unused error_code dom_parser_implementation::stage2_next(dom::docu
|
||||
return stage2::tape_builder::parse_document<true>(*this, _doc);
|
||||
}
|
||||
|
||||
SIMDJSON_NO_SANITIZE_MEMORY
|
||||
simdjson_warn_unused uint8_t *dom_parser_implementation::parse_string(const uint8_t *src, uint8_t *dst, bool replacement_char) const noexcept {
|
||||
return icelake::stringparsing::parse_string(src, dst, replacement_char);
|
||||
}
|
||||
|
||||
@@ -110,6 +110,7 @@ simdjson_warn_unused error_code dom_parser_implementation::stage2_next(dom::docu
|
||||
return stage2::tape_builder::parse_document<true>(*this, _doc);
|
||||
}
|
||||
|
||||
SIMDJSON_NO_SANITIZE_MEMORY
|
||||
simdjson_warn_unused uint8_t *dom_parser_implementation::parse_string(const uint8_t *src, uint8_t *dst, bool allow_replacement) const noexcept {
|
||||
return lasx::stringparsing::parse_string(src, dst, allow_replacement);
|
||||
}
|
||||
|
||||
@@ -114,6 +114,7 @@ simdjson_warn_unused error_code dom_parser_implementation::stage2_next(dom::docu
|
||||
return stage2::tape_builder::parse_document<true>(*this, _doc);
|
||||
}
|
||||
|
||||
SIMDJSON_NO_SANITIZE_MEMORY
|
||||
simdjson_warn_unused uint8_t *dom_parser_implementation::parse_string(const uint8_t *src, uint8_t *dst, bool allow_replacement) const noexcept {
|
||||
return lsx::stringparsing::parse_string(src, dst, allow_replacement);
|
||||
}
|
||||
|
||||
@@ -120,6 +120,7 @@ simdjson_warn_unused error_code dom_parser_implementation::stage2_next(dom::docu
|
||||
return stage2::tape_builder::parse_document<true>(*this, _doc);
|
||||
}
|
||||
|
||||
SIMDJSON_NO_SANITIZE_MEMORY
|
||||
simdjson_warn_unused uint8_t *dom_parser_implementation::parse_string(const uint8_t *src, uint8_t *dst, bool replacement_char) const noexcept {
|
||||
return ppc64::stringparsing::parse_string(src, dst, replacement_char);
|
||||
}
|
||||
|
||||
@@ -152,6 +152,7 @@ simdjson_warn_unused error_code dom_parser_implementation::stage2_next(dom::docu
|
||||
return stage2::tape_builder::parse_document<true>(*this, _doc);
|
||||
}
|
||||
|
||||
SIMDJSON_NO_SANITIZE_MEMORY
|
||||
simdjson_warn_unused uint8_t *dom_parser_implementation::parse_string(const uint8_t *src, uint8_t *dst, bool replacement_char) const noexcept {
|
||||
return westmere::stringparsing::parse_string(src, dst, replacement_char);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,23 @@ using namespace simdjson;
|
||||
|
||||
namespace misc_tests {
|
||||
using namespace std;
|
||||
bool issue2322() {
|
||||
TEST_START();
|
||||
std::vector<std::pair<std::string, bool>> examples = {{R"("hello")", false},
|
||||
{R"(\"hello)", true},
|
||||
{R"("hello\")", true},
|
||||
{R"("hel\"lo")", false},
|
||||
{R"("hel\\lo")", false},
|
||||
{R"(\"hel\\\"lo\")", true},
|
||||
{R"(\\"hel\\\"lo\")", false}};
|
||||
for (std::pair<std::string, bool> v : examples) {
|
||||
ASSERT_EQUAL(ondemand::raw_json_string::is_free_from_unescaped_quote(v.first),
|
||||
v.second);
|
||||
ASSERT_EQUAL(ondemand::raw_json_string::is_free_from_unescaped_quote(v.first.c_str()),
|
||||
v.second);
|
||||
}
|
||||
TEST_SUCCEED();
|
||||
}
|
||||
#if SIMDJSON_EXCEPTIONS
|
||||
// user reported an asan error:
|
||||
bool issue2199() {
|
||||
@@ -537,6 +554,24 @@ namespace misc_tests {
|
||||
TEST_SUCCEED();
|
||||
}
|
||||
|
||||
simdjson_warn_unused bool issue2312() {
|
||||
TEST_START();
|
||||
std::string init_string = R"("abc":)";
|
||||
init_string.resize(init_string.size() + simdjson::SIMDJSON_PADDING);
|
||||
simdjson::padded_string_view padded_view{init_string.data(), 5, init_string.size()};
|
||||
simdjson::ondemand::parser parser;
|
||||
simdjson::ondemand::document doc;
|
||||
ASSERT_SUCCESS(parser.iterate(padded_view).get(doc));
|
||||
std::string_view abc;
|
||||
ASSERT_SUCCESS(doc.get_string().get(abc));
|
||||
ASSERT_EQUAL(abc, "abc");
|
||||
ASSERT_SUCCESS(parser.iterate(padded_view).get(doc));
|
||||
std::string_view raw;
|
||||
ASSERT_SUCCESS(doc.raw_json().get(raw));
|
||||
ASSERT_EQUAL(raw, "\"abc\"");
|
||||
TEST_SUCCEED();
|
||||
}
|
||||
|
||||
simdjson_warn_unused bool big_integer() {
|
||||
TEST_START();
|
||||
simdjson::ondemand::parser parser;
|
||||
@@ -620,6 +655,8 @@ namespace misc_tests {
|
||||
|
||||
bool run() {
|
||||
return
|
||||
issue2322() &&
|
||||
issue2312() &&
|
||||
#if SIMDJSON_EXCEPTIONS
|
||||
issue2199() &&
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user