simdjson  3.11.0
Ridiculously Fast JSON
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 
8 namespace simdjson {
9 namespace fallback {
10 namespace {
11 
12 // Holds backslashes and quotes locations.
13 struct backslash_and_quote {
14 public:
15  static constexpr uint32_t BYTES_PROCESSED = 1;
16  simdjson_inline static 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 
26 simdjson_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 } // unnamed namespace
33 } // namespace fallback
34 } // namespace simdjson
35 
36 #endif // SIMDJSON_FALLBACK_STRINGPARSING_DEFS_H
The top level simdjson namespace, containing everything the library provides.
Definition: base.h:8