3 #include "c4/yml/detail/dbgprint.hpp"
10 C4_SUPPRESS_WARNING_GCC_CLANG_WITH_PUSH(
"-Wold-style-cast")
17 C4_ALWAYS_INLINE
bool _is_idchar(
char c)
19 return (c >=
'a' && c <=
'z')
20 || (c >=
'A' && c <=
'Z')
21 || (c >=
'0' && c <=
'9')
22 || (c ==
'_' || c ==
'-' || c ==
'~' || c ==
'$');
25 enum _ppstate :
int { kReadPending = 0, kKeyPending = 1, kValPending = 2 };
26 C4_ALWAYS_INLINE _ppstate _next(_ppstate s)
29 return (_ppstate)(n <= (int)kValPending ? n : 0);
38 detail::_SubstrWriter writer(buf);
39 _ppstate state = kReadPending;
42 if(s.begins_with(
'{'))
44 _RYML_CHECK_BASIC(s.ends_with(
'}'));
50 for(
size_t i = 0; i < s.len; ++i)
52 const char curr = s[i];
53 const char next = i+1 < s.len ? s[i+1] :
'\0';
55 if(curr ==
'\'' || curr ==
'"')
57 csubstr ss = s.sub(i).pair_range_esc(curr,
'\\');
58 i +=
static_cast<size_t>(ss.end() - (s.str + i));
61 else if(state == kReadPending && _is_idchar(curr))
70 if(curr ==
':' && next ==
' ')
74 else if(curr ==
',' && next ==
' ')
76 writer.append(s.range(last, i));
77 writer.append(
": 1, ");
84 if(curr ==
'[' || curr ==
'{' || curr ==
'(')
86 csubstr ss = s.sub(i).pair_range_nested(curr,
'\\');
87 i +=
static_cast<size_t>(ss.end() - (s.str + i));
90 else if(curr ==
',' && next ==
' ')
102 writer.append(s.sub(last));
103 if(state == kKeyPending)
104 writer.append(
": 1");
110 C4_SUPPRESS_WARNING_GCC_CLANG_POP
Error utilities used by ryml.
size_t preprocess_rxmap(csubstr s, substr buf)
Write into a given output buffer.
(Undefined by default) Use shorter error message from checks/asserts: do not show the check condition...
Functions for preprocessing YAML prior to parsing.