simdjson  3.1.6
Ridiculously Fast JSON
stringparsing.h
1 #ifndef SIMDJSON_FALLBACK_STRINGPARSING_H
2 #define SIMDJSON_FALLBACK_STRINGPARSING_H
3 
4 #include "simdjson/base.h"
5 
6 namespace simdjson {
7 namespace SIMDJSON_IMPLEMENTATION {
8 namespace {
9 
10 // Holds backslashes and quotes locations.
11 struct backslash_and_quote {
12 public:
13  static constexpr uint32_t BYTES_PROCESSED = 1;
14  simdjson_inline static backslash_and_quote copy_and_find(const uint8_t *src, uint8_t *dst);
15 
16  simdjson_inline bool has_quote_first() { return c == '"'; }
17  simdjson_inline bool has_backslash() { return c == '\\'; }
18  simdjson_inline int quote_index() { return c == '"' ? 0 : 1; }
19  simdjson_inline int backslash_index() { return c == '\\' ? 0 : 1; }
20 
21  uint8_t c;
22 }; // struct backslash_and_quote
23 
24 simdjson_inline backslash_and_quote backslash_and_quote::copy_and_find(const uint8_t *src, uint8_t *dst) {
25  // store to dest unconditionally - we can overwrite the bits we don't like later
26  dst[0] = src[0];
27  return { src[0] };
28 }
29 
30 } // unnamed namespace
31 } // namespace SIMDJSON_IMPLEMENTATION
32 } // namespace simdjson
33 
34 #endif // SIMDJSON_FALLBACK_STRINGPARSING_H
We want to support argument-dependent lookup (ADL).