simdjson 4.2.3
Ridiculously Fast JSON
Loading...
Searching...
No Matches
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
10namespace simdjson {
11namespace SIMDJSON_IMPLEMENTATION {
12namespace ondemand {
13
14simdjson_inline token_iterator::token_iterator(
15 const uint8_t *_buf,
16 token_position position
17) noexcept : buf{_buf}, _position{position}
18{
19}
20
21simdjson_inline uint32_t token_iterator::current_offset() const noexcept {
22 return *(_position);
23}
24
25
26simdjson_inline const uint8_t *token_iterator::return_current_and_advance() noexcept {
27 return &buf[*(_position++)];
28}
29
30simdjson_inline const uint8_t *token_iterator::peek(token_position position) const noexcept {
31 return &buf[*position];
32}
33simdjson_inline uint32_t token_iterator::peek_index(token_position position) const noexcept {
34 return *position;
35}
36simdjson_inline uint32_t token_iterator::peek_length(token_position position) const noexcept {
37 return *(position+1) - *position;
38}
39
40simdjson_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);
44}
45simdjson_inline const uint8_t *token_iterator::peek(int32_t delta) const noexcept {
46 return &buf[*(_position+delta)];
47}
48simdjson_inline uint32_t token_iterator::peek_index(int32_t delta) const noexcept {
49 return *(_position+delta);
50}
51simdjson_inline uint32_t token_iterator::peek_length(int32_t delta) const noexcept {
52 return *(_position+delta+1) - *(_position+delta);
53}
54
55simdjson_inline token_position token_iterator::position() const noexcept {
56 return _position;
57}
58simdjson_inline void token_iterator::set_position(token_position target_position) noexcept {
59 _position = target_position;
60}
61
62simdjson_inline bool token_iterator::operator==(const token_iterator &other) const noexcept {
63 return _position == other._position;
64}
65simdjson_inline bool token_iterator::operator!=(const token_iterator &other) const noexcept {
66 return _position != other._position;
67}
68simdjson_inline bool token_iterator::operator>(const token_iterator &other) const noexcept {
69 return _position > other._position;
70}
71simdjson_inline bool token_iterator::operator>=(const token_iterator &other) const noexcept {
72 return _position >= other._position;
73}
74simdjson_inline bool token_iterator::operator<(const token_iterator &other) const noexcept {
75 return _position < other._position;
76}
77simdjson_inline bool token_iterator::operator<=(const token_iterator &other) const noexcept {
78 return _position <= other._position;
79}
80
81} // namespace ondemand
82} // namespace SIMDJSON_IMPLEMENTATION
83} // namespace simdjson
84
85namespace simdjson {
86
87simdjson_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)) {}
89simdjson_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) {}
91
92} // namespace simdjson
93
94#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