@@ -5,54 +5,54 @@ namespace ondemand {
5
5
//
6
6
// ### Live States
7
7
//
8
- // While iterating or looking up values, depth >= doc->iter. depth. at_start may vary. Error is
8
+ // While iterating or looking up values, depth >= iter-> depth. at_start may vary. Error is
9
9
// always SUCCESS:
10
10
//
11
11
// - Start: This is the state when the array is first found and the iterator is just past the `{`.
12
12
// In this state, at_start == true.
13
13
// - Next: After we hand a scalar value to the user, or an array/object which they then fully
14
14
// iterate over, the iterator is at the `,` before the next value (or `]`). In this state,
15
- // depth == doc->iter. depth, at_start == false, and error == SUCCESS.
15
+ // depth == iter-> depth, at_start == false, and error == SUCCESS.
16
16
// - Unfinished Business: When we hand an array/object to the user which they do not fully
17
17
// iterate over, we need to finish that iteration by skipping child values until we reach the
18
- // Next state. In this state, depth > doc->iter. depth, at_start == false, and error == SUCCESS.
18
+ // Next state. In this state, depth > iter-> depth, at_start == false, and error == SUCCESS.
19
19
//
20
20
// ## Error States
21
21
//
22
- // In error states, we will yield exactly one more value before stopping. doc->iter. depth == depth
22
+ // In error states, we will yield exactly one more value before stopping. iter-> depth == depth
23
23
// and at_start is always false. We decrement after yielding the error, moving to the Finished
24
24
// state.
25
25
//
26
26
// - Chained Error: When the array iterator is part of an error chain--for example, in
27
27
// `for (auto tweet : doc["tweets"])`, where the tweet element may be missing or not be an
28
28
// array--we yield that error in the loop, exactly once. In this state, error != SUCCESS and
29
- // doc->iter. depth == depth, and at_start == false. We decrement depth when we yield the error.
29
+ // iter-> depth == depth, and at_start == false. We decrement depth when we yield the error.
30
30
// - Missing Comma Error: When the iterator ++ method discovers there is no comma between elements,
31
31
// we flag that as an error and treat it exactly the same as a Chained Error. In this state,
32
- // error == TAPE_ERROR, doc->iter. depth == depth, and at_start == false.
32
+ // error == TAPE_ERROR, iter-> depth == depth, and at_start == false.
33
33
//
34
34
// ## Terminal State
35
35
//
36
- // The terminal state has doc->iter. depth < depth. at_start is always false.
36
+ // The terminal state has iter-> depth < depth. at_start is always false.
37
37
//
38
38
// - Finished: When we have reached a `]` or have reported an error, we are finished. We signal this
39
- // by decrementing depth. In this state, doc->iter. depth < depth, at_start == false, and
39
+ // by decrementing depth. In this state, iter-> depth < depth, at_start == false, and
40
40
// error == SUCCESS.
41
41
//
42
42
43
43
simdjson_really_inline array::array () noexcept = default;
44
- simdjson_really_inline array::array (document *_doc , bool has_value) noexcept
45
- : doc{_doc }, has_next{has_value}, error{SUCCESS}
44
+ simdjson_really_inline array::array (json_iterator *_iter , bool has_value) noexcept
45
+ : iter{_iter }, has_next{has_value}, error{SUCCESS}
46
46
{
47
47
}
48
48
simdjson_really_inline array::array (array &&other) noexcept
49
- : doc {other.doc }, has_next{other.has_next }, error{other.error }
49
+ : iter {other.iter }, has_next{other.has_next }, error{other.error }
50
50
{
51
51
// Terminate the other iterator
52
52
other.has_next = false ;
53
53
}
54
54
simdjson_really_inline array &array::operator =(array &&other) noexcept {
55
- doc = other.doc ;
55
+ iter = other.iter ;
56
56
has_next = other.has_next ;
57
57
error = other.error ;
58
58
// Terminate the other iterator
@@ -62,18 +62,18 @@ simdjson_really_inline array &array::operator=(array &&other) noexcept {
62
62
63
63
simdjson_really_inline array::~array () noexcept {
64
64
if (!error && has_next) {
65
- logger::log_event (doc-> iter , " unfinished" , " array" );
66
- doc-> iter . skip_container ();
65
+ logger::log_event (* iter, " unfinished" , " array" );
66
+ iter-> skip_container ();
67
67
}
68
68
}
69
69
70
- simdjson_really_inline simdjson_result<array> array::start (document *doc ) noexcept {
70
+ simdjson_really_inline simdjson_result<array> array::start (json_iterator *iter ) noexcept {
71
71
bool has_value;
72
- SIMDJSON_TRY ( doc-> iter . start_array ().get (has_value) );
73
- return array (doc , has_value);
72
+ SIMDJSON_TRY ( iter-> start_array ().get (has_value) );
73
+ return array (iter , has_value);
74
74
}
75
- simdjson_really_inline array array::started (document *doc ) noexcept {
76
- return array (doc, doc-> iter . started_array ());
75
+ simdjson_really_inline array array::started (json_iterator *iter ) noexcept {
76
+ return array (iter, iter-> started_array ());
77
77
}
78
78
simdjson_really_inline array::iterator array::begin () noexcept {
79
79
return *this ;
@@ -96,7 +96,7 @@ simdjson_really_inline array::iterator &array::iterator::operator=(const array::
96
96
97
97
simdjson_really_inline simdjson_result<value> array::iterator::operator *() noexcept {
98
98
if (a->error ) { return a->report_error (); }
99
- return value::start (a->doc );
99
+ return value::start (a->iter );
100
100
}
101
101
simdjson_really_inline bool array::iterator::operator ==(const array::iterator &) noexcept {
102
102
return !a->has_next ;
@@ -106,7 +106,7 @@ simdjson_really_inline bool array::iterator::operator!=(const array::iterator &)
106
106
}
107
107
simdjson_really_inline array::iterator &array::iterator::operator ++() noexcept {
108
108
if (a->error ) { return *this ; }
109
- a->error = a->doc -> iter . has_next_element ().get (a->has_next ); // If there's an error, has_next stays true.
109
+ a->error = a->iter -> has_next_element ().get (a->has_next ); // If there's an error, has_next stays true.
110
110
return *this ;
111
111
}
112
112
@@ -179,12 +179,12 @@ simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>
179
179
if (error ()) { return error (); }
180
180
return *first;
181
181
}
182
- // Assumes it's being compared with the end. true if depth < doc->iter. depth.
182
+ // Assumes it's being compared with the end. true if depth < iter-> depth.
183
183
simdjson_really_inline bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array::iterator>::operator ==(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array::iterator> &other) noexcept {
184
184
if (error ()) { return true ; }
185
185
return first == other.first ;
186
186
}
187
- // Assumes it's being compared with the end. true if depth >= doc->iter. depth.
187
+ // Assumes it's being compared with the end. true if depth >= iter-> depth.
188
188
simdjson_really_inline bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array::iterator>::operator !=(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array::iterator> &other) noexcept {
189
189
if (error ()) { return false ; }
190
190
return first != other.first ;
0 commit comments