1 #ifndef _C4_YML_ESCAPE_SCALAR_HPP_
2 #define _C4_YML_ESCAPE_SCALAR_HPP_
4 #ifndef _C4_YML_COMMON_HPP_
58 uint8_t
const* C4_RESTRICT s =
reinterpret_cast<uint8_t const*
>(scalar.str);
60 for(
size_t i = 0; i < scalar.len; ++i)
109 if(s[i+1] == UINT8_C(0xa0))
115 else if(s[i+1] == UINT8_C(0x85))
126 if(s[i+1] == UINT8_C(0x80))
128 if(s[i+2] == UINT8_C(0xa8))
134 else if(s[i+2] == UINT8_C(0xa9))
147 std::forward<Fn>(fn)(scalar.range(prev, i));
148 std::forward<Fn>(fn)(repl);
151 std::forward<Fn>(fn)(
"\n");
157 if(scalar.len > prev)
158 std::forward<Fn>(fn)(scalar.sub(prev));
163 C4_SUPPRESS_WARNING_GCC_WITH_PUSH(
"-Wattributes")
170 inline C4_NO_INLINE
size_t escape_scalar(substr buffer, csubstr scalar,
bool keep_newlines=false)
173 auto _append = [&pos, &buffer](csubstr repl){
174 if(repl.len && (pos + repl.len <= buffer.len))
175 memcpy(buffer.str + pos, repl.str, repl.len);
181 C4_SUPPRESS_WARNING_GCC_POP
Common utilities and infrastructure used by ryml.
size_t to_chars(substr buf, escaped_scalar e)
formatting implementation to escape a scalar with x
size_t escape_scalar(substr buffer, csubstr scalar, bool keep_newlines=false)
Escape a scalar to an existing buffer, using escape_scalar_fn.
void escape_scalar_fn(Fn &&fn, csubstr scalar, bool keep_newlines=false)
Iterate through a scalar and escape special characters in it.
(Undefined by default) Use shorter error message from checks/asserts: do not show the check condition...
formatting helper to escape a scalar with x
escaped_scalar(csubstr s, bool keep_newl=false)