14 constexpr bool is_string_delimiter(
char32_t c)
noexcept
16 return c == U
'"' || c == U
'\'';
20 constexpr bool is_ascii_letter(
char32_t c)
noexcept
22 return (c >= U
'a' && c <= U
'z') || (c >= U
'A' && c <= U
'Z');
26 constexpr bool is_binary_digit(
char32_t c)
noexcept
28 return c == U
'0' || c == U
'1';
32 constexpr bool is_octal_digit(
char32_t c)
noexcept
34 return (c >= U
'0' && c <= U
'7');
38 constexpr bool is_decimal_digit(
char32_t c)
noexcept
40 return (c >= U
'0' && c <= U
'9');
44 constexpr bool is_hexadecimal_digit(
char32_t c)
noexcept
46 return U
'0' <= c && c <= U'f' && (1ull << (static_cast<uint_least64_t>(c) - 0x30u)) & 0x7E0000007E03FFull;
51 constexpr uint_least32_t hex_to_dec(
const T c)
noexcept
53 if constexpr (std::is_same_v<remove_cvref<T>, uint_least32_t>)
55 ? 10u + (c | 0x20u) - 0x61u
59 return hex_to_dec(
static_cast<uint_least32_t
>(c));
63 constexpr bool is_horizontal_whitespace(
char32_t c)
noexcept
65 return is_ascii_horizontal_whitespace(c) || is_non_ascii_horizontal_whitespace(c);
69 constexpr bool is_vertical_whitespace(
char32_t c)
noexcept
71 return is_ascii_vertical_whitespace(c) || is_non_ascii_vertical_whitespace(c);
75 constexpr bool is_whitespace(
char32_t c)
noexcept
77 return is_horizontal_whitespace(c) || is_vertical_whitespace(c);
81 constexpr bool is_bare_key_character(
char32_t c)
noexcept
83 return is_ascii_bare_key_character(c)
84#if TOML_LANG_UNRELEASED
85 || is_non_ascii_bare_key_character(c)
91 constexpr bool is_value_terminator(
char32_t c)
noexcept
93 return is_whitespace(c) || c == U
']' || c == U
'}' || c == U
',' || c == U
'#';
97 constexpr bool is_control_character(
char c)
noexcept
99 return c <=
'\u001F' || c ==
'\u007F';
103 constexpr bool is_control_character(
char32_t c)
noexcept
105 return c <= U
'\u001F' || c == U
'\u007F';
109 constexpr bool is_nontab_control_character(
char32_t c)
noexcept
111 return c <= U
'\u0008' || (c >= U
'\u000A' && c <= U
'\u001F') || c == U
'\u007F';
115 constexpr bool is_unicode_surrogate(
char32_t c)
noexcept
117 return c >= 0xD800u && c <= 0xDFFF;
125 uint_least32_t state{};
126 char32_t codepoint{};
128 static constexpr uint8_t state_table[]{
129 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
130 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
131 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
132 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
133 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1,
134 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7, 7,
135 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
136 7, 7, 7, 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
137 2, 2, 2, 2, 2, 2, 2, 2, 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 3, 11, 6, 6,
138 6, 5, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
140 0, 12, 24, 36, 60, 96, 84, 12, 12, 12, 48, 72, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 0, 12,
141 12, 12, 12, 12, 0, 12, 0, 12, 12, 12, 24, 12, 12, 12, 12, 12, 24, 12, 24, 12, 12, 12, 12, 12, 12, 12, 12,
142 12, 24, 12, 12, 12, 12, 12, 24, 12, 12, 12, 12, 12, 12, 12, 24, 12, 12, 12, 12, 12, 12, 12, 12, 12, 36, 12,
143 36, 12, 12, 12, 36, 12, 12, 12, 12, 12, 36, 12, 36, 12, 12, 12, 36, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12
147 constexpr bool error() const noexcept
149 return state == uint_least32_t{ 12u };
153 constexpr bool has_code_point() const noexcept
155 return state == uint_least32_t{};
159 constexpr bool needs_more_input() const noexcept
161 return !has_code_point() && !
error();
164 constexpr void operator()(uint8_t
byte)
noexcept
168 const auto type = state_table[byte];
170 codepoint =
static_cast<char32_t>(has_code_point() ? (uint_least32_t{ 255u } >> type) &
byte
171 : (byte & uint_least32_t{ 63u })
172 | (static_cast<uint_least32_t>(codepoint) << 6));
174 state = state_table[state + uint_least32_t{ 256u } + type];
178 constexpr void operator()(
char c)
noexcept
180 operator()(
static_cast<uint8_t
>(c));
184 constexpr void reset() noexcept
192 bool is_ascii(
const char* str,
size_t len)
noexcept;
#define TOML_ASSERT_ASSUME(expr)
Definition preprocessor.hpp:1190
@ error
throw a parse_error exception in case of a tag
#define TOML_CONST_GETTER
Definition preprocessor.hpp:485
#define TOML_PURE_GETTER
Definition preprocessor.hpp:474
#define TOML_ATTR(...)
Definition preprocessor.hpp:316
#define TOML_PURE_INLINE_GETTER
Definition preprocessor.hpp:479
#define TOML_ALWAYS_INLINE
Definition preprocessor.hpp:405
#define TOML_IMPL_NAMESPACE_END
Definition preprocessor.hpp:1334
#define TOML_IMPL_NAMESPACE_START
Definition preprocessor.hpp:1333