simdjson 4.2.2
Ridiculously Fast JSON
Loading...
Searching...
No Matches
stringparsing_defs.h
1#ifndef SIMDJSON_FALLBACK_STRINGPARSING_DEFS_H
2#define SIMDJSON_FALLBACK_STRINGPARSING_DEFS_H
3
4#ifndef SIMDJSON_CONDITIONAL_INCLUDE
5#include "simdjson/fallback/base.h"
6#endif // SIMDJSON_CONDITIONAL_INCLUDE
7
8namespace simdjson {
9namespace fallback {
10namespace {
11
12// Holds backslashes and quotes locations.
13struct backslash_and_quote {
14public:
15 static constexpr uint32_t BYTES_PROCESSED = 1;
16 simdjson_inline backslash_and_quote copy_and_find(const uint8_t *src, uint8_t *dst);
17
18 simdjson_inline bool has_quote_first() { return c == '"'; }
19 simdjson_inline bool has_backslash() { return c == '\\'; }
20 simdjson_inline int quote_index() { return c == '"' ? 0 : 1; }
21 simdjson_inline int backslash_index() { return c == '\\' ? 0 : 1; }
22
23 uint8_t c;
24}; // struct backslash_and_quote
25
26simdjson_inline backslash_and_quote backslash_and_quote::copy_and_find(const uint8_t *src, uint8_t *dst) {
27 // store to dest unconditionally - we can overwrite the bits we don't like later
28 dst[0] = src[0];
29 return { src[0] };
30}
31
32
33struct escaping {
34 static constexpr uint32_t BYTES_PROCESSED = 1;
35 simdjson_inline static escaping copy_and_find(const uint8_t *src, uint8_t *dst);
36
37 simdjson_inline bool has_escape() { return escape_bits; }
38 simdjson_inline int escape_index() { return 0; }
39
40 bool escape_bits;
41}; // struct escaping
42
43
44
45simdjson_inline escaping escaping::copy_and_find(const uint8_t *src, uint8_t *dst) {
46 dst[0] = src[0];
47 return { (src[0] == '\\') || (src[0] == '"') || (src[0] < 32) };
48}
49
50} // unnamed namespace
51} // namespace fallback
52} // namespace simdjson
53
54#endif // SIMDJSON_FALLBACK_STRINGPARSING_DEFS_H
The top level simdjson namespace, containing everything the library provides.
Definition base.h:8