1#ifndef SIMDJSON_CONSTEVALUTIL_H
2#define SIMDJSON_CONSTEVALUTIL_H
9namespace constevalutil {
12constexpr static std::array<uint8_t, 256> json_quotable_character = {
13 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
14 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
15 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
16 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
17 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
19 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
20 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
21 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
22 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
23 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
24constexpr static std::array<std::string_view, 32> control_chars = {
25 "\\u0000",
"\\u0001",
"\\u0002",
"\\u0003",
"\\u0004",
"\\u0005",
"\\u0006",
26 "\\u0007",
"\\b",
"\\t",
"\\n",
"\\u000b",
"\\f",
"\\r",
27 "\\u000e",
"\\u000f",
"\\u0010",
"\\u0011",
"\\u0012",
"\\u0013",
"\\u0014",
28 "\\u0015",
"\\u0016",
"\\u0017",
"\\u0018",
"\\u0019",
"\\u001a",
"\\u001b",
29 "\\u001c",
"\\u001d",
"\\u001e",
"\\u001f"};
31consteval std::string consteval_to_quoted_escaped(std::string_view input) {
32 std::string out =
"\"";
33 for (
char c : input) {
34 if (json_quotable_character[uint8_t(c)]) {
37 }
else if (c ==
'\\') {
40 std::string_view v = control_chars[uint8_t(c)];
53#if SIMDJSON_SUPPORTS_CONCEPTS
54template <std::
size_t N>
56 constexpr fixed_string(
const char (&str)[N]) {
57 for (std::size_t i = 0; i < N; ++i) {
62 constexpr std::string_view view()
const {
return {data, N - 1}; }
64template <std::
size_t N>
65fixed_string(
const char (&)[N]) -> fixed_string<N>;
67template <fixed_
string str>
68struct string_constant {
69 static constexpr std::string_view value = str.view();
The top level simdjson namespace, containing everything the library provides.