1 #ifndef SIMDJSON_GENERIC_ONDEMAND_TOKEN_ITERATOR_INL_H
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"
11 namespace SIMDJSON_IMPLEMENTATION {
14 simdjson_inline token_iterator::token_iterator(
16 token_position position
17 ) noexcept : buf{_buf}, _position{position}
21 simdjson_inline uint32_t token_iterator::current_offset() const noexcept {
26 simdjson_inline
const uint8_t *token_iterator::return_current_and_advance() noexcept {
27 return &buf[*(_position++)];
30 simdjson_inline
const uint8_t *token_iterator::peek(token_position position)
const noexcept {
31 return &buf[*position];
33 simdjson_inline uint32_t token_iterator::peek_index(token_position position)
const noexcept {
36 simdjson_inline uint32_t token_iterator::peek_length(token_position position)
const noexcept {
37 return *(position+1) - *position;
40 simdjson_inline uint32_t token_iterator::peek_root_length(token_position position)
const noexcept {
41 return *(position+2) - *(position) > *(position+1) - *(position) ?
42 *(position+1) - *(position)
43 : *(position+2) - *(position);
45 simdjson_inline
const uint8_t *token_iterator::peek(int32_t delta)
const noexcept {
46 return &buf[*(_position+delta)];
48 simdjson_inline uint32_t token_iterator::peek_index(int32_t delta)
const noexcept {
49 return *(_position+delta);
51 simdjson_inline uint32_t token_iterator::peek_length(int32_t delta)
const noexcept {
52 return *(_position+delta+1) - *(_position+delta);
55 simdjson_inline token_position token_iterator::position() const noexcept {
58 simdjson_inline
void token_iterator::set_position(token_position target_position) noexcept {
59 _position = target_position;
62 simdjson_inline
bool token_iterator::operator==(
const token_iterator &other)
const noexcept {
63 return _position == other._position;
65 simdjson_inline
bool token_iterator::operator!=(
const token_iterator &other)
const noexcept {
66 return _position != other._position;
68 simdjson_inline
bool token_iterator::operator>(
const token_iterator &other)
const noexcept {
69 return _position > other._position;
71 simdjson_inline
bool token_iterator::operator>=(
const token_iterator &other)
const noexcept {
72 return _position >= other._position;
74 simdjson_inline
bool token_iterator::operator<(
const token_iterator &other)
const noexcept {
75 return _position < other._position;
77 simdjson_inline
bool token_iterator::operator<=(
const token_iterator &other)
const noexcept {
78 return _position <= other._position;
87 simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::token_iterator>::simdjson_result(SIMDJSON_IMPLEMENTATION::ondemand::token_iterator &&value) noexcept
88 : implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::token_iterator>(std::forward<SIMDJSON_IMPLEMENTATION::ondemand::token_iterator>(value)) {}
89 simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::token_iterator>::simdjson_result(
error_code error) noexcept
90 : implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::token_iterator>(error) {}
The top level simdjson namespace, containing everything the library provides.
error_code
All possible errors returned by simdjson.