simdjson  3.6.2
Ridiculously Fast JSON
document.h
1 #ifndef SIMDJSON_GENERIC_ONDEMAND_DOCUMENT_H
2 
3 #ifndef SIMDJSON_CONDITIONAL_INCLUDE
4 #define SIMDJSON_GENERIC_ONDEMAND_DOCUMENT_H
5 #include "simdjson/generic/ondemand/base.h"
6 #include "simdjson/generic/ondemand/json_iterator.h"
7 #endif // SIMDJSON_CONDITIONAL_INCLUDE
8 
9 namespace simdjson {
10 namespace SIMDJSON_IMPLEMENTATION {
11 namespace ondemand {
12 
20 class document {
21 public:
27  simdjson_inline document() noexcept = default;
28  simdjson_inline document(const document &other) noexcept = delete; // pass your documents by reference, not by copy
29  simdjson_inline document(document &&other) noexcept = default;
30  simdjson_inline document &operator=(const document &other) noexcept = delete;
31  simdjson_inline document &operator=(document &&other) noexcept = default;
32 
39  simdjson_inline simdjson_result<array> get_array() & noexcept;
46  simdjson_inline simdjson_result<object> get_object() & noexcept;
53  simdjson_inline simdjson_result<uint64_t> get_uint64() noexcept;
60  simdjson_inline simdjson_result<uint64_t> get_uint64_in_string() noexcept;
67  simdjson_inline simdjson_result<int64_t> get_int64() noexcept;
74  simdjson_inline simdjson_result<int64_t> get_int64_in_string() noexcept;
81  simdjson_inline simdjson_result<double> get_double() noexcept;
82 
89  simdjson_inline simdjson_result<double> get_double_in_string() noexcept;
102  simdjson_inline simdjson_result<std::string_view> get_string(bool allow_replacement = false) noexcept;
116  template <typename string_type>
117  simdjson_inline error_code get_string(string_type& receiver, bool allow_replacement = false) noexcept;
129  simdjson_inline simdjson_result<std::string_view> get_wobbly_string() noexcept;
138  simdjson_inline simdjson_result<raw_json_string> get_raw_json_string() noexcept;
145  simdjson_inline simdjson_result<bool> get_bool() noexcept;
158  simdjson_inline simdjson_result<value> get_value() noexcept;
159 
168  simdjson_inline simdjson_result<bool> is_null() noexcept;
169 
181  template<typename T> simdjson_inline simdjson_result<T> get() & noexcept {
182  // Unless the simdjson library provides an inline implementation, calling this method should
183  // immediately fail.
184  static_assert(!sizeof(T), "The get method with given type is not implemented by the simdjson library. "
185  "The supported types are ondemand::object, ondemand::array, raw_json_string, std::string_view, uint64_t, "
186  "int64_t, double, and bool. We recommend you use get_double(), get_bool(), get_uint64(), get_int64(), "
187  " get_object(), get_array(), get_raw_json_string(), or get_string() instead of the get template.");
188  }
190  template<typename T> simdjson_inline simdjson_result<T> get() && noexcept {
191  // Unless the simdjson library provides an inline implementation, calling this method should
192  // immediately fail.
193  static_assert(!sizeof(T), "The get method with given type is not implemented by the simdjson library. "
194  "The supported types are ondemand::object, ondemand::array, raw_json_string, std::string_view, uint64_t, "
195  "int64_t, double, and bool. We recommend you use get_double(), get_bool(), get_uint64(), get_int64(), "
196  " get_object(), get_array(), get_raw_json_string(), or get_string() instead of the get template.");
197  }
198 
210  template<typename T> simdjson_inline error_code get(T &out) & noexcept;
212  template<typename T> simdjson_inline error_code get(T &out) && noexcept;
213 
214 #if SIMDJSON_EXCEPTIONS
221  simdjson_inline operator array() & noexcept(false);
228  simdjson_inline operator object() & noexcept(false);
235  simdjson_inline operator uint64_t() noexcept(false);
242  simdjson_inline operator int64_t() noexcept(false);
249  simdjson_inline operator double() noexcept(false);
259  simdjson_inline operator std::string_view() noexcept(false);
268  simdjson_inline operator raw_json_string() noexcept(false);
275  simdjson_inline operator bool() noexcept(false);
287  simdjson_inline operator value() noexcept(false);
288 #endif
300  simdjson_inline simdjson_result<size_t> count_elements() & noexcept;
315  simdjson_inline simdjson_result<size_t> count_fields() & noexcept;
323  simdjson_inline simdjson_result<value> at(size_t index) & noexcept;
329  simdjson_inline simdjson_result<array_iterator> begin() & noexcept;
335  simdjson_inline simdjson_result<array_iterator> end() & noexcept;
336 
369  simdjson_inline simdjson_result<value> find_field(std::string_view key) & noexcept;
371  simdjson_inline simdjson_result<value> find_field(const char *key) & noexcept;
372 
403  simdjson_inline simdjson_result<value> find_field_unordered(std::string_view key) & noexcept;
405  simdjson_inline simdjson_result<value> find_field_unordered(const char *key) & noexcept;
407  simdjson_inline simdjson_result<value> operator[](std::string_view key) & noexcept;
409  simdjson_inline simdjson_result<value> operator[](const char *key) & noexcept;
410 
422  simdjson_inline simdjson_result<json_type> type() noexcept;
423 
431  simdjson_inline simdjson_result<bool> is_scalar() noexcept;
432 
438  simdjson_inline bool is_negative() noexcept;
448  simdjson_inline simdjson_result<bool> is_integer() noexcept;
471  simdjson_inline simdjson_result<number_type> get_number_type() noexcept;
472 
499  simdjson_warn_unused simdjson_inline simdjson_result<number> get_number() noexcept;
500 
523  simdjson_inline simdjson_result<std::string_view> raw_json_token() noexcept;
524 
530  inline void rewind() noexcept;
534  inline std::string to_debug_string() noexcept;
539  inline bool is_alive() noexcept;
540 
544  inline simdjson_result<const char *> current_location() const noexcept;
545 
551  inline bool at_end() const noexcept;
552 
562  simdjson_inline int32_t current_depth() const noexcept;
563 
595  simdjson_inline simdjson_result<value> at_pointer(std::string_view json_pointer) noexcept;
601  simdjson_inline simdjson_result<std::string_view> raw_json() noexcept;
602 protected:
606  simdjson_inline error_code consume() noexcept;
607 
608  simdjson_inline document(ondemand::json_iterator &&iter) noexcept;
609  simdjson_inline const uint8_t *text(uint32_t idx) const noexcept;
610 
611  simdjson_inline value_iterator resume_value_iterator() noexcept;
612  simdjson_inline value_iterator get_root_value_iterator() noexcept;
613  simdjson_inline simdjson_result<object> start_or_resume_object() noexcept;
614  static simdjson_inline document start(ondemand::json_iterator &&iter) noexcept;
615 
616  //
617  // Fields
618  //
619  json_iterator iter{};
620  static constexpr depth_t DOCUMENT_DEPTH = 0;
621 
622  friend class array_iterator;
623  friend class value;
624  friend class ondemand::parser;
625  friend class object;
626  friend class array;
627  friend class field;
628  friend class token;
629  friend class document_stream;
630  friend class document_reference;
631 };
632 
633 
638 public:
639  simdjson_inline document_reference() noexcept;
640  simdjson_inline document_reference(document &d) noexcept;
641  simdjson_inline document_reference(const document_reference &other) noexcept = default;
642  simdjson_inline document_reference& operator=(const document_reference &other) noexcept = default;
643  simdjson_inline void rewind() noexcept;
644  simdjson_inline simdjson_result<array> get_array() & noexcept;
645  simdjson_inline simdjson_result<object> get_object() & noexcept;
646  simdjson_inline simdjson_result<uint64_t> get_uint64() noexcept;
647  simdjson_inline simdjson_result<uint64_t> get_uint64_in_string() noexcept;
648  simdjson_inline simdjson_result<int64_t> get_int64() noexcept;
649  simdjson_inline simdjson_result<int64_t> get_int64_in_string() noexcept;
650  simdjson_inline simdjson_result<double> get_double() noexcept;
651  simdjson_inline simdjson_result<double> get_double_in_string() noexcept;
652  simdjson_inline simdjson_result<std::string_view> get_string(bool allow_replacement = false) noexcept;
653  template <typename string_type>
654  simdjson_inline error_code get_string(string_type& receiver, bool allow_replacement = false) noexcept;
655  simdjson_inline simdjson_result<std::string_view> get_wobbly_string() noexcept;
656  simdjson_inline simdjson_result<raw_json_string> get_raw_json_string() noexcept;
657  simdjson_inline simdjson_result<bool> get_bool() noexcept;
658  simdjson_inline simdjson_result<value> get_value() noexcept;
659 
660  simdjson_inline simdjson_result<bool> is_null() noexcept;
661  simdjson_inline simdjson_result<std::string_view> raw_json() noexcept;
662  simdjson_inline operator document&() const noexcept;
663 
664 #if SIMDJSON_EXCEPTIONS
665  simdjson_inline operator array() & noexcept(false);
666  simdjson_inline operator object() & noexcept(false);
667  simdjson_inline operator uint64_t() noexcept(false);
668  simdjson_inline operator int64_t() noexcept(false);
669  simdjson_inline operator double() noexcept(false);
670  simdjson_inline operator std::string_view() noexcept(false);
671  simdjson_inline operator raw_json_string() noexcept(false);
672  simdjson_inline operator bool() noexcept(false);
673  simdjson_inline operator value() noexcept(false);
674 #endif
675  simdjson_inline simdjson_result<size_t> count_elements() & noexcept;
676  simdjson_inline simdjson_result<size_t> count_fields() & noexcept;
677  simdjson_inline simdjson_result<value> at(size_t index) & noexcept;
678  simdjson_inline simdjson_result<array_iterator> begin() & noexcept;
679  simdjson_inline simdjson_result<array_iterator> end() & noexcept;
680  simdjson_inline simdjson_result<value> find_field(std::string_view key) & noexcept;
681  simdjson_inline simdjson_result<value> find_field(const char *key) & noexcept;
682  simdjson_inline simdjson_result<value> operator[](std::string_view key) & noexcept;
683  simdjson_inline simdjson_result<value> operator[](const char *key) & noexcept;
684  simdjson_inline simdjson_result<value> find_field_unordered(std::string_view key) & noexcept;
685  simdjson_inline simdjson_result<value> find_field_unordered(const char *key) & noexcept;
686 
687  simdjson_inline simdjson_result<json_type> type() noexcept;
688  simdjson_inline simdjson_result<bool> is_scalar() noexcept;
689 
690  simdjson_inline simdjson_result<const char *> current_location() noexcept;
691  simdjson_inline int32_t current_depth() const noexcept;
692  simdjson_inline bool is_negative() noexcept;
693  simdjson_inline simdjson_result<bool> is_integer() noexcept;
694  simdjson_inline simdjson_result<number_type> get_number_type() noexcept;
695  simdjson_inline simdjson_result<number> get_number() noexcept;
696  simdjson_inline simdjson_result<std::string_view> raw_json_token() noexcept;
697  simdjson_inline simdjson_result<value> at_pointer(std::string_view json_pointer) noexcept;
698 private:
699  document *doc{nullptr};
700 };
701 } // namespace ondemand
702 } // namespace SIMDJSON_IMPLEMENTATION
703 } // namespace simdjson
704 
705 namespace simdjson {
706 
707 template<>
708 struct simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document> : public SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::document> {
709 public:
711  simdjson_inline simdjson_result(error_code error) noexcept;
712  simdjson_inline simdjson_result() noexcept = default;
713  simdjson_inline error_code rewind() noexcept;
714 
715  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array> get_array() & noexcept;
716  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object> get_object() & noexcept;
717  simdjson_inline simdjson_result<uint64_t> get_uint64() noexcept;
718  simdjson_inline simdjson_result<uint64_t> get_uint64_in_string() noexcept;
719  simdjson_inline simdjson_result<int64_t> get_int64() noexcept;
720  simdjson_inline simdjson_result<int64_t> get_int64_in_string() noexcept;
721  simdjson_inline simdjson_result<double> get_double() noexcept;
722  simdjson_inline simdjson_result<double> get_double_in_string() noexcept;
723  simdjson_inline simdjson_result<std::string_view> get_string(bool allow_replacement = false) noexcept;
724  template <typename string_type>
725  simdjson_inline error_code get_string(string_type& receiver, bool allow_replacement = false) noexcept;
726  simdjson_inline simdjson_result<std::string_view> get_wobbly_string() noexcept;
727  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string> get_raw_json_string() noexcept;
728  simdjson_inline simdjson_result<bool> get_bool() noexcept;
729  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> get_value() noexcept;
730  simdjson_inline simdjson_result<bool> is_null() noexcept;
731 
732  template<typename T> simdjson_inline simdjson_result<T> get() & noexcept;
733  template<typename T> simdjson_inline simdjson_result<T> get() && noexcept;
734 
735  template<typename T> simdjson_inline error_code get(T &out) & noexcept;
736  template<typename T> simdjson_inline error_code get(T &out) && noexcept;
737 
738 #if SIMDJSON_EXCEPTIONS
739  simdjson_inline operator SIMDJSON_IMPLEMENTATION::ondemand::array() & noexcept(false);
740  simdjson_inline operator SIMDJSON_IMPLEMENTATION::ondemand::object() & noexcept(false);
741  simdjson_inline operator uint64_t() noexcept(false);
742  simdjson_inline operator int64_t() noexcept(false);
743  simdjson_inline operator double() noexcept(false);
744  simdjson_inline operator std::string_view() noexcept(false);
745  simdjson_inline operator SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string() noexcept(false);
746  simdjson_inline operator bool() noexcept(false);
747  simdjson_inline operator SIMDJSON_IMPLEMENTATION::ondemand::value() noexcept(false);
748 #endif
749  simdjson_inline simdjson_result<size_t> count_elements() & noexcept;
750  simdjson_inline simdjson_result<size_t> count_fields() & noexcept;
751  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> at(size_t index) & noexcept;
754  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> find_field(std::string_view key) & noexcept;
755  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> find_field(const char *key) & noexcept;
756  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> operator[](std::string_view key) & noexcept;
757  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> operator[](const char *key) & noexcept;
758  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> find_field_unordered(std::string_view key) & noexcept;
759  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> find_field_unordered(const char *key) & noexcept;
761  simdjson_inline simdjson_result<bool> is_scalar() noexcept;
762  simdjson_inline simdjson_result<const char *> current_location() noexcept;
763  simdjson_inline int32_t current_depth() const noexcept;
764  simdjson_inline bool at_end() const noexcept;
765  simdjson_inline bool is_negative() noexcept;
766  simdjson_inline simdjson_result<bool> is_integer() noexcept;
767  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::number_type> get_number_type() noexcept;
768  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::number> get_number() noexcept;
770  simdjson_inline simdjson_result<std::string_view> raw_json_token() noexcept;
771 
772  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> at_pointer(std::string_view json_pointer) noexcept;
773 };
774 
775 
776 } // namespace simdjson
777 
778 
779 
780 namespace simdjson {
781 
782 template<>
783 struct simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference> : public SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::document_reference> {
784 public:
786  simdjson_inline simdjson_result() noexcept = default;
787  simdjson_inline error_code rewind() noexcept;
788 
789  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array> get_array() & noexcept;
790  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object> get_object() & noexcept;
791  simdjson_inline simdjson_result<uint64_t> get_uint64() noexcept;
792  simdjson_inline simdjson_result<uint64_t> get_uint64_in_string() noexcept;
793  simdjson_inline simdjson_result<int64_t> get_int64() noexcept;
794  simdjson_inline simdjson_result<int64_t> get_int64_in_string() noexcept;
795  simdjson_inline simdjson_result<double> get_double() noexcept;
796  simdjson_inline simdjson_result<double> get_double_in_string() noexcept;
797  simdjson_inline simdjson_result<std::string_view> get_string(bool allow_replacement = false) noexcept;
798  template <typename string_type>
799  simdjson_inline error_code get_string(string_type& receiver, bool allow_replacement = false) noexcept;
800  simdjson_inline simdjson_result<std::string_view> get_wobbly_string() noexcept;
801  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string> get_raw_json_string() noexcept;
802  simdjson_inline simdjson_result<bool> get_bool() noexcept;
803  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> get_value() noexcept;
804  simdjson_inline simdjson_result<bool> is_null() noexcept;
805 
806 #if SIMDJSON_EXCEPTIONS
807  simdjson_inline operator SIMDJSON_IMPLEMENTATION::ondemand::array() & noexcept(false);
808  simdjson_inline operator SIMDJSON_IMPLEMENTATION::ondemand::object() & noexcept(false);
809  simdjson_inline operator uint64_t() noexcept(false);
810  simdjson_inline operator int64_t() noexcept(false);
811  simdjson_inline operator double() noexcept(false);
812  simdjson_inline operator std::string_view() noexcept(false);
813  simdjson_inline operator SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string() noexcept(false);
814  simdjson_inline operator bool() noexcept(false);
815  simdjson_inline operator SIMDJSON_IMPLEMENTATION::ondemand::value() noexcept(false);
816 #endif
817  simdjson_inline simdjson_result<size_t> count_elements() & noexcept;
818  simdjson_inline simdjson_result<size_t> count_fields() & noexcept;
819  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> at(size_t index) & noexcept;
822  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> find_field(std::string_view key) & noexcept;
823  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> find_field(const char *key) & noexcept;
824  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> operator[](std::string_view key) & noexcept;
825  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> operator[](const char *key) & noexcept;
826  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> find_field_unordered(std::string_view key) & noexcept;
827  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> find_field_unordered(const char *key) & noexcept;
829  simdjson_inline simdjson_result<bool> is_scalar() noexcept;
830  simdjson_inline simdjson_result<const char *> current_location() noexcept;
831  simdjson_inline simdjson_result<int32_t> current_depth() const noexcept;
832  simdjson_inline simdjson_result<bool> is_negative() noexcept;
833  simdjson_inline simdjson_result<bool> is_integer() noexcept;
834  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::number_type> get_number_type() noexcept;
835  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::number> get_number() noexcept;
837  simdjson_inline simdjson_result<std::string_view> raw_json_token() noexcept;
838 
839  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> at_pointer(std::string_view json_pointer) noexcept;
840 };
841 
842 
843 } // namespace simdjson
844 
845 #endif // SIMDJSON_GENERIC_ONDEMAND_DOCUMENT_H
A document_reference is a thin wrapper around a document reference instance.
Definition: document.h:637
simdjson_inline simdjson_result< uint64_t > get_uint64() noexcept
The document_reference instances are used primarily/solely for streams of JSON documents.
Definition: document-inl.h:598
simdjson_inline simdjson_result< value > at(size_t index) &noexcept
Get the value at the given index in the array.
Definition: document-inl.h:209
static constexpr depth_t DOCUMENT_DEPTH
document depth is always 0
Definition: document.h:620
simdjson_inline int32_t current_depth() const noexcept
Returns the current depth in the document if in bounds.
Definition: document-inl.h:43
simdjson_inline simdjson_result< array_iterator > begin() &noexcept
Begin array iteration.
Definition: document-inl.h:213
simdjson_inline simdjson_result< size_t > count_fields() &noexcept
This method scans the object and counts the number of key-value pairs.
Definition: document-inl.h:202
simdjson_inline simdjson_result< std::string_view > get_string(bool allow_replacement=false) noexcept
Cast this JSON value to a string.
Definition: document-inl.h:138
simdjson_warn_unused simdjson_inline simdjson_result< number > get_number() noexcept
Attempt to parse an ondemand::number.
Definition: document-inl.h:280
bool is_alive() noexcept
Some unrecoverable error conditions may render the document instance unusable.
Definition: document-inl.h:52
simdjson_inline simdjson_result< bool > get_bool() noexcept
Cast this JSON value to a bool.
Definition: document-inl.h:151
simdjson_inline simdjson_result< object > get_object() &noexcept
Cast this JSON value to an object.
Definition: document-inl.h:107
simdjson_inline simdjson_result< uint64_t > get_uint64() noexcept
Cast this JSON value to an unsigned integer.
Definition: document-inl.h:120
simdjson_inline bool is_negative() noexcept
Checks whether the document is a negative number.
Definition: document-inl.h:268
simdjson_inline document() noexcept=default
Create a new invalid document.
simdjson_inline simdjson_result< std::string_view > raw_json_token() noexcept
Get the raw JSON for this token.
Definition: document-inl.h:285
simdjson_inline simdjson_result< uint64_t > get_uint64_in_string() noexcept
Cast this JSON value (inside string) to an unsigned integer.
Definition: document-inl.h:123
simdjson_inline simdjson_result< bool > is_null() noexcept
Checks if this JSON value is null.
Definition: document-inl.h:154
simdjson_inline simdjson_result< int64_t > get_int64() noexcept
Cast this JSON value to a signed integer.
Definition: document-inl.h:126
simdjson_inline simdjson_result< value > at_pointer(std::string_view json_pointer) noexcept
Get the value associated with the given JSON pointer.
Definition: document-inl.h:290
simdjson_inline simdjson_result< json_type > type() noexcept
Get the type of this JSON value.
Definition: document-inl.h:257
simdjson_inline simdjson_result< array_iterator > end() &noexcept
Sentinel representing the end of the array.
Definition: document-inl.h:216
simdjson_inline simdjson_result< T > get() &noexcept
Get this value as the given type.
Definition: document.h:181
simdjson_inline simdjson_result< double > get_double_in_string() noexcept
Cast this JSON value (inside string) to a double.
Definition: document-inl.h:135
json_iterator iter
Current position in the document.
Definition: document.h:619
simdjson_inline simdjson_result< double > get_double() noexcept
Cast this JSON value to a double.
Definition: document-inl.h:132
std::string to_debug_string() noexcept
Returns debugging information.
Definition: document-inl.h:35
void rewind() noexcept
Reset the iterator inside the document instance so we are pointing back at the beginning of the docum...
Definition: document-inl.h:31
simdjson_inline simdjson_result< std::string_view > raw_json() noexcept
Consumes the document and returns a string_view instance corresponding to the document as represented...
Definition: document-inl.h:245
simdjson_inline simdjson_result< value > find_field_unordered(std::string_view key) &noexcept
Look up a field by name on an object, without regard to key order.
Definition: document-inl.h:226
simdjson_inline simdjson_result< int64_t > get_int64_in_string() noexcept
Cast this JSON value (inside string) to a signed integer.
Definition: document-inl.h:129
simdjson_inline simdjson_result< size_t > count_elements() &noexcept
This method scans the array and counts the number of elements.
Definition: document-inl.h:195
simdjson_inline simdjson_result< value > get_value() noexcept
Cast this JSON value to a value when the document is an object or an array.
Definition: document-inl.h:68
simdjson_inline simdjson_result< value > find_field(std::string_view key) &noexcept
Look up a field by name on an object (order-sensitive).
Definition: document-inl.h:220
simdjson_inline simdjson_result< number_type > get_number_type() noexcept
Determine the number type (integer or floating-point number) as quickly as possible.
Definition: document-inl.h:276
simdjson_inline error_code consume() noexcept
Consumes the document.
Definition: document-inl.h:239
simdjson_inline simdjson_result< bool > is_scalar() noexcept
Checks whether the document is a scalar (string, number, null, Boolean).
Definition: document-inl.h:261
simdjson_inline simdjson_result< std::string_view > get_wobbly_string() noexcept
Cast this JSON value to a string.
Definition: document-inl.h:145
bool at_end() const noexcept
Returns true if this document has been fully parsed.
Definition: document-inl.h:47
simdjson_inline simdjson_result< array > get_array() &noexcept
Cast this JSON value to an array.
Definition: document-inl.h:103
simdjson_inline error_code get(T &out) &noexcept
Get this value as the given type.
simdjson_inline simdjson_result< bool > is_integer() noexcept
Checks whether the document is an integer number.
Definition: document-inl.h:272
simdjson_result< const char * > current_location() const noexcept
Returns the current location in the document if in bounds.
Definition: document-inl.h:39
simdjson_inline simdjson_result< raw_json_string > get_raw_json_string() noexcept
Cast this JSON value to a raw_json_string.
Definition: document-inl.h:148
A JSON field (key/value pair) in an object.
Definition: field.h:22
A forward-only JSON object field iterator.
Definition: object.h:17
A string escaped per JSON rules, terminated with quote (").
An ephemeral JSON value returned during iteration.
Definition: value.h:18
int32_t depth_t
Represents the depth of a JSON value (number of nested arrays/objects).
Definition: base.h:18
The top level simdjson namespace, containing everything the library provides.
Definition: base.h:8
error_code
All possible errors returned by simdjson.
Definition: error.h:19
A type representing a JSON number.
Definition: json_type.h:32
The result of a simdjson operation that could fail.
Definition: error.h:214
simdjson_inline error_code error() const noexcept
The error.
Definition: error-inl.h:131
simdjson_warn_unused simdjson_inline error_code get(T &value) &&noexcept
Move the value to the provided variable.
Definition: error-inl.h:126
simdjson_inline T & value() &noexcept(false)
Get the result value.