1 #ifndef SIMDJSON_WESTMERE_STRINGPARSING_DEFS_H
2 #define SIMDJSON_WESTMERE_STRINGPARSING_DEFS_H
4 #include "simdjson/westmere/bitmanipulation.h"
5 #include "simdjson/westmere/simd.h"
14 struct backslash_and_quote {
16 static constexpr uint32_t BYTES_PROCESSED = 32;
17 simdjson_inline
static backslash_and_quote copy_and_find(
const uint8_t *src, uint8_t *dst);
19 simdjson_inline
bool has_quote_first() {
return ((bs_bits - 1) & quote_bits) != 0; }
20 simdjson_inline
bool has_backslash() {
return bs_bits != 0; }
21 simdjson_inline
int quote_index() {
return trailing_zeroes(quote_bits); }
22 simdjson_inline
int backslash_index() {
return trailing_zeroes(bs_bits); }
28 simdjson_inline backslash_and_quote backslash_and_quote::copy_and_find(
const uint8_t *src, uint8_t *dst) {
31 static_assert(
SIMDJSON_PADDING >= (BYTES_PROCESSED - 1),
"backslash and quote finder must process fewer than SIMDJSON_PADDING bytes");
32 simd8<uint8_t> v0(src);
33 simd8<uint8_t> v1(src + 16);
36 uint64_t bs_and_quote = simd8x64<bool>(v0 ==
'\\', v1 ==
'\\', v0 ==
'"', v1 ==
'"').to_bitmask();
38 uint32_t(bs_and_quote),
39 uint32_t(bs_and_quote >> 32)
The top level simdjson namespace, containing everything the library provides.
constexpr size_t SIMDJSON_PADDING
The amount of padding needed in a buffer to parse JSON.