@@ -2,22 +2,27 @@ namespace simdjson {
2
2
namespace SIMDJSON_IMPLEMENTATION {
3
3
namespace ondemand {
4
4
5
- simdjson_really_inline array_iterator::array_iterator (json_iterator_ref &_iter) noexcept : iter{&_iter} {}
5
+ template <typename T>
6
+ simdjson_really_inline array_iterator<T>::array_iterator(T &_iter) noexcept : iter{&_iter} {}
6
7
7
- simdjson_really_inline simdjson_result<value> array_iterator::operator *() noexcept {
8
- if ((*iter)->error ()) { iter->release (); return (*iter)->error (); }
9
- return value::start (iter->borrow ());
8
+ template <typename T>
9
+ simdjson_really_inline simdjson_result<value> array_iterator<T>::operator *() noexcept {
10
+ if (iter->get_iterator ().error ()) { iter->iteration_finished (); return iter->get_iterator ().error (); }
11
+ return value::start (iter->borrow_iterator ());
10
12
}
11
- simdjson_really_inline bool array_iterator::operator ==(const array_iterator &other) noexcept {
13
+ template <typename T>
14
+ simdjson_really_inline bool array_iterator<T>::operator ==(const array_iterator<T> &other) noexcept {
12
15
return !(*this != other);
13
16
}
14
- simdjson_really_inline bool array_iterator::operator !=(const array_iterator &) noexcept {
15
- return iter->is_alive ();
17
+ template <typename T>
18
+ simdjson_really_inline bool array_iterator<T>::operator !=(const array_iterator<T> &) noexcept {
19
+ return iter->is_iteration_finished ();
16
20
}
17
- simdjson_really_inline array_iterator &array_iterator::operator ++() noexcept {
21
+ template <typename T>
22
+ simdjson_really_inline array_iterator<T> &array_iterator<T>::operator ++() noexcept {
18
23
bool has_value;
19
- error_code error = (* iter)-> has_next_element ().get (has_value); // If there's an error, has_next stays true.
20
- if (!(error || has_value)) { iter->release (); }
24
+ error_code error = iter-> get_iterator (). has_next_element ().get (has_value); // If there's an error, has_next stays true.
25
+ if (!(error || has_value)) { iter->iteration_finished (); }
21
26
return *this ;
22
27
}
23
28
@@ -27,35 +32,38 @@ simdjson_really_inline array_iterator &array_iterator::operator++() noexcept {
27
32
28
33
namespace simdjson {
29
34
30
- simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>::simdjson_result(
31
- SIMDJSON_IMPLEMENTATION::ondemand::array_iterator &&value
35
+ template <typename T>
36
+ simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator<T>>::simdjson_result(
37
+ SIMDJSON_IMPLEMENTATION::ondemand::array_iterator<T> &&value
32
38
) noexcept
33
- : implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> (std::forward<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>(value))
39
+ : SIMDJSON_IMPLEMENTATION:: implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator<T>> (std::forward<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator<T> >(value))
34
40
{
35
41
}
36
- simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>::simdjson_result(error_code error) noexcept
37
- : implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>({}, error)
42
+ template <typename T>
43
+ simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator<T>>::simdjson_result(error_code error) noexcept
44
+ : SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator<T>>({}, error)
38
45
{
39
46
}
40
47
41
- simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>::operator *() noexcept {
42
- if (error ()) { second = SUCCESS; return error (); }
43
- return *first;
44
- }
45
- // Assumes it's being compared with the end. true if depth < iter->depth.
46
- simdjson_really_inline bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>::operator ==(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> &other) noexcept {
47
- if (error ()) { return true ; }
48
- return first == other.first ;
49
- }
50
- // Assumes it's being compared with the end. true if depth >= iter->depth.
51
- simdjson_really_inline bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>::operator !=(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> &other) noexcept {
52
- if (error ()) { return false ; }
53
- return first != other.first ;
54
- }
55
- // Checks for ']' and ','
56
- simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> &simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>::operator ++() noexcept {
57
- if (error ()) { return *this ; }
58
- ++first;
48
+ template <typename T>
49
+ simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator<T>>::operator *() noexcept {
50
+ if (this ->error ()) { this ->second = SUCCESS; return this ->error (); }
51
+ return *this ->first ;
52
+ }
53
+ template <typename T>
54
+ simdjson_really_inline bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator<T>>::operator ==(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator<T>> &other) noexcept {
55
+ if (this ->error ()) { return true ; }
56
+ return this ->first == other.first ;
57
+ }
58
+ template <typename T>
59
+ simdjson_really_inline bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator<T>>::operator !=(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator<T>> &other) noexcept {
60
+ if (this ->error ()) { return false ; }
61
+ return this ->first != other.first ;
62
+ }
63
+ template <typename T>
64
+ simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator<T>> &simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator<T>>::operator ++() noexcept {
65
+ if (this ->error ()) { return *this ; }
66
+ ++(this ->first );
59
67
return *this ;
60
68
}
61
69
0 commit comments