simdjson  3.9.1
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 or the user 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  " You may also add support for custom types, see our documentation.");
189  }
191  template<typename T> simdjson_inline simdjson_result<T> get() && noexcept {
192  // Unless the simdjson library or the user provides an inline implementation, calling this method should
193  // immediately fail.
194  static_assert(!sizeof(T), "The get method with given type is not implemented by the simdjson library. "
195  "The supported types are ondemand::object, ondemand::array, raw_json_string, std::string_view, uint64_t, "
196  "int64_t, double, and bool. We recommend you use get_double(), get_bool(), get_uint64(), get_int64(), "
197  " get_object(), get_array(), get_raw_json_string(), or get_string() instead of the get template."
198  " You may also add support for custom types, see our documentation.");
199  }
200 
212  template<typename T> simdjson_inline error_code get(T &out) & noexcept;
214  template<typename T> simdjson_inline error_code get(T &out) && noexcept;
215 
216 #if SIMDJSON_EXCEPTIONS
226  template <class T>
227  explicit simdjson_inline operator T() noexcept(false);
234  simdjson_inline operator array() & noexcept(false);
241  simdjson_inline operator object() & noexcept(false);
248  simdjson_inline operator uint64_t() noexcept(false);
255  simdjson_inline operator int64_t() noexcept(false);
262  simdjson_inline operator double() noexcept(false);
272  simdjson_inline operator std::string_view() noexcept(false);
281  simdjson_inline operator raw_json_string() noexcept(false);
288  simdjson_inline operator bool() noexcept(false);
300  simdjson_inline operator value() noexcept(false);
301 #endif
313  simdjson_inline simdjson_result<size_t> count_elements() & noexcept;
328  simdjson_inline simdjson_result<size_t> count_fields() & noexcept;
336  simdjson_inline simdjson_result<value> at(size_t index) & noexcept;
342  simdjson_inline simdjson_result<array_iterator> begin() & noexcept;
348  simdjson_inline simdjson_result<array_iterator> end() & noexcept;
349 
382  simdjson_inline simdjson_result<value> find_field(std::string_view key) & noexcept;
384  simdjson_inline simdjson_result<value> find_field(const char *key) & noexcept;
385 
416  simdjson_inline simdjson_result<value> find_field_unordered(std::string_view key) & noexcept;
418  simdjson_inline simdjson_result<value> find_field_unordered(const char *key) & noexcept;
420  simdjson_inline simdjson_result<value> operator[](std::string_view key) & noexcept;
422  simdjson_inline simdjson_result<value> operator[](const char *key) & noexcept;
423 
435  simdjson_inline simdjson_result<json_type> type() noexcept;
436 
444  simdjson_inline simdjson_result<bool> is_scalar() noexcept;
445 
452  simdjson_inline simdjson_result<bool> is_string() noexcept;
453 
459  simdjson_inline bool is_negative() noexcept;
469  simdjson_inline simdjson_result<bool> is_integer() noexcept;
494  simdjson_inline simdjson_result<number_type> get_number_type() noexcept;
495 
522  simdjson_warn_unused simdjson_inline simdjson_result<number> get_number() noexcept;
523 
546  simdjson_inline simdjson_result<std::string_view> raw_json_token() noexcept;
547 
553  inline void rewind() noexcept;
557  inline std::string to_debug_string() noexcept;
562  inline bool is_alive() noexcept;
563 
567  inline simdjson_result<const char *> current_location() const noexcept;
568 
574  inline bool at_end() const noexcept;
575 
585  simdjson_inline int32_t current_depth() const noexcept;
586 
626  simdjson_inline simdjson_result<value> at_pointer(std::string_view json_pointer) noexcept;
627 
649  simdjson_inline simdjson_result<value> at_path(std::string_view json_path) noexcept;
650 
656  simdjson_inline simdjson_result<std::string_view> raw_json() noexcept;
657 protected:
661  simdjson_inline error_code consume() noexcept;
662 
663  simdjson_inline document(ondemand::json_iterator &&iter) noexcept;
664  simdjson_inline const uint8_t *text(uint32_t idx) const noexcept;
665 
666  simdjson_inline value_iterator resume_value_iterator() noexcept;
667  simdjson_inline value_iterator get_root_value_iterator() noexcept;
668  simdjson_inline simdjson_result<object> start_or_resume_object() noexcept;
669  static simdjson_inline document start(ondemand::json_iterator &&iter) noexcept;
670 
671  //
672  // Fields
673  //
674  json_iterator iter{};
675  static constexpr depth_t DOCUMENT_DEPTH = 0;
676 
677  friend class array_iterator;
678  friend class value;
679  friend class ondemand::parser;
680  friend class object;
681  friend class array;
682  friend class field;
683  friend class token;
684  friend class document_stream;
685  friend class document_reference;
686 };
687 
688 
693 public:
694  simdjson_inline document_reference() noexcept;
695  simdjson_inline document_reference(document &d) noexcept;
696  simdjson_inline document_reference(const document_reference &other) noexcept = default;
697  simdjson_inline document_reference& operator=(const document_reference &other) noexcept = default;
698  simdjson_inline void rewind() noexcept;
699  simdjson_inline simdjson_result<array> get_array() & noexcept;
700  simdjson_inline simdjson_result<object> get_object() & noexcept;
701  simdjson_inline simdjson_result<uint64_t> get_uint64() noexcept;
702  simdjson_inline simdjson_result<uint64_t> get_uint64_in_string() noexcept;
703  simdjson_inline simdjson_result<int64_t> get_int64() noexcept;
704  simdjson_inline simdjson_result<int64_t> get_int64_in_string() noexcept;
705  simdjson_inline simdjson_result<double> get_double() noexcept;
706  simdjson_inline simdjson_result<double> get_double_in_string() noexcept;
707  simdjson_inline simdjson_result<std::string_view> get_string(bool allow_replacement = false) noexcept;
708  template <typename string_type>
709  simdjson_inline error_code get_string(string_type& receiver, bool allow_replacement = false) noexcept;
710  simdjson_inline simdjson_result<std::string_view> get_wobbly_string() noexcept;
711  simdjson_inline simdjson_result<raw_json_string> get_raw_json_string() noexcept;
712  simdjson_inline simdjson_result<bool> get_bool() noexcept;
713  simdjson_inline simdjson_result<value> get_value() noexcept;
714 
715  simdjson_inline simdjson_result<bool> is_null() noexcept;
716  template<typename T> simdjson_inline simdjson_result<T> get() & noexcept;
717  simdjson_inline simdjson_result<std::string_view> raw_json() noexcept;
718  simdjson_inline operator document&() const noexcept;
719 #if SIMDJSON_EXCEPTIONS
720  template <class T>
721  explicit simdjson_inline operator T() noexcept(false);
722  simdjson_inline operator array() & noexcept(false);
723  simdjson_inline operator object() & noexcept(false);
724  simdjson_inline operator uint64_t() noexcept(false);
725  simdjson_inline operator int64_t() noexcept(false);
726  simdjson_inline operator double() noexcept(false);
727  simdjson_inline operator std::string_view() noexcept(false);
728  simdjson_inline operator raw_json_string() noexcept(false);
729  simdjson_inline operator bool() noexcept(false);
730  simdjson_inline operator value() noexcept(false);
731 #endif
732  simdjson_inline simdjson_result<size_t> count_elements() & noexcept;
733  simdjson_inline simdjson_result<size_t> count_fields() & noexcept;
734  simdjson_inline simdjson_result<value> at(size_t index) & noexcept;
735  simdjson_inline simdjson_result<array_iterator> begin() & noexcept;
736  simdjson_inline simdjson_result<array_iterator> end() & noexcept;
737  simdjson_inline simdjson_result<value> find_field(std::string_view key) & noexcept;
738  simdjson_inline simdjson_result<value> find_field(const char *key) & noexcept;
739  simdjson_inline simdjson_result<value> operator[](std::string_view key) & noexcept;
740  simdjson_inline simdjson_result<value> operator[](const char *key) & noexcept;
741  simdjson_inline simdjson_result<value> find_field_unordered(std::string_view key) & noexcept;
742  simdjson_inline simdjson_result<value> find_field_unordered(const char *key) & noexcept;
743 
744  simdjson_inline simdjson_result<json_type> type() noexcept;
745  simdjson_inline simdjson_result<bool> is_scalar() noexcept;
746  simdjson_inline simdjson_result<bool> is_string() noexcept;
747 
748  simdjson_inline simdjson_result<const char *> current_location() noexcept;
749  simdjson_inline int32_t current_depth() const noexcept;
750  simdjson_inline bool is_negative() noexcept;
751  simdjson_inline simdjson_result<bool> is_integer() noexcept;
752  simdjson_inline simdjson_result<number_type> get_number_type() noexcept;
753  simdjson_inline simdjson_result<number> get_number() noexcept;
754  simdjson_inline simdjson_result<std::string_view> raw_json_token() noexcept;
755  simdjson_inline simdjson_result<value> at_pointer(std::string_view json_pointer) noexcept;
756  simdjson_inline simdjson_result<value> at_path(std::string_view json_path) noexcept;
757 
758 private:
759  document *doc{nullptr};
760 };
761 } // namespace ondemand
762 } // namespace SIMDJSON_IMPLEMENTATION
763 } // namespace simdjson
764 
765 namespace simdjson {
766 
767 template<>
768 struct simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document> : public SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::document> {
769 public:
771  simdjson_inline simdjson_result(error_code error) noexcept;
772  simdjson_inline simdjson_result() noexcept = default;
773  simdjson_inline error_code rewind() noexcept;
774 
775  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array> get_array() & noexcept;
776  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object> get_object() & noexcept;
777  simdjson_inline simdjson_result<uint64_t> get_uint64() noexcept;
778  simdjson_inline simdjson_result<uint64_t> get_uint64_in_string() noexcept;
779  simdjson_inline simdjson_result<int64_t> get_int64() noexcept;
780  simdjson_inline simdjson_result<int64_t> get_int64_in_string() noexcept;
781  simdjson_inline simdjson_result<double> get_double() noexcept;
782  simdjson_inline simdjson_result<double> get_double_in_string() noexcept;
783  simdjson_inline simdjson_result<std::string_view> get_string(bool allow_replacement = false) noexcept;
784  template <typename string_type>
785  simdjson_inline error_code get_string(string_type& receiver, bool allow_replacement = false) noexcept;
786  simdjson_inline simdjson_result<std::string_view> get_wobbly_string() noexcept;
787  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string> get_raw_json_string() noexcept;
788  simdjson_inline simdjson_result<bool> get_bool() noexcept;
789  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> get_value() noexcept;
790  simdjson_inline simdjson_result<bool> is_null() noexcept;
791 
792  template<typename T> simdjson_inline simdjson_result<T> get() & noexcept;
793  template<typename T> simdjson_inline simdjson_result<T> get() && noexcept;
794 
795  template<typename T> simdjson_inline error_code get(T &out) & noexcept;
796  template<typename T> simdjson_inline error_code get(T &out) && noexcept;
797 #if SIMDJSON_EXCEPTIONS
798  template <class T, typename std::enable_if<std::is_same<T, SIMDJSON_IMPLEMENTATION::ondemand::document>::value == false>::type>
799  explicit simdjson_inline operator T() noexcept(false);
800  simdjson_inline operator SIMDJSON_IMPLEMENTATION::ondemand::array() & noexcept(false);
801  simdjson_inline operator SIMDJSON_IMPLEMENTATION::ondemand::object() & noexcept(false);
802  simdjson_inline operator uint64_t() noexcept(false);
803  simdjson_inline operator int64_t() noexcept(false);
804  simdjson_inline operator double() noexcept(false);
805  simdjson_inline operator std::string_view() noexcept(false);
806  simdjson_inline operator SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string() noexcept(false);
807  simdjson_inline operator bool() noexcept(false);
808  simdjson_inline operator SIMDJSON_IMPLEMENTATION::ondemand::value() noexcept(false);
809 #endif
810  simdjson_inline simdjson_result<size_t> count_elements() & noexcept;
811  simdjson_inline simdjson_result<size_t> count_fields() & noexcept;
812  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> at(size_t index) & noexcept;
815  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> find_field(std::string_view key) & noexcept;
816  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> find_field(const char *key) & noexcept;
817  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> operator[](std::string_view key) & noexcept;
818  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> operator[](const char *key) & noexcept;
819  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> find_field_unordered(std::string_view key) & noexcept;
820  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> find_field_unordered(const char *key) & noexcept;
822  simdjson_inline simdjson_result<bool> is_scalar() noexcept;
823  simdjson_inline simdjson_result<bool> is_string() noexcept;
824  simdjson_inline simdjson_result<const char *> current_location() noexcept;
825  simdjson_inline int32_t current_depth() const noexcept;
826  simdjson_inline bool at_end() const noexcept;
827  simdjson_inline bool is_negative() noexcept;
828  simdjson_inline simdjson_result<bool> is_integer() noexcept;
829  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::number_type> get_number_type() noexcept;
830  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::number> get_number() noexcept;
832  simdjson_inline simdjson_result<std::string_view> raw_json_token() noexcept;
833 
834  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> at_pointer(std::string_view json_pointer) noexcept;
835  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> at_path(std::string_view json_path) noexcept;
836 };
837 
838 
839 } // namespace simdjson
840 
841 
842 
843 namespace simdjson {
844 
845 template<>
846 struct simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference> : public SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::document_reference> {
847 public:
849  simdjson_inline simdjson_result() noexcept = default;
850  simdjson_inline error_code rewind() noexcept;
851 
852  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array> get_array() & noexcept;
853  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object> get_object() & noexcept;
854  simdjson_inline simdjson_result<uint64_t> get_uint64() noexcept;
855  simdjson_inline simdjson_result<uint64_t> get_uint64_in_string() noexcept;
856  simdjson_inline simdjson_result<int64_t> get_int64() noexcept;
857  simdjson_inline simdjson_result<int64_t> get_int64_in_string() noexcept;
858  simdjson_inline simdjson_result<double> get_double() noexcept;
859  simdjson_inline simdjson_result<double> get_double_in_string() noexcept;
860  simdjson_inline simdjson_result<std::string_view> get_string(bool allow_replacement = false) noexcept;
861  template <typename string_type>
862  simdjson_inline error_code get_string(string_type& receiver, bool allow_replacement = false) noexcept;
863  simdjson_inline simdjson_result<std::string_view> get_wobbly_string() noexcept;
864  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string> get_raw_json_string() noexcept;
865  simdjson_inline simdjson_result<bool> get_bool() noexcept;
866  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> get_value() noexcept;
867  simdjson_inline simdjson_result<bool> is_null() noexcept;
868 #if SIMDJSON_EXCEPTIONS
869  template <class T, typename std::enable_if<std::is_same<T, SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::value == false>::type>
870  explicit simdjson_inline operator T() noexcept(false);
871  simdjson_inline operator SIMDJSON_IMPLEMENTATION::ondemand::array() & noexcept(false);
872  simdjson_inline operator SIMDJSON_IMPLEMENTATION::ondemand::object() & noexcept(false);
873  simdjson_inline operator uint64_t() noexcept(false);
874  simdjson_inline operator int64_t() noexcept(false);
875  simdjson_inline operator double() noexcept(false);
876  simdjson_inline operator std::string_view() noexcept(false);
877  simdjson_inline operator SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string() noexcept(false);
878  simdjson_inline operator bool() noexcept(false);
879  simdjson_inline operator SIMDJSON_IMPLEMENTATION::ondemand::value() noexcept(false);
880 #endif
881  simdjson_inline simdjson_result<size_t> count_elements() & noexcept;
882  simdjson_inline simdjson_result<size_t> count_fields() & noexcept;
883  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> at(size_t index) & noexcept;
886  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> find_field(std::string_view key) & noexcept;
887  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> find_field(const char *key) & noexcept;
888  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> operator[](std::string_view key) & noexcept;
889  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> operator[](const char *key) & noexcept;
890  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> find_field_unordered(std::string_view key) & noexcept;
891  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> find_field_unordered(const char *key) & noexcept;
893  simdjson_inline simdjson_result<bool> is_scalar() noexcept;
894  simdjson_inline simdjson_result<bool> is_string() noexcept;
895  simdjson_inline simdjson_result<const char *> current_location() noexcept;
896  simdjson_inline simdjson_result<int32_t> current_depth() const noexcept;
897  simdjson_inline simdjson_result<bool> is_negative() noexcept;
898  simdjson_inline simdjson_result<bool> is_integer() noexcept;
899  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::number_type> get_number_type() noexcept;
900  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::number> get_number() noexcept;
902  simdjson_inline simdjson_result<std::string_view> raw_json_token() noexcept;
903 
904  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> at_pointer(std::string_view json_pointer) noexcept;
905  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> at_path(std::string_view json_path) noexcept;
906 };
907 
908 
909 } // namespace simdjson
910 
911 #endif // SIMDJSON_GENERIC_ONDEMAND_DOCUMENT_H
A document_reference is a thin wrapper around a document reference instance.
Definition: document.h:692
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:639
simdjson_inline simdjson_result< value > at(size_t index) &noexcept
Get the value at the given index in the array.
Definition: document-inl.h:213
static constexpr depth_t DOCUMENT_DEPTH
document depth is always 0
Definition: document.h:675
simdjson_inline int32_t current_depth() const noexcept
Returns the current depth in the document if in bounds.
Definition: document-inl.h:45
simdjson_inline simdjson_result< array_iterator > begin() &noexcept
Begin array iteration.
Definition: document-inl.h:217
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:206
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:140
simdjson_warn_unused simdjson_inline simdjson_result< number > get_number() noexcept
Attempt to parse an ondemand::number.
Definition: document-inl.h:291
bool is_alive() noexcept
Some unrecoverable error conditions may render the document instance unusable.
Definition: document-inl.h:54
simdjson_inline simdjson_result< bool > get_bool() noexcept
Cast this JSON value to a bool.
Definition: document-inl.h:153
simdjson_inline simdjson_result< object > get_object() &noexcept
Cast this JSON value to an object.
Definition: document-inl.h:109
simdjson_inline simdjson_result< bool > is_string() noexcept
Checks whether the document is a string.
Definition: document-inl.h:272
simdjson_inline simdjson_result< uint64_t > get_uint64() noexcept
Cast this JSON value to an unsigned integer.
Definition: document-inl.h:122
simdjson_inline bool is_negative() noexcept
Checks whether the document is a negative number.
Definition: document-inl.h:279
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:296
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:125
simdjson_inline simdjson_result< bool > is_null() noexcept
Checks if this JSON value is null.
Definition: document-inl.h:156
simdjson_inline simdjson_result< int64_t > get_int64() noexcept
Cast this JSON value to a signed integer.
Definition: document-inl.h:128
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:301
simdjson_inline simdjson_result< json_type > type() noexcept
Get the type of this JSON value.
Definition: document-inl.h:261
simdjson_inline simdjson_result< array_iterator > end() &noexcept
Sentinel representing the end of the array.
Definition: document-inl.h:220
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:137
simdjson_inline simdjson_result< value > at_path(std::string_view json_path) noexcept
Get the value associated with the given JSONPath expression.
Definition: document-inl.h:319
json_iterator iter
Current position in the document.
Definition: document.h:674
simdjson_inline simdjson_result< double > get_double() noexcept
Cast this JSON value to a double.
Definition: document-inl.h:134
std::string to_debug_string() noexcept
Returns debugging information.
Definition: document-inl.h:37
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:33
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:249
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:230
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:131
simdjson_inline simdjson_result< size_t > count_elements() &noexcept
This method scans the array and counts the number of elements.
Definition: document-inl.h:199
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:70
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:224
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:287
simdjson_inline error_code consume() noexcept
Consumes the document.
Definition: document-inl.h:243
simdjson_inline simdjson_result< bool > is_scalar() noexcept
Checks whether the document is a scalar (string, number, null, Boolean).
Definition: document-inl.h:265
simdjson_inline simdjson_result< std::string_view > get_wobbly_string() noexcept
Cast this JSON value to a string.
Definition: document-inl.h:147
bool at_end() const noexcept
Returns true if this document has been fully parsed.
Definition: document-inl.h:49
simdjson_inline simdjson_result< array > get_array() &noexcept
Cast this JSON value to an array.
Definition: document-inl.h:105
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:283
simdjson_result< const char * > current_location() const noexcept
Returns the current location in the document if in bounds.
Definition: document-inl.h:41
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:150
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:215
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.