13 constexpr bool is_string_delimiter(
char32_t c)
noexcept {
14 return c ==
U'"' ||
c ==
U'\'';
18 constexpr bool is_ascii_letter(
char32_t c)
noexcept {
19 return (
c >=
U'a' &&
c <=
U'z') || (
c >=
U'A' &&
c <=
U'Z');
23 constexpr bool is_binary_digit(
char32_t c)
noexcept {
24 return c ==
U'0' ||
c ==
U'1';
28 constexpr bool is_octal_digit(
char32_t c)
noexcept {
29 return (
c >=
U'0' &&
c <=
U'7');
33 constexpr bool is_decimal_digit(
char32_t c)
noexcept {
34 return (
c >=
U'0' &&
c <=
U'9');
38 constexpr bool is_hexadecimal_digit(
char32_t c)
noexcept {
39 return U'0' <=
c &&
c <=
U'f' &&
40 (1ull << (
static_cast<uint_least64_t
>(
c) - 0x30u)) & 0x7E0000007E03FFull;
45 if constexpr (std::is_same_v<remove_cvref<T>, uint_least32_t>)
47 ? 10u + (
c | 0x20u) - 0x61u
51 return hex_to_dec(
static_cast<uint_least32_t
>(
c));
55 constexpr bool is_horizontal_whitespace(
char32_t c)
noexcept {
56 return is_ascii_horizontal_whitespace(
c) || is_non_ascii_horizontal_whitespace(
c);
60 constexpr bool is_vertical_whitespace(
char32_t c)
noexcept {
61 return is_ascii_vertical_whitespace(
c) || is_non_ascii_vertical_whitespace(
c);
65 constexpr bool is_whitespace(
char32_t c)
noexcept {
66 return is_horizontal_whitespace(
c) || is_vertical_whitespace(
c);
70 constexpr bool is_bare_key_character(
char32_t c)
noexcept {
71 return is_ascii_bare_key_character(
c)
72#if TOML_LANG_UNRELEASED
73 || is_non_ascii_bare_key_character(
c)
79 constexpr bool is_value_terminator(
char32_t c)
noexcept {
80 return is_whitespace(
c) ||
c ==
U']' ||
c ==
U'}' ||
c ==
U',' ||
c ==
U'#';
84 constexpr bool is_control_character(
char c)
noexcept {
85 return c <=
'\u001F' ||
c ==
'\u007F';
89 constexpr bool is_control_character(
char32_t c)
noexcept {
90 return c <=
U'\u001F' ||
c ==
U'\u007F';
94 constexpr bool is_nontab_control_character(
char32_t c)
noexcept {
95 return c <=
U'\u0008' || (
c >=
U'\u000A' &&
c <=
U'\u001F') ||
c ==
U'\u007F';
99 constexpr bool is_unicode_surrogate(
char32_t c)
noexcept {
100 return c >= 0xD800u &&
c <= 0xDFFF;
103 struct utf8_decoder {
107 uint_least32_t state{};
108 char32_t codepoint{};
110 static constexpr uint8_t state_table[]{
111 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
112 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
113 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
114 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
115 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
116 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
117 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
118 9, 9, 9, 9, 9, 9, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
119 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 2, 2, 2, 2,
120 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
121 2, 2, 2, 2, 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 3, 11, 6,
122 6, 6, 5, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
124 0, 12, 24, 36, 60, 96, 84, 12, 12, 12, 48, 72, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
125 12, 12, 12, 0, 12, 12, 12, 12, 12, 0, 12, 0, 12, 12, 12, 24, 12, 12, 12, 12, 12, 24,
126 12, 24, 12, 12, 12, 12, 12, 12, 12, 12, 12, 24, 12, 12, 12, 12, 12, 24, 12, 12, 12, 12,
127 12, 12, 12, 24, 12, 12, 12, 12, 12, 12, 12, 12, 12, 36, 12, 36, 12, 12, 12, 36, 12, 12,
128 12, 12, 12, 36, 12, 36, 12, 12, 12, 36, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12};
131 constexpr bool error() const noexcept {
return state == uint_least32_t{12u}; }
134 constexpr bool has_code_point() const noexcept {
return state == uint_least32_t{}; }
137 constexpr bool needs_more_input() const noexcept {
return !has_code_point() && !
error(); }
139 constexpr void operator()(uint8_t
byte)
noexcept {
142 const auto type = state_table[byte];
144 codepoint =
static_cast<char32_t>(has_code_point()
145 ? (uint_least32_t{255u} >> type) &
byte
146 : (byte & uint_least32_t{63u}) |
147 (static_cast<uint_least32_t>(codepoint) << 6));
149 state = state_table[state + uint_least32_t{256u} + type];
153 constexpr void operator()(
char c)
noexcept { operator()(
static_cast<uint8_t
>(
c)); }
156 constexpr void reset() noexcept { state = {}; }
161 bool is_ascii(
const char*
str,
size_t len)
noexcept;
#define TOML_ASSERT_ASSUME(expr)
@ error
throw a parse_error exception in case of a tag
#define TOML_CONST_GETTER
#define TOML_PURE_INLINE_GETTER
#define TOML_ALWAYS_INLINE
#define TOML_IMPL_NAMESPACE_END
#define TOML_IMPL_NAMESPACE_START