forked from simdjson/simdjson
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstructural_iterator.h
More file actions
52 lines (48 loc) · 1.52 KB
/
structural_iterator.h
File metadata and controls
52 lines (48 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
namespace {
namespace SIMDJSON_IMPLEMENTATION {
namespace stage2 {
class structural_iterator {
public:
const uint8_t* const buf;
uint32_t *next_structural;
dom_parser_implementation &dom_parser;
// Start a structural
really_inline structural_iterator(dom_parser_implementation &_dom_parser, size_t start_structural_index)
: buf{_dom_parser.buf},
next_structural{&_dom_parser.structural_indexes[start_structural_index]},
dom_parser{_dom_parser} {
}
// Get the buffer position of the current structural character
really_inline const uint8_t* current() {
return &buf[*(next_structural-1)];
}
// Get the current structural character
really_inline char current_char() {
return buf[*(next_structural-1)];
}
// Get the next structural character without advancing
really_inline char peek_next_char() {
return buf[*next_structural];
}
really_inline const uint8_t* peek() {
return &buf[*next_structural];
}
really_inline const uint8_t* advance() {
return &buf[*(next_structural++)];
}
really_inline char advance_char() {
return buf[*(next_structural++)];
}
really_inline size_t remaining_len() {
return dom_parser.len - *(next_structural-1);
}
really_inline bool at_end() {
return next_structural == &dom_parser.structural_indexes[dom_parser.n_structural_indexes];
}
really_inline bool at_beginning() {
return next_structural == dom_parser.structural_indexes.get();
}
};
} // namespace stage2
} // namespace SIMDJSON_IMPLEMENTATION
} // unnamed namespace