68 #define _prflag(fl, txt) \
70 if((flags & fl) == (fl)) \
74 if(pos + 1 < buf.len) \
78 csubstr fltxt = txt; \
79 if(pos + fltxt.len <= buf.len) \
80 memcpy(buf.str + pos, fltxt.str, fltxt.len); \
83 flags = (flags & ~fl); \
126 return buf.first(pos);
131 failed.len = pos + 1;
132 failed.str =
nullptr;
143 return ! s.first_of_any(
"\n ",
"\n\t");
149 if(s.begins_with(
"-."))
151 if(s ==
"-.inf" || s ==
"-.INF")
153 else if(s.sub(2).is_number())
156 else if(s.begins_with_any(
"0123456789.-+") && s.is_number())
161 && ( ! s.begins_with_any(
"-:?*&,'\"{}[]|>%#@`\r"))
162 && ( ! s.ends_with_any(
":#"))
166 && (s.first_of(
"\n#:[]{},") ==
npos);
173 if(s.begins_with_any(
" \n\t")
175 s.ends_with_any(
" \n\t"))
193 (s ==
"true" || s ==
"false" || s ==
"null")
202 (!(s.len > 1 && s.begins_with(
'0')))
NodeType_e scalar_style_json_choose(csubstr s) noexcept
choose a json style based on the scalar's contents
bool scalar_style_query_squo(csubstr s) noexcept
query whether a scalar can be encoded using single quotes.
bool scalar_style_query_plain(csubstr s) noexcept
query whether a scalar can be encoded using plain style (no quotes, not a literal/folded block scalar...
NodeType_e scalar_style_choose(csubstr s) noexcept
choose a YAML emitting style based on the scalar's contents
NodeType_e
a bit mask for marking node types and styles
@ VALANCH
the val has an &anchor
@ NOTYPE
no node type or style is set
@ KEY_DQUO
mark key scalar as double quoted "
@ VALREF
a *reference: the val references an &anchor
@ MAP
a map: a parent of KEYVAL/KEYSEQ/KEYMAP nodes
@ STREAM
a stream: a seq of docs
@ KEY
is member of a map, must have non-empty key
@ VAL_FOLDED
mark val scalar as multiline, block folded >
@ KEYTAG
the key has a tag
@ FLOW_SL
mark container with single-line flow style (seqs as '[val1,val2], maps as '{key: val,...
@ FLOW_ML
(NOT IMPLEMENTED, work in progress) mark container with multi-line flow style (seqs as '[ val1,...
@ VAL_UNFILT
the val scalar was left unfiltered; the parser was set not to filter.
@ VAL
a scalar: has a scalar (ie string) value, possibly empty. must be a leaf node, and cannot be MAP or S...
@ VALTAG
the val has a tag
@ _TYMASK
all the bits up to here
@ SEQ
a seq: a parent of VAL/SEQ/MAP nodes
@ VAL_SQUO
mark val scalar as single quoted '
@ VAL_PLAIN
mark val scalar as plain scalar (unquoted, even when multiline)
@ KEYREF
a *reference: the key references an &anchor
@ BLOCK
mark container with block style (seqs as '- val ', maps as 'key: val')
@ KEYANCH
the key has an &anchor
@ VAL_DQUO
mark val scalar as double quoted "
@ KEY_UNFILT
the key scalar was left unfiltered; the parser was set not to filter.
@ KEY_SQUO
mark key scalar as single quoted '
@ VAL_LITERAL
mark val scalar as multiline, block literal |
@ KEY_LITERAL
mark key scalar as multiline, block literal |
@ KEY_PLAIN
mark key scalar as plain scalar (unquoted, even when multiline)
@ KEY_FOLDED
mark key scalar as multiline, block folded >
@ npos
a null string position
const char * type_str() const noexcept
return a preset string based on the node type