@@ -12,43 +12,46 @@ simdjson_really_inline document document::start(json_iterator &&iter) noexcept {
12
12
return document (std::forward<json_iterator>(iter));
13
13
}
14
14
15
- simdjson_really_inline value document::as_value () noexcept {
16
- return as_value_iterator ( );
15
+ simdjson_really_inline value_iterator document::resume_value_iterator () noexcept {
16
+ return value_iterator (&iter, 1 , iter. root_checkpoint () );
17
17
}
18
- simdjson_really_inline value_iterator document::as_value_iterator () noexcept {
18
+ simdjson_really_inline value_iterator document::get_root_value_iterator () noexcept {
19
19
iter.assert_at_root ();
20
- return value_iterator (&iter, 1 , iter. root_checkpoint () );
20
+ return resume_value_iterator ( );
21
21
}
22
- simdjson_really_inline value_iterator document::as_non_root_value_iterator () noexcept {
23
- return value_iterator (&iter, 1 , iter.root_checkpoint ());
22
+ simdjson_really_inline value document::resume_value () noexcept {
23
+ return resume_value_iterator ();
24
+ }
25
+ simdjson_really_inline value document::get_root_value () noexcept {
26
+ return get_root_value_iterator ();
24
27
}
25
28
26
29
simdjson_really_inline simdjson_result<array> document::get_array () & noexcept {
27
- return as_value ().get_array ();
30
+ return get_root_value ().get_array ();
28
31
}
29
32
simdjson_really_inline simdjson_result<object> document::get_object () & noexcept {
30
- return as_value ().get_object ();
33
+ return get_root_value ().get_object ();
31
34
}
32
35
simdjson_really_inline simdjson_result<uint64_t > document::get_uint64 () noexcept {
33
- return as_value_iterator ().require_root_uint64 ();
36
+ return get_root_value_iterator ().require_root_uint64 ();
34
37
}
35
38
simdjson_really_inline simdjson_result<int64_t > document::get_int64 () noexcept {
36
- return as_value_iterator ().require_root_int64 ();
39
+ return get_root_value_iterator ().require_root_int64 ();
37
40
}
38
41
simdjson_really_inline simdjson_result<double > document::get_double () noexcept {
39
- return as_value_iterator ().require_root_double ();
42
+ return get_root_value_iterator ().require_root_double ();
40
43
}
41
44
simdjson_really_inline simdjson_result<std::string_view> document::get_string () & noexcept {
42
- return as_value ().get_string ();
45
+ return get_root_value ().get_string ();
43
46
}
44
47
simdjson_really_inline simdjson_result<raw_json_string> document::get_raw_json_string () & noexcept {
45
- return as_value ().get_raw_json_string ();
48
+ return get_root_value ().get_raw_json_string ();
46
49
}
47
50
simdjson_really_inline simdjson_result<bool > document::get_bool () noexcept {
48
- return as_value_iterator ().require_root_bool ();
51
+ return get_root_value_iterator ().require_root_bool ();
49
52
}
50
53
simdjson_really_inline bool document::is_null () noexcept {
51
- return as_value_iterator ().is_root_null ();
54
+ return get_root_value_iterator ().is_root_null ();
52
55
}
53
56
54
57
template <> simdjson_really_inline simdjson_result<array> document::get () & noexcept { return get_array (); }
@@ -89,21 +92,24 @@ simdjson_really_inline simdjson_result<array_iterator> document::begin() & noexc
89
92
simdjson_really_inline simdjson_result<array_iterator> document::end () & noexcept {
90
93
return {};
91
94
}
95
+
96
+ simdjson_really_inline simdjson_result<value> document::find_field (std::string_view key) & noexcept {
97
+ return resume_value ().find_field (key);
98
+ }
99
+ simdjson_really_inline simdjson_result<value> document::find_field (const char *key) & noexcept {
100
+ return resume_value ().find_field (key);
101
+ }
102
+ simdjson_really_inline simdjson_result<value> document::find_field_unordered (std::string_view key) & noexcept {
103
+ return resume_value ().find_field_unordered (key);
104
+ }
105
+ simdjson_really_inline simdjson_result<value> document::find_field_unordered (const char *key) & noexcept {
106
+ return resume_value ().find_field_unordered (key);
107
+ }
92
108
simdjson_really_inline simdjson_result<value> document::operator [](std::string_view key) & noexcept {
93
- if (iter.at_root ()) {
94
- return get_object ()[key];
95
- } else {
96
- // If we're not at the root, this is not the first key we've grabbed
97
- return object::resume (as_non_root_value_iterator ())[key];
98
- }
109
+ return resume_value ()[key];
99
110
}
100
111
simdjson_really_inline simdjson_result<value> document::operator [](const char *key) & noexcept {
101
- if (iter.at_root ()) {
102
- return get_object ()[key];
103
- } else {
104
- // If we're not at the root, this is not the first key we've grabbed
105
- return object::resume (as_non_root_value_iterator ())[key];
106
- }
112
+ return resume_value ()[key];
107
113
}
108
114
109
115
} // namespace ondemand
@@ -136,6 +142,14 @@ simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_
136
142
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::end() & noexcept {
137
143
return {};
138
144
}
145
+ simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::find_field_unordered(std::string_view key) & noexcept {
146
+ if (error ()) { return error (); }
147
+ return first.find_field_unordered (key);
148
+ }
149
+ simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::find_field_unordered(const char *key) & noexcept {
150
+ if (error ()) { return error (); }
151
+ return first.find_field_unordered (key);
152
+ }
139
153
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::operator [](std::string_view key) & noexcept {
140
154
if (error ()) { return error (); }
141
155
return first[key];
@@ -144,6 +158,14 @@ simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>
144
158
if (error ()) { return error (); }
145
159
return first[key];
146
160
}
161
+ simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::find_field(std::string_view key) & noexcept {
162
+ if (error ()) { return error (); }
163
+ return first.find_field (key);
164
+ }
165
+ simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::find_field(const char *key) & noexcept {
166
+ if (error ()) { return error (); }
167
+ return first.find_field (key);
168
+ }
147
169
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_array() & noexcept {
148
170
if (error ()) { return error (); }
149
171
return first.get_array ();
0 commit comments