1 #ifndef SIMDJSON_DOM_ELEMENT_H
2 #define SIMDJSON_DOM_ELEMENT_H
4 #include "simdjson/common_defs.h"
5 #include "simdjson/error.h"
6 #include "simdjson/internal/tape_ref.h"
23 enum class element_type {
43 simdjson_inline
element() noexcept;
46 simdjson_inline element_type
type()
const noexcept;
135 inline bool is_array()
const noexcept;
153 inline bool is_int64()
const noexcept;
179 inline bool is_bool()
const noexcept;
183 inline bool is_null()
const noexcept;
198 simdjson_inline
bool is()
const noexcept;
223 static_assert(!
sizeof(T),
"The get method with given type is not implemented by the simdjson library.");
243 simdjson_warn_unused simdjson_inline
error_code get(T &value)
const noexcept;
263 #if SIMDJSON_EXCEPTIONS
270 inline operator bool() const noexcept(false);
283 inline explicit operator const
char*() const noexcept(false);
294 inline operator std::string_view() const noexcept(false);
303 inline operator uint64_t() const noexcept(false);
311 inline operator int64_t() const noexcept(false);
319 inline operator
double() const noexcept(false);
326 inline operator
array() const noexcept(false);
333 inline operator
object() const noexcept(false);
341 inline dom::
array::iterator
begin() const noexcept(false);
349 inline dom::
array::iterator
end() const noexcept(false);
406 #ifndef SIMDJSON_DISABLE_DEPRECATED_API
427 [[deprecated(
"For standard compliance, use at_pointer instead, and prefix your pointers with a slash '/', see RFC6901 ")]]
464 inline bool dump_raw_tape(std::ostream &out)
const noexcept;
467 simdjson_inline
element(
const internal::tape_ref &tape) noexcept;
468 internal::tape_ref tape;
474 friend class simdjson::internal::string_builder;
482 struct simdjson_result<dom::element> :
public internal::simdjson_result_base<dom::element> {
490 simdjson_inline
bool is()
const noexcept;
506 simdjson_inline
bool is_array()
const noexcept;
507 simdjson_inline
bool is_object()
const noexcept;
508 simdjson_inline
bool is_string()
const noexcept;
509 simdjson_inline
bool is_int64()
const noexcept;
510 simdjson_inline
bool is_uint64()
const noexcept;
511 simdjson_inline
bool is_double()
const noexcept;
512 simdjson_inline
bool is_number()
const noexcept;
513 simdjson_inline
bool is_bool()
const noexcept;
514 simdjson_inline
bool is_null()
const noexcept;
519 [[deprecated(
"For standard compliance, use at_pointer instead, and prefix your pointers with a slash '/', see RFC6901 ")]]
525 #if SIMDJSON_EXCEPTIONS
526 simdjson_inline
operator bool()
const noexcept(
false);
527 simdjson_inline
explicit operator const char*()
const noexcept(
false);
528 simdjson_inline
operator std::string_view()
const noexcept(
false);
529 simdjson_inline
operator uint64_t()
const noexcept(
false);
530 simdjson_inline
operator int64_t()
const noexcept(
false);
531 simdjson_inline
operator double()
const noexcept(
false);
532 simdjson_inline
operator dom::array()
const noexcept(
false);
533 simdjson_inline
operator dom::object()
const noexcept(
false);
bool is_object() const noexcept
Whether this element is a json object.
bool is_double() const noexcept
Whether this element is a json number that fits in a double.
simdjson_inline element_type type() const noexcept
The type of this element.
bool is_number() const noexcept
Whether this element is a json number.
simdjson_result< const char * > get_c_str() const noexcept
Cast this element to a null-terminated C string.
simdjson_result< element > at_pointer(const std::string_view json_pointer) const noexcept
Get the value associated with the given JSON pointer.
simdjson_result< double > get_double() const noexcept
Cast this element to a double floating-point.
simdjson_result< T > get() const noexcept
Get the value as the provided type (T).
simdjson_inline bool is() const noexcept
Tell whether the value can be cast to provided type (T).
simdjson_result< element > at_key_case_insensitive(std::string_view key) const noexcept
Get the value associated with the given key in a case-insensitive manner.
void tie(T &value, error_code &error) &&noexcept
Get the value as the provided type (T), setting error if it's not the given type.
simdjson_result< bool > get_bool() const noexcept
Cast this element to a bool.
bool is_string() const noexcept
Whether this element is a json string.
simdjson_result< element > at_key(std::string_view key) const noexcept
Get the value associated with the given key.
dom::array::iterator end() const noexcept(false)
Iterate over each element in this array.
simdjson_result< array > get_array() const noexcept
Cast this element to an array.
simdjson_result< size_t > get_string_length() const noexcept
Gives the length in bytes of the string.
simdjson_inline element() noexcept
Create a new, invalid element.
simdjson_result< uint64_t > get_uint64() const noexcept
Cast this element to an unsigned integer.
dom::array::iterator begin() const noexcept(false)
Iterate over each element in this array.
simdjson_result< element > at(const std::string_view json_pointer) const noexcept
Version 0.4 of simdjson used an incorrect interpretation of the JSON Pointer standard and allowed the...
simdjson_result< int64_t > get_int64() const noexcept
Cast this element to a signed integer.
simdjson_result< object > get_object() const noexcept
Cast this element to an object.
bool is_uint64() const noexcept
Whether this element is a json number that fits in an unsigned 64-bit integer.
simdjson_result< element > operator[](std::string_view key) const noexcept
Get the value associated with the given key.
bool is_int64() const noexcept
Whether this element is a json number that fits in a signed 64-bit integer.
bool is_null() const noexcept
Whether this element is a json null.
simdjson_result< std::string_view > get_string() const noexcept
Cast this element to a string.
bool is_array() const noexcept
Whether this element is a json array.
bool is_bool() const noexcept
Whether this element is a json true or false.
@ object
A JSON object ( { "a": 1, "b" 2, ... } )
@ array
A JSON array ( [ 1, 2, 3 ... ] )
We want to support argument-dependent lookup (ADL).
error_code
All possible errors returned by simdjson.
The result of a JSON conversion that may fail.
The result of a JSON navigation that may fail.
The result of a JSON conversion that may fail.
The result of a simdjson operation that could fail.
simdjson_inline error_code error() const noexcept
The error.
simdjson_warn_unused simdjson_inline error_code get(T &value) &&noexcept
Move the value to the provided variable.
simdjson_inline T & value() &noexcept(false)
Get the result value.