forked from simdjson/simdjson
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstringparsing.h
More file actions
34 lines (25 loc) · 1 KB
/
stringparsing.h
File metadata and controls
34 lines (25 loc) · 1 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
#ifndef SIMDJSON_FALLBACK_STRINGPARSING_H
#define SIMDJSON_FALLBACK_STRINGPARSING_H
#include "simdjson.h"
namespace {
namespace fallback {
// Holds backslashes and quotes locations.
struct backslash_and_quote {
public:
static constexpr uint32_t BYTES_PROCESSED = 1;
really_inline static backslash_and_quote copy_and_find(const uint8_t *src, uint8_t *dst);
really_inline bool has_quote_first() { return c == '"'; }
really_inline bool has_backslash() { return c == '\\'; }
really_inline int quote_index() { return c == '"' ? 0 : 1; }
really_inline int backslash_index() { return c == '\\' ? 0 : 1; }
uint8_t c;
}; // struct backslash_and_quote
really_inline backslash_and_quote backslash_and_quote::copy_and_find(const uint8_t *src, uint8_t *dst) {
// store to dest unconditionally - we can overwrite the bits we don't like later
dst[0] = src[0];
return { src[0] };
}
} // namespace fallback
} // unnamed namespace
#include "generic/stage2/stringparsing.h"
#endif // SIMDJSON_FALLBACK_STRINGPARSING_H