1
- /* auto-generated on Tue 23 Jun 2020 20:51:12 EDT . Do not edit! */
1
+ /* auto-generated on Thu Jun 25 16:43:19 PDT 2020 . Do not edit! */
2
2
/* begin file include/simdjson.h */
3
3
#ifndef SIMDJSON_H
4
4
#define SIMDJSON_H
91
91
92
92
#if defined(__x86_64__) || defined(_M_AMD64)
93
93
#define SIMDJSON_IS_X86_64 1
94
- #endif
95
- #if defined(__aarch64__) || defined(_M_ARM64)
94
+ #elif defined(__aarch64__) || defined(_M_ARM64)
96
95
#define SIMDJSON_IS_ARM64 1
96
+ #else
97
+ #define SIMDJSON_IS_32BITS 1
97
98
#endif
98
99
99
- #if (!defined(SIMDJSON_IS_X86_64)) && (!defined(SIMDJSON_IS_ARM64))
100
- #ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
100
+ #ifdef SIMDJSON_IS_32BITS
101
+ #if defined( SIMDJSON_REGULAR_VISUAL_STUDIO) || defined(__GNUC__)
101
102
#pragma message("The simdjson library is designed\
102
103
for 64 -bit processors and it seems that you are not \
103
104
compiling for a known 64 -bit platform. All fast kernels \
@@ -108,7 +109,7 @@ use a 64-bit target such as x64 or 64-bit ARM.")
108
109
for 64 -bit processors. It seems that you are not \
109
110
compiling for a known 64 -bit platform."
110
111
#endif
111
- #endif // (!defined(SIMDJSON_IS_X86_64)) && (!defined(SIMDJSON_IS_ARM64))
112
+ #endif // SIMDJSON_IS_32BITS
112
113
113
114
// this is almost standard?
114
115
#undef STRINGIFY_IMPLEMENTATION_
@@ -2632,7 +2633,6 @@ inline error_code dom_parser_implementation::allocate(size_t capacity, size_t ma
2632
2633
2633
2634
#endif // SIMDJSON_INTERNAL_DOM_PARSER_IMPLEMENTATION_H
2634
2635
/* end file include/simdjson/internal/dom_parser_implementation.h */
2635
- #include <optional>
2636
2636
#include <string>
2637
2637
#include <atomic>
2638
2638
#include <vector>
@@ -4008,21 +4008,42 @@ class element {
4008
4008
*/
4009
4009
inline simdjson_result<object> get_object () const noexcept ;
4010
4010
/* *
4011
- * Cast this element to a string.
4011
+ * Cast this element to a null-terminated C string.
4012
+ *
4013
+ * The string is guaranteed to be valid UTF-8.
4012
4014
*
4013
- * Equivalent to get<const char *>().
4015
+ * The get_c_str() function is equivalent to get<const char *>().
4016
+ *
4017
+ * The length of the string is given by get_string_length(). Because JSON strings
4018
+ * may contain null characters, it may be incorrect to use strlen to determine the
4019
+ * string length.
4020
+ *
4021
+ * It is possible to get a single string_view instance which represents both the string
4022
+ * content and its length: see get_string().
4014
4023
*
4015
- * @returns An pointer to a null-terminated string. This string is stored in the parser and will
4024
+ * @returns A pointer to a null-terminated UTF-8 string. This string is stored in the parser and will
4016
4025
* be invalidated the next time it parses a document or when it is destroyed.
4017
4026
* Returns INCORRECT_TYPE if the JSON element is not a string.
4018
4027
*/
4019
4028
inline simdjson_result<const char *> get_c_str () const noexcept ;
4020
4029
/* *
4021
- * Cast this element to a string.
4030
+ * Gives the length in bytes of the string.
4031
+ *
4032
+ * It is possible to get a single string_view instance which represents both the string
4033
+ * content and its length: see get_string().
4034
+ *
4035
+ * @returns A string length in bytes.
4036
+ * Returns INCORRECT_TYPE if the JSON element is not a string.
4037
+ */
4038
+ inline simdjson_result<size_t > get_string_length () const noexcept ;
4039
+ /* *
4040
+ * Cast this element to a string.
4041
+ *
4042
+ * The string is guaranteed to be valid UTF-8.
4022
4043
*
4023
4044
* Equivalent to get<std::string_view>().
4024
4045
*
4025
- * @returns A string. The string is stored in the parser and will be invalidated the next time it
4046
+ * @returns An UTF-8 string. The string is stored in the parser and will be invalidated the next time it
4026
4047
* parses a document or when it is destroyed.
4027
4048
* Returns INCORRECT_TYPE if the JSON element is not a string.
4028
4049
*/
@@ -4199,7 +4220,9 @@ class element {
4199
4220
inline operator bool () const noexcept (false );
4200
4221
4201
4222
/* *
4202
- * Read this element as a null-terminated string.
4223
+ * Read this element as a null-terminated UTF-8 string.
4224
+ *
4225
+ * Be mindful that JSON allows strings to contain null characters.
4203
4226
*
4204
4227
* Does *not* convert other types to a string; requires that the JSON type of the element was
4205
4228
* an actual string.
@@ -4210,7 +4233,7 @@ class element {
4210
4233
inline explicit operator const char *() const noexcept (false );
4211
4234
4212
4235
/* *
4213
- * Read this element as a null-terminated string.
4236
+ * Read this element as a null-terminated UTF-8 string.
4214
4237
*
4215
4238
* Does *not* convert other types to a string; requires that the JSON type of the element was
4216
4239
* an actual string.
@@ -4410,6 +4433,7 @@ struct simdjson_result<dom::element> : public internal::simdjson_result_base<dom
4410
4433
really_inline simdjson_result<dom::array> get_array () const noexcept ;
4411
4434
really_inline simdjson_result<dom::object> get_object () const noexcept ;
4412
4435
really_inline simdjson_result<const char *> get_c_str () const noexcept ;
4436
+ really_inline simdjson_result<size_t > get_string_length () const noexcept ;
4413
4437
really_inline simdjson_result<std::string_view> get_string () const noexcept ;
4414
4438
really_inline simdjson_result<int64_t > get_int64 () const noexcept ;
4415
4439
really_inline simdjson_result<uint64_t > get_uint64 () const noexcept ;
@@ -5820,6 +5844,10 @@ really_inline simdjson_result<const char *> simdjson_result<dom::element>::get_c
5820
5844
if (error ()) { return error (); }
5821
5845
return first.get_c_str ();
5822
5846
}
5847
+ really_inline simdjson_result<size_t > simdjson_result<dom::element>::get_string_length() const noexcept {
5848
+ if (error ()) { return error (); }
5849
+ return first.get_string_length ();
5850
+ }
5823
5851
really_inline simdjson_result<std::string_view> simdjson_result<dom::element>::get_string() const noexcept {
5824
5852
if (error ()) { return error (); }
5825
5853
return first.get_string ();
@@ -5960,6 +5988,15 @@ inline simdjson_result<const char *> element::get_c_str() const noexcept {
5960
5988
return INCORRECT_TYPE;
5961
5989
}
5962
5990
}
5991
+ inline simdjson_result<size_t > element::get_string_length () const noexcept {
5992
+ switch (tape.tape_ref_type ()) {
5993
+ case internal::tape_type::STRING: {
5994
+ return tape.get_string_length ();
5995
+ }
5996
+ default :
5997
+ return INCORRECT_TYPE;
5998
+ }
5999
+ }
5963
6000
inline simdjson_result<std::string_view> element::get_string () const noexcept {
5964
6001
switch (tape.tape_ref_type ()) {
5965
6002
case internal::tape_type::STRING:
0 commit comments