1
- /* auto-generated on 2025-02-14 16:11:36 -0500 . Do not edit! */
1
+ /* auto-generated on 2025-03-27 15:01:10 -0400 . Do not edit! */
2
2
/* including simdjson.cpp: */
3
3
/* begin file simdjson.cpp */
4
4
#define SIMDJSON_SRC_SIMDJSON_CPP
@@ -776,22 +776,22 @@ inline namespace literals {
776
776
inline namespace string_view_literals {
777
777
778
778
779
- constexpr std::string_view operator "" _sv( const char* str, size_t len ) noexcept // (1)
779
+ constexpr std::string_view operator ""_sv( const char* str, size_t len ) noexcept // (1)
780
780
{
781
781
return std::string_view{ str, len };
782
782
}
783
783
784
- constexpr std::u16string_view operator "" _sv( const char16_t* str, size_t len ) noexcept // (2)
784
+ constexpr std::u16string_view operator ""_sv( const char16_t* str, size_t len ) noexcept // (2)
785
785
{
786
786
return std::u16string_view{ str, len };
787
787
}
788
788
789
- constexpr std::u32string_view operator "" _sv( const char32_t* str, size_t len ) noexcept // (3)
789
+ constexpr std::u32string_view operator ""_sv( const char32_t* str, size_t len ) noexcept // (3)
790
790
{
791
791
return std::u32string_view{ str, len };
792
792
}
793
793
794
- constexpr std::wstring_view operator "" _sv( const wchar_t* str, size_t len ) noexcept // (4)
794
+ constexpr std::wstring_view operator ""_sv( const wchar_t* str, size_t len ) noexcept // (4)
795
795
{
796
796
return std::wstring_view{ str, len };
797
797
}
@@ -2122,22 +2122,22 @@ nssv_inline_ns namespace string_view_literals {
2122
2122
2123
2123
#if nssv_CONFIG_STD_SV_OPERATOR && nssv_HAVE_STD_DEFINED_LITERALS
2124
2124
2125
- nssv_constexpr nonstd::sv_lite::string_view operator "" sv( const char* str, size_t len ) nssv_noexcept // (1)
2125
+ nssv_constexpr nonstd::sv_lite::string_view operator ""sv( const char* str, size_t len ) nssv_noexcept // (1)
2126
2126
{
2127
2127
return nonstd::sv_lite::string_view{ str, len };
2128
2128
}
2129
2129
2130
- nssv_constexpr nonstd::sv_lite::u16string_view operator "" sv( const char16_t* str, size_t len ) nssv_noexcept // (2)
2130
+ nssv_constexpr nonstd::sv_lite::u16string_view operator ""sv( const char16_t* str, size_t len ) nssv_noexcept // (2)
2131
2131
{
2132
2132
return nonstd::sv_lite::u16string_view{ str, len };
2133
2133
}
2134
2134
2135
- nssv_constexpr nonstd::sv_lite::u32string_view operator "" sv( const char32_t* str, size_t len ) nssv_noexcept // (3)
2135
+ nssv_constexpr nonstd::sv_lite::u32string_view operator ""sv( const char32_t* str, size_t len ) nssv_noexcept // (3)
2136
2136
{
2137
2137
return nonstd::sv_lite::u32string_view{ str, len };
2138
2138
}
2139
2139
2140
- nssv_constexpr nonstd::sv_lite::wstring_view operator "" sv( const wchar_t* str, size_t len ) nssv_noexcept // (4)
2140
+ nssv_constexpr nonstd::sv_lite::wstring_view operator ""sv( const wchar_t* str, size_t len ) nssv_noexcept // (4)
2141
2141
{
2142
2142
return nonstd::sv_lite::wstring_view{ str, len };
2143
2143
}
@@ -2146,22 +2146,22 @@ nssv_constexpr nonstd::sv_lite::wstring_view operator "" sv( const wchar_t* str,
2146
2146
2147
2147
#if nssv_CONFIG_USR_SV_OPERATOR
2148
2148
2149
- nssv_constexpr nonstd::sv_lite::string_view operator "" _sv( const char* str, size_t len ) nssv_noexcept // (1)
2149
+ nssv_constexpr nonstd::sv_lite::string_view operator ""_sv( const char* str, size_t len ) nssv_noexcept // (1)
2150
2150
{
2151
2151
return nonstd::sv_lite::string_view{ str, len };
2152
2152
}
2153
2153
2154
- nssv_constexpr nonstd::sv_lite::u16string_view operator "" _sv( const char16_t* str, size_t len ) nssv_noexcept // (2)
2154
+ nssv_constexpr nonstd::sv_lite::u16string_view operator ""_sv( const char16_t* str, size_t len ) nssv_noexcept // (2)
2155
2155
{
2156
2156
return nonstd::sv_lite::u16string_view{ str, len };
2157
2157
}
2158
2158
2159
- nssv_constexpr nonstd::sv_lite::u32string_view operator "" _sv( const char32_t* str, size_t len ) nssv_noexcept // (3)
2159
+ nssv_constexpr nonstd::sv_lite::u32string_view operator ""_sv( const char32_t* str, size_t len ) nssv_noexcept // (3)
2160
2160
{
2161
2161
return nonstd::sv_lite::u32string_view{ str, len };
2162
2162
}
2163
2163
2164
- nssv_constexpr nonstd::sv_lite::wstring_view operator "" _sv( const wchar_t* str, size_t len ) nssv_noexcept // (4)
2164
+ nssv_constexpr nonstd::sv_lite::wstring_view operator ""_sv( const wchar_t* str, size_t len ) nssv_noexcept // (4)
2165
2165
{
2166
2166
return nonstd::sv_lite::wstring_view{ str, len };
2167
2167
}
@@ -2431,7 +2431,7 @@ enum error_code {
2431
2431
SUCCESS = 0, ///< No error
2432
2432
CAPACITY, ///< This parser can't support a document that big
2433
2433
MEMALLOC, ///< Error allocating memory, most likely out of memory
2434
- TAPE_ERROR, ///< Something went wrong, this is a generic error
2434
+ TAPE_ERROR, ///< Something went wrong, this is a generic error. Fatal/unrecoverable error.
2435
2435
DEPTH_ERROR, ///< Your document exceeds the user-specified depth limitation
2436
2436
STRING_ERROR, ///< Problem while parsing a string
2437
2437
T_ATOM_ERROR, ///< Problem while parsing an atom starting with the letter 't'
@@ -2456,13 +2456,21 @@ enum error_code {
2456
2456
PARSER_IN_USE, ///< parser is already in use.
2457
2457
OUT_OF_ORDER_ITERATION, ///< tried to iterate an array or object out of order (checked when SIMDJSON_DEVELOPMENT_CHECKS=1)
2458
2458
INSUFFICIENT_PADDING, ///< The JSON doesn't have enough padding for simdjson to safely parse it.
2459
- INCOMPLETE_ARRAY_OR_OBJECT, ///< The document ends early.
2459
+ INCOMPLETE_ARRAY_OR_OBJECT, ///< The document ends early. Fatal/unrecoverable error.
2460
2460
SCALAR_DOCUMENT_AS_VALUE, ///< A scalar document is treated as a value.
2461
2461
OUT_OF_BOUNDS, ///< Attempted to access location outside of document.
2462
2462
TRAILING_CONTENT, ///< Unexpected trailing content in the JSON input
2463
2463
NUM_ERROR_CODES
2464
2464
};
2465
2465
2466
+ /**
2467
+ * Some errors are fatal and invalidate the document. This function returns true if the
2468
+ * error is fatal. It returns true for TAPE_ERROR and INCOMPLETE_ARRAY_OR_OBJECT.
2469
+ * Once a fatal error is encountered, the on-demand document is no longer valid and
2470
+ * processing should stop.
2471
+ */
2472
+ inline bool is_fatal(error_code error) noexcept;
2473
+
2466
2474
/**
2467
2475
* It is the convention throughout the code that the macro SIMDJSON_DEVELOPMENT_CHECKS determines whether
2468
2476
* we check for OUT_OF_ORDER_ITERATION. The logic behind it is that these errors only occurs when the code
@@ -2765,14 +2773,30 @@ SIMDJSON_IMPL_CONCEPT(op_append, operator+=)
2765
2773
#undef SIMDJSON_IMPL_CONCEPT
2766
2774
} // namespace details
2767
2775
2776
+
2777
+ template <typename T>
2778
+ concept string_view_like = std::is_convertible_v<T, std::string_view> &&
2779
+ !std::is_convertible_v<T, const char*>;
2780
+
2781
+ template<typename T>
2782
+ concept constructible_from_string_view = std::is_constructible_v<T, std::string_view>
2783
+ && !std::is_same_v<T, std::string_view>
2784
+ && std::is_default_constructible_v<T>;
2785
+
2786
+ template<typename M>
2787
+ concept string_view_keyed_map = string_view_like<typename M::key_type>
2788
+ && requires(std::remove_cvref_t<M>& m, typename M::key_type sv, typename M::mapped_type v) {
2789
+ { m.emplace(sv, v) } -> std::same_as<std::pair<typename M::iterator, bool>>;
2790
+ };
2791
+
2768
2792
/// Check if T is a container that we can append to, including:
2769
2793
/// std::vector, std::deque, std::list, std::string, ...
2770
2794
template <typename T>
2771
2795
concept appendable_containers =
2772
- details::supports_emplace_back<T> || details::supports_emplace<T> ||
2796
+ ( details::supports_emplace_back<T> || details::supports_emplace<T> ||
2773
2797
details::supports_push_back<T> || details::supports_push<T> ||
2774
2798
details::supports_add<T> || details::supports_append<T> ||
2775
- details::supports_insert<T>;
2799
+ details::supports_insert<T>) && !string_view_keyed_map<T> ;
2776
2800
2777
2801
/// Insert into the container however possible
2778
2802
template <appendable_containers T, typename... Args>
@@ -2840,6 +2864,8 @@ concept optional_type = requires(std::remove_cvref_t<T> obj) {
2840
2864
{ static_cast<bool>(obj) } -> std::same_as<bool>; // convertible to bool
2841
2865
};
2842
2866
2867
+
2868
+
2843
2869
} // namespace concepts
2844
2870
} // namespace simdjson
2845
2871
#endif // SIMDJSON_SUPPORTS_DESERIALIZATION
@@ -4511,6 +4537,11 @@ extern SIMDJSON_DLLIMPORTEXPORT const uint32_t digit_to_val32[886];
4511
4537
#include <iostream>
4512
4538
4513
4539
namespace simdjson {
4540
+
4541
+ inline bool is_fatal(error_code error) noexcept {
4542
+ return error == TAPE_ERROR || error == INCOMPLETE_ARRAY_OR_OBJECT;
4543
+ }
4544
+
4514
4545
namespace internal {
4515
4546
// We store the error code so we can validate the error message is associated with the right code
4516
4547
struct error_code_info {
@@ -4696,7 +4727,7 @@ namespace internal {
4696
4727
{ SUCCESS, "SUCCESS: No error" },
4697
4728
{ CAPACITY, "CAPACITY: This parser can't support a document that big" },
4698
4729
{ MEMALLOC, "MEMALLOC: Error allocating memory, we're most likely out of memory" },
4699
- { TAPE_ERROR, "TAPE_ERROR: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc." },
4730
+ { TAPE_ERROR, "TAPE_ERROR: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. This is a fatal and unrecoverable error. " },
4700
4731
{ DEPTH_ERROR, "DEPTH_ERROR: The JSON document was too deep (too many nested objects and arrays)" },
4701
4732
{ STRING_ERROR, "STRING_ERROR: Problem while parsing a string" },
4702
4733
{ T_ATOM_ERROR, "T_ATOM_ERROR: Problem while parsing an atom starting with the letter 't'" },
@@ -4721,7 +4752,7 @@ namespace internal {
4721
4752
{ PARSER_IN_USE, "PARSER_IN_USE: Cannot parse a new document while a document is still in use." },
4722
4753
{ OUT_OF_ORDER_ITERATION, "OUT_OF_ORDER_ITERATION: Objects and arrays can only be iterated when they are first encountered." },
4723
4754
{ INSUFFICIENT_PADDING, "INSUFFICIENT_PADDING: simdjson requires the input JSON string to have at least SIMDJSON_PADDING extra bytes allocated, beyond the string's length. Consider using the simdjson::padded_string class if needed." },
4724
- { INCOMPLETE_ARRAY_OR_OBJECT, "INCOMPLETE_ARRAY_OR_OBJECT: JSON document ended early in the middle of an object or array." },
4755
+ { INCOMPLETE_ARRAY_OR_OBJECT, "INCOMPLETE_ARRAY_OR_OBJECT: JSON document ended early in the middle of an object or array. This is a fatal and unrecoverable error. " },
4725
4756
{ SCALAR_DOCUMENT_AS_VALUE, "SCALAR_DOCUMENT_AS_VALUE: A JSON document made of a scalar (number, Boolean, null or string) is treated as a value. Use get_bool(), get_double(), etc. on the document instead. "},
4726
4757
{ OUT_OF_BOUNDS, "OUT_OF_BOUNDS: Attempt to access location outside of document."},
4727
4758
{ TRAILING_CONTENT, "TRAILING_CONTENT: Unexpected trailing content in the JSON input."}
@@ -6787,7 +6818,7 @@ class document {
6787
6818
* The memory allocation is strict: you
6788
6819
* can you use this function to increase
6789
6820
* or lower the amount of allocated memory.
6790
- * Passsing zero clears the memory.
6821
+ * Passing zero clears the memory.
6791
6822
*/
6792
6823
error_code allocate(size_t len) noexcept;
6793
6824
/** @private Capacity in bytes, in terms
@@ -9185,7 +9216,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
9185
9216
// floor(log(5**power)/log(2))
9186
9217
//
9187
9218
// Note that this is not magic: 152170/(1<<16) is
9188
- // approximatively equal to log(5)/log(2).
9219
+ // approximately equal to log(5)/log(2).
9189
9220
// The 1<<16 value is a power of two; we could use a
9190
9221
// larger power of 2 if we wanted to.
9191
9222
//
@@ -15545,7 +15576,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
15545
15576
// floor(log(5**power)/log(2))
15546
15577
//
15547
15578
// Note that this is not magic: 152170/(1<<16) is
15548
- // approximatively equal to log(5)/log(2).
15579
+ // approximately equal to log(5)/log(2).
15549
15580
// The 1<<16 value is a power of two; we could use a
15550
15581
// larger power of 2 if we wanted to.
15551
15582
//
@@ -21769,7 +21800,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
21769
21800
// floor(log(5**power)/log(2))
21770
21801
//
21771
21802
// Note that this is not magic: 152170/(1<<16) is
21772
- // approximatively equal to log(5)/log(2).
21803
+ // approximately equal to log(5)/log(2).
21773
21804
// The 1<<16 value is a power of two; we could use a
21774
21805
// larger power of 2 if we wanted to.
21775
21806
//
@@ -28149,7 +28180,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
28149
28180
// floor(log(5**power)/log(2))
28150
28181
//
28151
28182
// Note that this is not magic: 152170/(1<<16) is
28152
- // approximatively equal to log(5)/log(2).
28183
+ // approximately equal to log(5)/log(2).
28153
28184
// The 1<<16 value is a power of two; we could use a
28154
28185
// larger power of 2 if we wanted to.
28155
28186
//
@@ -34891,7 +34922,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
34891
34922
// floor(log(5**power)/log(2))
34892
34923
//
34893
34924
// Note that this is not magic: 152170/(1<<16) is
34894
- // approximatively equal to log(5)/log(2).
34925
+ // approximately equal to log(5)/log(2).
34895
34926
// The 1<<16 value is a power of two; we could use a
34896
34927
// larger power of 2 if we wanted to.
34897
34928
//
@@ -41457,7 +41488,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
41457
41488
// floor(log(5**power)/log(2))
41458
41489
//
41459
41490
// Note that this is not magic: 152170/(1<<16) is
41460
- // approximatively equal to log(5)/log(2).
41491
+ // approximately equal to log(5)/log(2).
41461
41492
// The 1<<16 value is a power of two; we could use a
41462
41493
// larger power of 2 if we wanted to.
41463
41494
//
@@ -47468,7 +47499,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
47468
47499
// floor(log(5**power)/log(2))
47469
47500
//
47470
47501
// Note that this is not magic: 152170/(1<<16) is
47471
- // approximatively equal to log(5)/log(2).
47502
+ // approximately equal to log(5)/log(2).
47472
47503
// The 1<<16 value is a power of two; we could use a
47473
47504
// larger power of 2 if we wanted to.
47474
47505
//
@@ -53078,7 +53109,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative,
53078
53109
// floor(log(5**power)/log(2))
53079
53110
//
53080
53111
// Note that this is not magic: 152170/(1<<16) is
53081
- // approximatively equal to log(5)/log(2).
53112
+ // approximately equal to log(5)/log(2).
53082
53113
// The 1<<16 value is a power of two; we could use a
53083
53114
// larger power of 2 if we wanted to.
53084
53115
//
0 commit comments