3 #include "c4/yml/detail/dbgprint.hpp"
10 C4_SUPPRESS_WARNING_GCC_CLANG_WITH_PUSH(
"-Wold-style-cast")
19 C4_ALWAYS_INLINE
bool _is_idchar(
char c)
21 return (c >=
'a' && c <=
'z')
22 || (c >=
'A' && c <=
'Z')
23 || (c >=
'0' && c <=
'9')
24 || (c ==
'_' || c ==
'-' || c ==
'~' || c ==
'$');
27 enum _ppstate :
int { kReadPending = 0, kKeyPending = 1, kValPending = 2 };
28 C4_ALWAYS_INLINE _ppstate _next(_ppstate s)
31 return (_ppstate)(n <= (int)kValPending ? n : 0);
40 detail::_SubstrWriter writer(buf);
41 _ppstate state = kReadPending;
44 if(s.begins_with(
'{'))
46 _RYML_CHECK_BASIC(s.ends_with(
'}'));
52 for(
size_t i = 0; i < s.len; ++i)
54 const char curr = s[i];
55 const char next = i+1 < s.len ? s[i+1] :
'\0';
57 if(curr ==
'\'' || curr ==
'"')
59 csubstr ss = s.sub(i).pair_range_esc(curr,
'\\');
60 i +=
static_cast<size_t>(ss.end() - (s.str + i));
63 else if(state == kReadPending && _is_idchar(curr))
72 if(curr ==
':' && next ==
' ')
76 else if(curr ==
',' && next ==
' ')
78 writer.append(s.range(last, i));
79 writer.append(
": 1, ");
86 if(curr ==
'[' || curr ==
'{' || curr ==
'(')
88 csubstr ss = s.sub(i).pair_range_nested(curr,
'\\');
89 i +=
static_cast<size_t>(ss.end() - (s.str + i));
92 else if(curr ==
',' && next ==
' ')
104 writer.append(s.sub(last));
105 if(state == kKeyPending)
106 writer.append(
": 1");
113 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.