simdjson  3.6.3
Ridiculously Fast JSON
token_iterator-inl.h
1 #ifndef SIMDJSON_GENERIC_ONDEMAND_TOKEN_ITERATOR_INL_H
2 
3 #ifndef SIMDJSON_CONDITIONAL_INCLUDE
4 #define SIMDJSON_GENERIC_ONDEMAND_TOKEN_ITERATOR_INL_H
5 #include "simdjson/generic/ondemand/base.h"
6 #include "simdjson/generic/ondemand/token_iterator.h"
7 #include "simdjson/generic/implementation_simdjson_result_base-inl.h"
8 #endif // SIMDJSON_CONDITIONAL_INCLUDE
9 
10 namespace simdjson {
11 namespace SIMDJSON_IMPLEMENTATION {
12 namespace ondemand {
13 
14 simdjson_inline token_iterator::token_iterator(
15  const uint8_t *_buf,
16  token_position position
17 ) noexcept : buf{_buf}, _position{position}
18 {
19 }
20 
21 simdjson_inline uint32_t token_iterator::current_offset() const noexcept {
22  return *(_position);
23 }
24 
25 
26 simdjson_inline const uint8_t *token_iterator::return_current_and_advance() noexcept {
27  return &buf[*(_position++)];
28 }
29 
30 simdjson_inline const uint8_t *token_iterator::peek(token_position position) const noexcept {
31  return &buf[*position];
32 }
33 simdjson_inline uint32_t token_iterator::peek_index(token_position position) const noexcept {
34  return *position;
35 }
36 simdjson_inline uint32_t token_iterator::peek_length(token_position position) const noexcept {
37  return *(position+1) - *position;
38 }
39 
40 simdjson_inline const uint8_t *token_iterator::peek(int32_t delta) const noexcept {
41  return &buf[*(_position+delta)];
42 }
43 simdjson_inline uint32_t token_iterator::peek_index(int32_t delta) const noexcept {
44  return *(_position+delta);
45 }
46 simdjson_inline uint32_t token_iterator::peek_length(int32_t delta) const noexcept {
47  return *(_position+delta+1) - *(_position+delta);
48 }
49 
50 simdjson_inline token_position token_iterator::position() const noexcept {
51  return _position;
52 }
53 simdjson_inline void token_iterator::set_position(token_position target_position) noexcept {
54  _position = target_position;
55 }
56 
57 simdjson_inline bool token_iterator::operator==(const token_iterator &other) const noexcept {
58  return _position == other._position;
59 }
60 simdjson_inline bool token_iterator::operator!=(const token_iterator &other) const noexcept {
61  return _position != other._position;
62 }
63 simdjson_inline bool token_iterator::operator>(const token_iterator &other) const noexcept {
64  return _position > other._position;
65 }
66 simdjson_inline bool token_iterator::operator>=(const token_iterator &other) const noexcept {
67  return _position >= other._position;
68 }
69 simdjson_inline bool token_iterator::operator<(const token_iterator &other) const noexcept {
70  return _position < other._position;
71 }
72 simdjson_inline bool token_iterator::operator<=(const token_iterator &other) const noexcept {
73  return _position <= other._position;
74 }
75 
76 } // namespace ondemand
77 } // namespace SIMDJSON_IMPLEMENTATION
78 } // namespace simdjson
79 
80 namespace simdjson {
81 
82 simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::token_iterator>::simdjson_result(SIMDJSON_IMPLEMENTATION::ondemand::token_iterator &&value) noexcept
83  : implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::token_iterator>(std::forward<SIMDJSON_IMPLEMENTATION::ondemand::token_iterator>(value)) {}
84 simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::token_iterator>::simdjson_result(error_code error) noexcept
85  : implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::token_iterator>(error) {}
86 
87 } // namespace simdjson
88 
89 #endif // SIMDJSON_GENERIC_ONDEMAND_TOKEN_ITERATOR_INL_H
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