![]() |
simdjson
3.1.6
Ridiculously Fast JSON
|
We want to support argument-dependent lookup (ADL). More...
Typedefs | |
| using | ParsedJson = dom::parser |
| using | ErrorValues = error_code |
Enumerations | |
| enum | error_code { SUCCESS = 0 , CAPACITY , MEMALLOC , TAPE_ERROR , DEPTH_ERROR , STRING_ERROR , T_ATOM_ERROR , F_ATOM_ERROR , N_ATOM_ERROR , NUMBER_ERROR , UTF8_ERROR , UNINITIALIZED , EMPTY , UNESCAPED_CHARS , UNCLOSED_STRING , UNSUPPORTED_ARCHITECTURE , INCORRECT_TYPE , NUMBER_OUT_OF_RANGE , INDEX_OUT_OF_BOUNDS , NO_SUCH_FIELD , IO_ERROR , INVALID_JSON_POINTER , INVALID_URI_FRAGMENT , UNEXPECTED_ERROR , PARSER_IN_USE , OUT_OF_ORDER_ITERATION , INSUFFICIENT_PADDING , INCOMPLETE_ARRAY_OR_OBJECT , SCALAR_DOCUMENT_AS_VALUE , OUT_OF_BOUNDS , TRAILING_CONTENT , NUM_ERROR_CODES } |
| All possible errors returned by simdjson. More... | |
| enum class | stage1_mode { regular , streaming_partial , streaming_final } |
| This enum is used with the dom_parser_implementation::stage1 function. More... | |
| enum | { SIMDJSON_VERSION_MAJOR = 3 , SIMDJSON_VERSION_MINOR = 1 , SIMDJSON_VERSION_REVISION = 6 } |
Functions | |
| const implementation * | builtin_implementation () |
| Represents the best statically linked simdjson implementation that can be used by the compiling program. More... | |
| int | json_parse (const uint8_t *buf, size_t len, dom::parser &parser, bool realloc_if_needed=true) noexcept |
| int | json_parse (const char *buf, size_t len, dom::parser &parser, bool realloc_if_needed=true) noexcept |
| int | json_parse (const std::string &s, dom::parser &parser, bool realloc_if_needed=true) noexcept |
| int | json_parse (const padded_string &s, dom::parser &parser) noexcept |
| simdjson_warn_unused dom::parser | build_parsed_json (const uint8_t *buf, size_t len, bool realloc_if_needed=true) noexcept |
| simdjson_warn_unused dom::parser | build_parsed_json (const char *buf, size_t len, bool realloc_if_needed=true) noexcept |
| simdjson_warn_unused dom::parser | build_parsed_json (const std::string &s, bool realloc_if_needed=true) noexcept |
| simdjson_warn_unused dom::parser | build_parsed_json (const padded_string &s) noexcept |
| template<class T > | |
| std::string | to_string (T x) |
| Converts JSON to a string. More... | |
| template<class T > | |
| std::string | to_string (simdjson_result< T > x) |
| template<class T > | |
| std::string | minify (T x) |
| Minifies a JSON element or document, printing the smallest possible valid JSON. More... | |
| template<class T > | |
| std::string | minify (simdjson_result< T > x) |
| const char * | error_message (error_code error) noexcept |
| Get the error message for the given error code. More... | |
| const std::string | error_message (int error) noexcept |
| std::ostream & | operator<< (std::ostream &out, error_code error) noexcept |
| Write the error message to the output stream. | |
| template<typename T > | |
| std::ostream & | operator<< (std::ostream &out, simdjson_result< T > value) |
| std::string_view | trim (const std::string_view str) noexcept |
| simdjson_result< std::string_view > | to_json_string (SIMDJSON_IMPLEMENTATION::ondemand::document &x) noexcept |
| Create a string-view instance out of a document instance. More... | |
| simdjson_result< std::string_view > | to_json_string (SIMDJSON_IMPLEMENTATION::ondemand::document_reference &x) noexcept |
| simdjson_result< std::string_view > | to_json_string (SIMDJSON_IMPLEMENTATION::ondemand::value &x) noexcept |
| Create a string-view instance out of a value instance. More... | |
| simdjson_result< std::string_view > | to_json_string (SIMDJSON_IMPLEMENTATION::ondemand::object &x) noexcept |
| Create a string-view instance out of an object instance. More... | |
| simdjson_result< std::string_view > | to_json_string (SIMDJSON_IMPLEMENTATION::ondemand::array &x) noexcept |
| Create a string-view instance out of an array instance. More... | |
| simdjson_result< std::string_view > | to_json_string (simdjson_result< SIMDJSON_IMPLEMENTATION::ondemand::document > x) |
| simdjson_result< std::string_view > | to_json_string (simdjson_result< SIMDJSON_IMPLEMENTATION::ondemand::document_reference > x) |
| simdjson_result< std::string_view > | to_json_string (simdjson_result< SIMDJSON_IMPLEMENTATION::ondemand::value > x) |
| simdjson_result< std::string_view > | to_json_string (simdjson_result< SIMDJSON_IMPLEMENTATION::ondemand::object > x) |
| simdjson_result< std::string_view > | to_json_string (simdjson_result< SIMDJSON_IMPLEMENTATION::ondemand::array > x) |
| simdjson_warn_unused bool | validate_utf8 (const char *buf, size_t len) noexcept |
| Validate the UTF-8 string. More... | |
| simdjson_inline simdjson_warn_unused bool | validate_utf8 (const std::string_view sv) noexcept |
| Validate the UTF-8 string. More... | |
| simdjson_inline simdjson_warn_unused bool | validate_utf8 (const std::string &s) noexcept |
| Validate the UTF-8 string. More... | |
| SIMDJSON_DLLIMPORTEXPORT const internal::available_implementation_list & | get_available_implementations () |
| The list of available implementations compiled into simdjson. | |
| SIMDJSON_DLLIMPORTEXPORT internal::atomic_ptr< const implementation > & | get_active_implementation () |
| The active implementation. More... | |
| bool | is_streaming (stage1_mode mode) |
| Returns true if mode == streaming_partial or mode == streaming_final. | |
| padded_string | get_corpus (const char *path) |
| simdjson_warn_unused error_code | minify (const char *buf, size_t len, char *dst, size_t &dst_len) noexcept |
| Minify the input string assuming that it represents a JSON string, does not parse or validate. More... | |
| std::ostream & | operator<< (std::ostream &out, const padded_string &s) |
| Send padded_string instance to an output stream. More... | |
| std::ostream & | operator<< (std::ostream &out, simdjson_result< padded_string > &s) noexcept(false) |
| Send padded_string instance to an output stream. More... | |
| std::ostream & | operator<< (std::ostream &out, simdjson_result< padded_string_view > &s) noexcept(false) |
| Send padded_string instance to an output stream. More... | |
Variables | |
| constexpr size_t | SIMDJSON_MAXSIZE_BYTES = 0xFFFFFFFF |
| The maximum document size supported by simdjson. | |
| constexpr size_t | SIMDJSON_PADDING = 64 |
| The amount of padding needed in a buffer to parse JSON. More... | |
| constexpr size_t | DEFAULT_MAX_DEPTH = 1024 |
| By default, simdjson supports this many nested objects and arrays. More... | |
We want to support argument-dependent lookup (ADL).
Hence we should define operator<< in the namespace where the argument (here value, object, etc.) resides. Credit: @madhur4127 See https://github.com/simdjson/simdjson/issues/1768
| using simdjson::ErrorValues = typedef error_code |
| using simdjson::ParsedJson = typedef dom::parser |
dom::parser instead.Definition at line 13 of file parsedjson.h.
| anonymous enum |
Definition at line 10 of file simdjson_version.h.
| enum simdjson::error_code |
All possible errors returned by simdjson.
These error codes are subject to change and not all simdjson kernel returns the same error code given the same input: it is not well defined which error a given input should produce.
Only SUCCESS evaluates to false as a Boolean. All other error codes will evaluate to true as a Boolean.
|
strong |
This enum is used with the dom_parser_implementation::stage1 function.
1) The regular mode expects a fully formed JSON document. 2) The streaming_partial mode expects a possibly truncated input within a stream on JSON documents. 3) The stream_final mode allows us to truncate final unterminated strings. It is useful in conjunction with streaming_partial.
Definition at line 22 of file dom_parser_implementation.h.
| const implementation* simdjson::builtin_implementation | ( | ) |
Represents the best statically linked simdjson implementation that can be used by the compiling program.
Detects what options the program is compiled against, and picks the minimum implementation that will work on any computer that can run the program. For example, if you compile with g++ -march=westmere, it will pick the westmere implementation. The haswell implementation will still be available, and can be selected at runtime, but the builtin implementation (and any code that uses it) will use westmere.
Function which returns a pointer to an implementation matching the "builtin" implementation. The builtin implementation is the best statically linked simdjson implementation that can be used by the compiling program. If you compile with g++ -march=haswell, this will return the haswell implementation. It is handy to be able to check what builtin was used: builtin_implementation()->name().
|
inlinenoexcept |
Get the error message for the given error code.
dom::parser parser; dom::element doc; auto error = parser.parse("foo",3).get(doc); if (error) { printf("Error: %s\n", error_message(error)); }
Definition at line 21 of file error-inl.h.
|
inlinenoexcept |
error_code, use error_message() instead.Definition at line 28 of file error-inl.h.
| SIMDJSON_DLLIMPORTEXPORT internal::atomic_ptr<const implementation>& simdjson::get_active_implementation | ( | ) |
The active implementation.
Automatically initialized on first use to the most advanced implementation supported by this hardware.
|
noexcept |
Minify the input string assuming that it represents a JSON string, does not parse or validate.
This function is much faster than parsing a JSON string and then writing a minified version of it. However, it does not validate the input. It will merely return an error in simple cases (e.g., if there is a string that was never terminated).
| buf | the json document to minify. |
| len | the length of the json document. |
| dst | the buffer to write the minified document to. MUST be allocated up to len bytes. |
| dst_len | the number of bytes written. Output only. |
| std::string simdjson::minify | ( | T | x | ) |
Minifies a JSON element or document, printing the smallest possible valid JSON.
dom::parser parser; element doc = parser.parse(" [ 1 , 2 , 3 ] "_padded); cout << minify(doc) << endl; // prints [1,2,3]
Definition at line 203 of file serialization.h.
|
inline |
Send padded_string instance to an output stream.
| out | The output stream. |
| s | The padded_string instance. |
| if | there is an error with the underlying output stream. simdjson itself will not throw. |
Definition at line 132 of file padded_string.h.
|
inlinenoexcept |
Send padded_string instance to an output stream.
| out | The output stream. |
| s | The padded_string instance. |
| simdjson_error | if the result being printed has an error. If there is an error with the underlying output stream, that error will be propagated (simdjson_error will not be thrown). |
Definition at line 144 of file padded_string.h.
|
inlinenoexcept |
Send padded_string instance to an output stream.
| out | The output stream. |
| s | The padded_string_view. |
| simdjson_error | if the result being printed has an error. If there is an error with the underlying output stream, that error will be propagated (simdjson_error will not be thrown). |
Definition at line 72 of file padded_string_view.h.
|
inlinenoexcept |
Create a string-view instance out of an array instance.
The string-view instance contains JSON text that is suitable to be parsed as JSON again. It does not validate the content.
Definition at line 69 of file serialization-inl.h.
|
inlinenoexcept |
Create a string-view instance out of a document instance.
The string-view instance contains JSON text that is suitable to be parsed as JSON again. It does not validate the content.
Definition at line 16 of file serialization-inl.h.
|
inlinenoexcept |
Create a string-view instance out of an object instance.
The string-view instance contains JSON text that is suitable to be parsed as JSON again. It does not validate the content.
Definition at line 62 of file serialization-inl.h.
|
inlinenoexcept |
Create a string-view instance out of a value instance.
The string-view instance contains JSON text that is suitable to be parsed as JSON again. The value must not have been accessed previously. It does not validate the content.
If we somehow receive a value that has already been consumed, then the following code could be in trouble. E.g., we create an array as needed, but if an array was already created, then it could be bad.
Definition at line 30 of file serialization-inl.h.
| std::string simdjson::to_string | ( | T | x | ) |
Converts JSON to a string.
dom::parser parser; element doc = parser.parse(" [ 1 , 2 , 3 ] "_padded); cout << to_string(doc) << endl; // prints [1,2,3]
Definition at line 177 of file serialization.h.
|
noexcept |
Validate the UTF-8 string.
| buf | the string to validate. |
| len | the length of the string in bytes. |
|
noexcept |
Validate the UTF-8 string.
| p | the string to validate. |
Definition at line 37 of file implementation.h.
|
noexcept |
Validate the UTF-8 string.
| sv | the string_view to validate. |
Definition at line 27 of file implementation.h.
|
constexpr |
By default, simdjson supports this many nested objects and arrays.
This is the default for parser::max_depth().
Definition at line 52 of file common_defs.h.
|
constexpr |
The amount of padding needed in a buffer to parse JSON.
The input buf should be readable up to buf + SIMDJSON_PADDING this is a stopgap; there should be a better description of the main loop and its behavior that abstracts over this See https://github.com/simdjson/simdjson/issues/174
Definition at line 45 of file common_defs.h.