2 namespace SIMDJSON_IMPLEMENTATION {
5 namespace atomparsing {
13 simdjson_inline uint32_t string_to_uint32(
const char* str) { uint32_t val; std::memcpy(&val, str,
sizeof(uint32_t));
return val; }
19 simdjson_inline uint32_t str4ncmp(
const uint8_t *src,
const char* atom) {
21 static_assert(
sizeof(uint32_t) <=
SIMDJSON_PADDING,
"SIMDJSON_PADDING must be larger than 4 bytes");
22 std::memcpy(&srcval, src,
sizeof(uint32_t));
23 return srcval ^ string_to_uint32(atom);
27 simdjson_inline
bool is_valid_true_atom(
const uint8_t *src) {
28 return (str4ncmp(src,
"true") | jsoncharutils::is_not_structural_or_whitespace(src[4])) == 0;
32 simdjson_inline
bool is_valid_true_atom(
const uint8_t *src,
size_t len) {
33 if (len > 4) {
return is_valid_true_atom(src); }
34 else if (len == 4) {
return !str4ncmp(src,
"true"); }
35 else {
return false; }
39 simdjson_inline
bool is_valid_false_atom(
const uint8_t *src) {
40 return (str4ncmp(src+1,
"alse") | jsoncharutils::is_not_structural_or_whitespace(src[5])) == 0;
44 simdjson_inline
bool is_valid_false_atom(
const uint8_t *src,
size_t len) {
45 if (len > 5) {
return is_valid_false_atom(src); }
46 else if (len == 5) {
return !str4ncmp(src+1,
"alse"); }
47 else {
return false; }
51 simdjson_inline
bool is_valid_null_atom(
const uint8_t *src) {
52 return (str4ncmp(src,
"null") | jsoncharutils::is_not_structural_or_whitespace(src[4])) == 0;
56 simdjson_inline
bool is_valid_null_atom(
const uint8_t *src,
size_t len) {
57 if (len > 4) {
return is_valid_null_atom(src); }
58 else if (len == 4) {
return !str4ncmp(src,
"null"); }
59 else {
return false; }
We want to support argument-dependent lookup (ADL).
constexpr size_t SIMDJSON_PADDING
The amount of padding needed in a buffer to parse JSON.