3 #ifndef SIMDJSON_PARSEDJSON_ITERATOR_H
4 #define SIMDJSON_PARSEDJSON_ITERATOR_H
13 #include "simdjson/document.h"
14 #include "simdjson/parsedjson.h"
15 #include "simdjson/internal/jsonformatutils.h"
19 class [[deprecated("Use the new DOM navigation API instead (see doc/usage.md)")]] dom::
parser::Iterator {
25 inline bool is_ok()
const;
28 inline size_t get_tape_location()
const;
31 inline size_t get_tape_length()
const;
35 inline size_t get_depth()
const;
39 inline uint8_t get_scope_type()
const;
42 inline bool move_forward();
46 inline uint8_t get_type()
const {
51 inline int64_t get_integer()
const {
52 if (location + 1 >= tape_length) {
55 return static_cast<int64_t
>(doc.tape[location + 1]);
59 inline uint64_t get_unsigned_integer()
const {
60 if (location + 1 >= tape_length) {
63 return doc.tape[location + 1];
70 inline const char *get_string()
const {
71 return reinterpret_cast<const char *
>(
72 doc.string_buf.get() + (current_val & internal::JSON_VALUE_MASK) +
sizeof(uint32_t));
76 inline uint32_t get_string_length()
const {
79 reinterpret_cast<const char *
>(doc.string_buf.get() +
80 (current_val & internal::JSON_VALUE_MASK)),
87 inline double get_double()
const {
88 if (location + 1 >= tape_length) {
89 return std::numeric_limits<double>::quiet_NaN();
93 memcpy(&answer, &doc.tape[location + 1],
sizeof(answer));
97 inline bool is_object_or_array()
const {
return is_object() || is_array(); }
99 inline bool is_object()
const {
return get_type() ==
'{'; }
101 inline bool is_array()
const {
return get_type() ==
'['; }
103 inline bool is_string()
const {
return get_type() ==
'"'; }
107 inline bool is_integer()
const {
return get_type() ==
'l'; }
117 inline bool is_unsigned_integer()
const {
return get_type() ==
'u'; }
119 inline bool is_double()
const {
return get_type() ==
'd'; }
121 inline bool is_number()
const {
122 return is_integer() || is_unsigned_integer() || is_double();
125 inline bool is_true()
const {
return get_type() ==
't'; }
127 inline bool is_false()
const {
return get_type() ==
'f'; }
129 inline bool is_null()
const {
return get_type() ==
'n'; }
131 static bool is_object_or_array(uint8_t type) {
132 return ((type ==
'[') || (type ==
'{'));
144 inline bool move_to_key(
const char *key);
147 inline bool move_to_key_insensitive(
const char *key);
156 inline bool move_to_key(
const char *key, uint32_t length);
161 inline void move_to_value();
166 inline bool move_to_index(uint32_t index);
178 inline bool move_to(
const char *pointer, uint32_t length);
189 inline bool move_to(
const std::string &pointer) {
190 return move_to(pointer.c_str(), pointer.length());
201 inline bool relative_move_to(
const char *pointer, uint32_t length);
237 inline void to_start_scope();
239 inline void rewind() {
248 inline bool print(std::ostream &os,
bool escape_strings =
true)
const;
250 size_t start_of_scope;
260 uint8_t current_type;
261 uint64_t current_val;