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! */
22/* begin file include/simdjson.h */
33#ifndef SIMDJSON_H
44#define SIMDJSON_H
9191
9292#if defined(__x86_64__) || defined(_M_AMD64)
9393#define SIMDJSON_IS_X86_64 1
94- #endif
95- #if defined(__aarch64__) || defined(_M_ARM64)
94+ #elif defined(__aarch64__) || defined(_M_ARM64)
9695#define SIMDJSON_IS_ARM64 1
96+ #else
97+ #define SIMDJSON_IS_32BITS 1
9798#endif
9899
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__)
101102#pragma message("The simdjson library is designed\
102103 for 64 -bit processors and it seems that you are not \
103104compiling 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.")
108109 for 64 -bit processors. It seems that you are not \
109110compiling for a known 64 -bit platform."
110111#endif
111- #endif // (!defined(SIMDJSON_IS_X86_64)) && (!defined(SIMDJSON_IS_ARM64))
112+ #endif // SIMDJSON_IS_32BITS
112113
113114// this is almost standard?
114115#undef STRINGIFY_IMPLEMENTATION_
@@ -2632,7 +2633,6 @@ inline error_code dom_parser_implementation::allocate(size_t capacity, size_t ma
26322633
26332634#endif // SIMDJSON_INTERNAL_DOM_PARSER_IMPLEMENTATION_H
26342635/* end file include/simdjson/internal/dom_parser_implementation.h */
2635- #include <optional>
26362636#include <string>
26372637#include <atomic>
26382638#include <vector>
@@ -4008,21 +4008,42 @@ class element {
40084008 */
40094009 inline simdjson_result<object> get_object () const noexcept ;
40104010 /* *
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.
40124014 *
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().
40144023 *
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
40164025 * be invalidated the next time it parses a document or when it is destroyed.
40174026 * Returns INCORRECT_TYPE if the JSON element is not a string.
40184027 */
40194028 inline simdjson_result<const char *> get_c_str () const noexcept ;
40204029 /* *
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.
40224043 *
40234044 * Equivalent to get<std::string_view>().
40244045 *
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
40264047 * parses a document or when it is destroyed.
40274048 * Returns INCORRECT_TYPE if the JSON element is not a string.
40284049 */
@@ -4199,7 +4220,9 @@ class element {
41994220 inline operator bool () const noexcept (false );
42004221
42014222 /* *
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.
42034226 *
42044227 * Does *not* convert other types to a string; requires that the JSON type of the element was
42054228 * an actual string.
@@ -4210,7 +4233,7 @@ class element {
42104233 inline explicit operator const char *() const noexcept (false );
42114234
42124235 /* *
4213- * Read this element as a null-terminated string.
4236+ * Read this element as a null-terminated UTF-8 string.
42144237 *
42154238 * Does *not* convert other types to a string; requires that the JSON type of the element was
42164239 * an actual string.
@@ -4410,6 +4433,7 @@ struct simdjson_result<dom::element> : public internal::simdjson_result_base<dom
44104433 really_inline simdjson_result<dom::array> get_array () const noexcept ;
44114434 really_inline simdjson_result<dom::object> get_object () const noexcept ;
44124435 really_inline simdjson_result<const char *> get_c_str () const noexcept ;
4436+ really_inline simdjson_result<size_t > get_string_length () const noexcept ;
44134437 really_inline simdjson_result<std::string_view> get_string () const noexcept ;
44144438 really_inline simdjson_result<int64_t > get_int64 () const noexcept ;
44154439 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
58205844 if (error ()) { return error (); }
58215845 return first.get_c_str ();
58225846}
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+ }
58235851really_inline simdjson_result<std::string_view> simdjson_result<dom::element>::get_string() const noexcept {
58245852 if (error ()) { return error (); }
58255853 return first.get_string ();
@@ -5960,6 +5988,15 @@ inline simdjson_result<const char *> element::get_c_str() const noexcept {
59605988 return INCORRECT_TYPE;
59615989 }
59625990}
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+ }
59636000inline simdjson_result<std::string_view> element::get_string () const noexcept {
59646001 switch (tape.tape_ref_type ()) {
59656002 case internal::tape_type::STRING:
0 commit comments