Release 0.16.02026-07-22
TL;DR
This release focuses on API cleaning and tidying, in preparation of release 1.0:
- improves tracking of nodes causing deserialization errors
- adds serialization to/from Tree (not just NodeRef/ConstNodeRef)
- deprecates a good number of functions, mostly around serialization and tree/node building
- brings code coverage to 100% (rounded from >99.5%)
- remove the c4core submodule, vendoring-in just the required c4core source code.
The API cleanup introduces a number of deprecations, and some other opt-in but recommended changes: see the migration guide in the next section.
Finally there are other fixes and improvements: see the full changelog, below the migration guide.
Migration guide
This is the list of migration changes, linking to the relevant section below:
- Deprecated .to_val() method family for tree building
- Deprecated operators (but define RYMLWITHLEGACY_OPERATORS to avoid the deprecation):
- tree building: deprecate operators |= or =
- serialization: deprecate operators << or >>
- Optional but recommended:
- user-implemented read() should now return ReadResult
- user-implemented read()/write() should now receive Tree and id
- do not use .load() (former >>) inside read()
- use .deserialize_child() inside read()
Be sure to also read through the quickstart diff for the full overview on how the new features work.
> [!TIP]
> Hint to see what changed in the quickstart: run git diff v0.15.2...v0.16.0 samples/quickstart.cpp on an up-to-date repo clone.
<a id="toval"></a>
Deprecate .to_val() family
For tree building, methods .to() were deprecated in favour of the newly-added .set() methods. See next section.
<a id="notequal"></a>
Deprecate operators |= and =
For tree building, operator|= and operator= were deprecated in favour of the newly-added .set_*() methods:
``c++
c4::yml::Tree tree = ...;
c4::yml::idtype nodeid = ...;
c4::yml::NodeRef node = ...;
// before (deprecated)
node |= MAP|BLOCK;
node["key"] = "val";
node["key"] |= VAL_SQUO;
node["seq"] |= SEQ|FLOW;
node["seq2"] |= SEQ;
node.appendchild().toseq("map");
// now, same as above:
node.set_map(BLOCK);
node["key"].setval("val", VALSQUO);
node["seq"].set_seq(FLOW);
node["seq2"].set_seq();
c4::yml::NodeRef child = node.append_child();
child.set_seq("map");
// or now, same as above, but from the tree:
// more code, but also more efficient
tree.setmap(nodeid, BLOCK);
c4::yml::idtype idkey = tree.appendchild(nodeid),
idseq = tree.appendchild(node_id),
idseq2 = tree.appendchild(node_id),
idmap = tree.appendchild(node_id);
tree.setkey(idkey, "key");
tree.setval(idkey, "val", VAL_SQUO);
tree.setkey(idseq, "seq");
tree.setseq(idseq, FLOW);
tree.setkey(idseq2, "seq2");
tree.setseq(idseq2);
tree.setkey(idmap, "map");
tree.setmap(idmap);
`
If you prefer to keep on using the legacy operators =, |=, <<, >>, you can enable the cmake symbol (or define the macro) RYMLWITHLEGACY_OPERATORS.
<a id="notshift"></a>
Deprecate operators << and >>
For serialization, operator<< and operator>> were deprecated in favour of .set_serialized() and .deserialize() (which introduce return on error) or .save() and .load() (which trigger error callback on error):
`c++
c4::yml::Tree tree = ...;
c4::yml::idtype nodeid = ...;
c4::yml::NodeRef node = ...;
const T var1 = ...;
T var2 = ...;
// before (deprecated)
node << var1;
node >> var2;
node << key(var1);
node >> key(var2);
// now - save() and load() do checks and call error on failure
node.save(var1);
node.load(&var2);
node.save_key(var1);
node.load_key(&var2);
// or now, without exceptional flow: use .set_serialized() and .deserialize()
node.set_serialized(var1);
if( ! node.deserialize(&var2))
...
node.setkeyserialized(var1);
if( ! node.deserialize_key(&var2))
...
// also now possible from tree!
tree.save(node_id, var1);
tree.load(node_id, &var2);
tree.savekey(nodeid, var1);
tree.loadkey(nodeid, &var2);
tree.setserialized(nodeid, var1);
if( ! tree.deserialize(node_id, &var2))
...
tree.setkeyserialized(node_id, var1);
if( ! tree.deserializekey(nodeid, &var2))
...
`
If you prefer to keep on using the legacy operators =, |=, <<, >>, you can enable the cmake variable (or define the macro) RYMLWITHLEGACY_OPERATORS.
The rest of the changes are optional, but recommended. If you don't do these changes, your code will go on working as before, but the new features and improved behavior will not be available.
<a id="readresult"></a>
Optional: user-implemented read() should now return ReadResult
Your read() functions should now return a c4::yml::ReadResult. This enables reporting the exact node on which a deserialization error happens, even if it is nested deep in the tree, which in turn helps tremendously pinpointing problems in YAML source (especially with location tracking):
`c++
// optional: your implementation of read() should be changed from...
bool read(c4::yml::ConstNodeRef const& node, T *var)
{
bool success = ...;
return success;
}
// optional: change to this:
c4::yml::ReadResult read(c4::yml::ConstNodeRef const& node, T *var)
{
bool success = ...;
return c4::yml::ReadResult(success, node.id());
}
`
If you don't change, rapidyaml will still report the error, but on the node of the outer-most function returning false, instead of the node at the inner-most function.
<a id="treeid"></a>
Optional: user-implemented read()/write() should now receive Tree and id
If you want to use deserialization from Tree, your read() and write() implementations should now be rewritten for Tree, instead of NodeRef. This will enable using your read()/write() functions with both the Tree and NodeRef methods:
`c++
// optional: your implementation of write()/read() should be changed from...
void write(c4::yml::NodeRef *node, T const& var)
{
...
}
c4::yml::ReadResult read(c4::yml::ConstNodeRef const& node, T *var)
{
bool success = ...;
return c4::yml::ReadResult(success, node.id());
}
// optional: change to this to enable serialization from/to both Tree and NodeRef:
void write(c4::yml::Tree tree, c4::yml::idtype id, T const& var)
{
...
}
c4::yml::ReadResult read(c4::yml::Tree const tree, c4::yml::idtype id, T *var)
{
bool success = ...;
return c4::yml::ReadResult(success, id);
}
`
If you don't change, you will not be able to serialize to/from Tree. That is, having only the node implementation will not work with the Tree methods. You can also provide both functions, and they would be picked up correctly, but that is pointless. In short, prefer the Tree version.
Note also that inside the tree version, you can still use the node API. For example:
`c++
c4::yml::ReadResult read(c4::yml::Tree const tree, c4::yml::idtype id, T *var)
{
c4::yml::ConstNodeRef n(tree, id);
... // this way you can keep the function body as before
// BUT read next note
}
`
<a id="noloadinread"></a>
Optional: do not use .load() (former >>) inside read()
Inside your write()/read() implementation you should now use the new .deserialize() calls. On error, these methods will play nice when they are called from .deserialize() on upper-level objects. On the contrary, .load() (formerly >>) will interrupt execution immediately, and this will prevent those upper-level calls from successfully receiving the actual ReadResult` and reporting it upwards.
Release 0.15.22026-06-08
See the Doxygen version of this changelog, which links any symbols mentioned here.
- Workaround for Doxygen changelog (use of HTML anchors in .md: doxy 1.15 fails but 1.16 succeeds).
Release 0.15.12026-06-08
See the Doxygen version of this changelog, which links the symbols mentioned here.
- PR#618:
- JSON emitter now adheres to flow style customization from PR#615
- JSON emitter now tolerates YAML streams (ie a seq of docs), and emits these as a top-level seq. The old behavior of throwing an error on streams can be obtained by using the new option EmitOptions::jsonerron_stream().
- Fix error in EmitOptions where EmitOptions::emitnonrootdash() had the same effect as EmitOptions::jsonerron_tag().
Release 0.15.02026-06-07
See the Doxygen version of this changelog, which links the symbols mentioned here.
- PR#615: add flow style customization:
- Add NodeTypee::FLOWSPC to force space after comma in flow style containers:
``c++
Tree tree = parseinarena("[0,1,2,3,4,5,6]");
CHECK(emitrs_yaml<std::string>(tree), "[0,1,2,3,4,5,6]");
tree.rootref().setcontainerstyle(FLOWSL|FLOWSPC); // add spaces
CHECK(emitrs_yaml<std::string>(tree), "[0, 1, 2, 3, 4, 5, 6]");
`
- Add FLOWMLN (flow multiline, multi-values per line, wrapped at max columns). The old FLOWML was deprecated, and is now known as FLOW_ML1 (flow multiline, 1 value per line):
`c++
tree.rootref().setcontainerstyle(FLOW_ML1);
CHECK(emitrs_yaml<std::string>(tree),
"[\n"
" 0,\n"
" 1,\n"
" 2,\n"
" 3,\n"
" 4,\n"
" 5,\n"
" 6\n"
"]\n");
tree.rootref().setcontainerstyle(FLOW_MLN);
CHECK(emitrs_yaml<std::string>(tree),
"[\n"
" 0,1,2,3,4,5,6\n"
"]\n");
`
- Add FLOWMLX mask to match both FLOWML1 and FLOW_MLN
- Add EmitOptions::maxcols() to control wrapping of FLOWMLN:
`c++
CHECK(emitrsyaml<std::string>(tree, EmitOptions{}.maxcols(8)),
"[\n"
" 0,1,2,\n"
" 3,4,5,\n"
" 6\n"
"]\n");
`
- Add EmitOptions::forceflowspc() to override all per-node settings of FLOW_SPC when emitting:
`c++
CHECK(emitrsyaml<std::string>(tree, EmitOptions{}.forceflow_spc(true)),
"[\n"
" 0, 1, 2, 3, 4, 5, 6\n"
"]\n");
`
- Add ParserOptions::flowmlstyle() to choose the multiline flow style to assign while parsing. The default value is still FLOWML1 (the old behavior), but this option allows picking any of FLOWMLN or FLOW_ML1.
- See samplestyleflow_formatting()` in the quickstart for more info.
Release 0.14.02026-06-05
- PR#607: add file utilities:
- fileputcontents()
- filegetcontents()
- stdingetcontents()
- PR#609: fix misbuild in gcc 16.
- PR#610: fix clang warnings: -Weverything. Thanks @TedLyngmo !
- PR#613: fix #612: parse error on whitespace-only after block scalar indicators | or >:
``yaml
space after: >\space
tag after: >\t
`
- PR#614 improve base64 serialization facilities:
`c++
std::string decoded;
tree["node"] >> fmt::base64(decoded); // now possible
// also can now obtain the size explicitly:
substr buf = ...;
size_t required = 0;
tree["node"] >> fmt::base64(buf, &required);
``
- Update c4core to 0.4.0.
Thanks
- @TedLyngmo
Release 0.13.02026-05-22
- PR#606: scalar style utilities now are specific to flow/block mode. This enables stable-style roundtrips of block-mode plain scalars with characters invalid in flow mode:
``yaml
# these scalars were previously emitted as single-quoted style
# because they were conservatively assumed to be in flow mode.
- doe: a deer, a female deer
- (10,11)
- also scalars containing [] and {}
`
- scalarstylechoose() was split into scalarstylechoose_{flow,block}()
- scalarstylequeryplain() was split into scalarstylequeryplain_{flow,block}()
- NodeType::type_str(NodeType,flags): remove zero-termination, use common approach of returning required size
- Add NodeType::typestrsub()
- PR#605: fix parse errors:
- : and # on continuation lines of multiline plain scalars:
`yaml
[plain
:scalar] # leading colon belongs to the scalar
`
- Tabs inside quoted scalars opening a map were mistook for indentation tabs:
`yaml
foo:
'\ta': b
`
- PR#604: add string_view and span to the c4/yml/std/std.hpp` interop umbrella header.
- Fix 600: shared symbols not exported in clang on Windows (PR#601).
- Fix 256: installation directory on Linux 64bit (PR#599). See also original fix at cmake#16. Big thanks to @GabrielBarrantes and @musicinmybrain, not just for their fixes but also for all their downstream work!
- PR#591: Add missing includes to avoid compilation warning. Thanks @GabrielBarrantes!
- Update c4core to 0.3.0.
Thanks
- @GabrielBarrantes
- @musicinmybrain
Release 0.12.12026-05-07
- Fix #597: parse error when quoted scalars start with ... or --- (PR#598). This fixes a regression introduced in (PR#587), while trying to ensure a parse error when ... or --- occur in quoted scalars at a line begin.
Release 0.12.02026-05-06
This release focuses in compliance with the YAML standard, mostly by ensuring parse errors in invalid YAML cases.
rapidyaml is now 100% compliant to the YAML test suite, both for valid and invalid YAML cases. :tada:
General fixes and improvements
- Narrow the scope of %TAG to only the following document, as per the standard (PR#588). This required or prompted some API changes:
- Added new type TagDirectives
- Added ParseOptions::resolvetags() and ParseOptions::resolvetagsall() options to allow controling resolution of tags while parsing. When disabled (which is the default), the tree still has Tree::resolvetags() to perform post-parsing or programmatic resolution.
- Changed TagDirective to point at its in-scope document, changed API to reflect this.
- ParseEngine now has an instance of TagDirectives, and is in charge of updating it and checking for directive errors.
- Removed the old TagDirective mtagdirectives[] members from the ints and testsuite handlers. Tree also has its own TagDirectives member, redundantly updated during parsing: this enables programmatic manipulation the tree's tag directives .
- The event handlers now track the current document id, in order to enable the document scope check for %TAG directives. This required adding node id tracking to the ints and testsuite handlers.
- Added Tree::ancestordoc(nodeid) and ConstNodeRef::ancestor_doc() to query for the parent document of a node. This is needed to implement resolution of tags.
- NodeType: rename tag directive types TAGD->TAGH (tag handle) and TAGV->TAGP (tag prefix).
- Internal changes to improve the design of event handlers, moving relocation and error checking logic to ParseEngine, where it is most suited.
- Fix warnings with clang-tidy 22
- PR#596: Add TagCache accelerator structure (in c4/yml/tag.hpp), used by Tree::resolve_tags() and the parser engine. This reduces significantly the arena requirements for heavily-tagged YAML by ensuring reuse of resolved tags.
YAML fixes: valid cases
Fix parsing of valid YAML corner cases:
- Ambiguity of tags/anchors in ? mode (PR#587):
``yaml
? &mapanchor
key: val
?
&keyanchor key: val
`
- flow tags/anchors with omitted plain scalar (PR#587):
`yaml
# ... likewise for !tag
- [&anchor,&anchor]
- {&anchor,&anchor}
- [&anchor :,&anchor :]
- {&anchor :,&anchor :}
- [: &anchor,: &anchor]
- {: &anchor,: &anchor}
---
? anchor
`
- flow tags/anchors terminating with : (the colon is part of the tag/anchor) (PR#587):
`yaml
# ... likewise for !tag:
- [&anchor:,&anchor:]
- {&anchor:,&anchor:}
- [&anchor: :,&anchor: :]
- {&anchor: :,&anchor: :}
- [: &anchor:,: &anchor:]
- {: &anchor:,: &anchor:}
---
? anchor
`
- Fix corner cases of explicit keys now allow same-line containers (PR#587):
`yaml
? - a # same-line container key now parses successfully. both seqs and maps
: - b # same-line container val now parses successfully. both seqs and maps
? ? - c # nested explicit keys were also fixed
? - d
`
- Missing tags/anchors in some flow maps (PR#587).
YAML fixes: invalid cases
Ensure parse errors for invalid YAML cases, and improve reported error location:
- %TAG directives are valid only in the following document (PR#588).
`yaml
%TAG !m my-
--- !m!first a
--- !m!second a # error: %TAG directive out of scope here
...
%TAG !m your-
--- !m!second a # ok: %TAG provided now.
`
- colon on newline at top level (PR#585):
`yaml
scalar
: bad
---
[seq]
: bad
---
{map: }
: bad
`
- colon on newline generally in block containers (PR#585):
`yaml
bad cases:
scalar
: bad colon
[seq]
: bad colon
{map: }
: bad colon
`
- colon on newline in flow sequences (PR#586):
`yaml
[a
:
b]
`
- tokens after explicit document end (PR#585):
`yaml
foo: bar
... bad tokens
`
- - is invalid scalar in flow sequences (PR#586):
`yaml
[-]
---
[-,-]
---
[--,-]
---
[-
]
`
- doc start/begin tokens at zero indentation in seq flow and quoted scalars (PR#587):
`yaml
[
---,
--- ,
---\t,
...,
... ,
...\t,
# etc
]
---
"
--- # error as well
... # error as well
"
---
'
--- # error as well
... # error as well
'
`
- nested flow containers now enforce the contextual parent indentation (PR#587):
`yaml
- - - [
a # now this is a parse error
]
- - - [
a # this is ok
]
`
- single/double-quoted scalars now enforce the contextual parent indentation (PR#587):
`yaml
- - - "a
b" # now this is a parse error
- - - "a
b" # this is ok
`
- plain scalars in block mode starting with , (PR#587):
`yaml
all invalid:
- , foo
- ,foo
- ,
`
- references with anchors or tags (PR#587):
`yaml
all invalid:
- &anchor *ref
- !tag *ref
`
- directives with extra tokens (PR#587):
`yaml
%YAML 1.2 blabla # invalid
%YAML 1. # this is ok
%TAG ! my- ! blabla # this is also wrong
---
`
- multiline implicit keys are invalid (PR#587):
`yaml
multiline
plain: invalid
'multiline
squoted': invalid
"multiline
dquoted": invalid
[multiline,
seq]: invalid
{multiline:
map}: invalid
`
- invalid block containers after document open (PR#592):
`yaml
--- a: b # invalid
--- - a # invalid
--- ? a # invalid
`
- invalid block containers after in-block open (PR#592):
`yaml
a: - b # invalid
a: ? b # invalid
`
- same-line repeated annotations (PR#592):
`yaml
!a
!b foo: bar # ok
---
&a
&b foo: bar # ok
---
!a !b foo: bar # invalid
---
&a &b foo: bar # invalid
`
- Fix parsing of invalid YAML: block scalars with deindented first line (PR#593):
`yaml
# the _ characters are not part of the YAML;
# they are used here only to show the leading whitespace
empty block scalar: >
_
_
_
# comment
``
Release 0.11.12026-03-26
- PR#583: Fix corner cases of container keys. Eg, parsing of explicit keys forming valid YAML like:
``yaml
?
? # was causing a parse error
? # popping was also causing a parse error
---
? [a: b]: x
: y
`
With this fix, rapidyaml now has a 100% success rate for valid YAML cases in the YAML test suite.
- PR#580: fix compilation error when RYMLNODEFAULT_CALLBACKS is defined (thanks @toge)
- PR#582: fix compilation error with clang-cl
- Fix #584: install: RYML_VERSION` was missing from rymlConfig.cmake
- Update c4core to 0.2.11
Python
- PR#579: python packaging files and CI infrastructure was moved to a different repo biojppm/rapidyaml-python. This was done because python packaging is notoriously hard and has always posed trouble in the CI, standing in the way of C++ development and releases.
Thanks
- @toge
Release 0.11.02026-03-14
New features
- PR#550 - Implement flow multiline style (FLOW_ML):
- The parser now detects this style automatically for flow seqs or maps when the terminating bracket sits on a line different from the opening bracket.
- Added ParserOptions::detectflowml() to enable/disable this behavior
- Added EmitOptions::indentflowml() to control indentation of FLOW_ML containers
- The emit implementation was refactored, and is now significantly cleaner
- Emitted YAML will now have anchors emitted before tags, as is customary (see example).
- Added ParserOptions defaulted argument to temp-parser overloads of parse{yaml,json}in_{place,arena}()
- PR#567 (fixes #566) fixes a regression from this refactor where top-level container anchors were wrongly emitted in the same line if no style was set on the container.
API changes
- BREAKING PR#503 (fixes #399): change error callbacks.
- Errors in ryml now have one of these types:
- parse error: when parsing YAML/JSON. See: pfnerrorparse, ErrorDataParse, ExceptionParse, errparseformat(), sampleerrorparse.
- visit error: when visiting a tree (reading or writing). See: pfnerrorvisit, ErrorDataVisit, ExceptionVisit, errvisitformat(), sampleerrorvisit.
- basic error: other, non specific errors. See: pfnerrorbasic, ErrorDataBasic, ExceptionBasic, errbasicformat(), sampleerrorbasic.
- parse and visit errors/exceptions can be treated/caught as basic errors/exceptions.
- Add message formatting functions to simplify user-provided implementation of error callbacks:
- errparseformat(): format/print a full error message for a parse error
- errvisitformat(): format/print a full error message for a visit error
- errbasicformat(): format/print a full error message for a basic error
- location_format(): format/print a location
- locationformatwith_context(): useful to create a rich error message showing the YAML region causing the error, maybe even for a visit error if the source is kept and locations are enabled.
- format_exc(): format an exception (when exceptions are enabled)
- See the new header c4/yml/error.hpp (and c4/yml/error.def.hpp for definitions of the functions in c4/yml/error.hpp)
- See the relevant sample functions in the quickstart sample: sampleerrorbasic, sampleerrorparse and sampleerrorvisit.
- There are breaking user-facing changes in the Callbacks structure:
- Removed member m_error
- Added members merrorbasic, merrorparse, merrorvisit
- Added methods .seterrorbasic(), .seterrorparse() and .seterrorvisit().
- BREAKING PR#557 - Tree is now non-empty by default, and Tree::root_id() will no longer modify the tree when it is empty. To create an empty tree, it is now necessary to use the capacity constructor with a capacity of zero:
``c++
// breaking change: default-constructed tree is now non-empty
Tree tree;
assert(!tree.empty()); // MODIFIED! was empty on previous version
idtype root = tree.rootid(); // OK. default-constructed tree is now non-empty
// to create an empty tree (as happened before):
Tree tree(0); // pass capacity of zero
assert(tree.empty()); // as expected
// but watchout, this is no longer possible:
//idtype root = tree.rootid(); // ERROR: cannot get root of empty tree.
`
This changeset also enables the python library to call root_id() on a default-constructed tree (fixes #556).
Fixes in YAML parsing
- PR#561 (fixes #559) - Byte Order Mark: account for BOM length when determining block indentation
- PR#547 - Fix parsing of implicit first documents with empty sequences, caused by a problem in Tree::setrootas_stream():
`yaml
[] # this container was lost during parsing
---
more data here
`
- PR#576 - extra::eventsintsprint(): Prevent integer overflow in bounds check (thanks @bytecodesky).
JSON emitting changes
- PR#574 (fixes #535 and #312) - improve handling of .inf, .nan and some float formats when emitting to JSON. For example, the tree
`yaml
{
inf: [inf, infinity, .inf, .Inf, .INF, -inf, -infinity, -.inf, -.Inf, -.INF],
nan: [nan, .nan, .NaN, .NAN],
dot: [.1, 1., .2e2, 10., -.2, -2.],
zero: [10, 01],
normal: [0.1, 0.2e3, 4.e5],
}
`
is now emitted to JSON as:
`json
{
".inf": [".inf",".inf",".inf",".inf","-.inf","-.inf","-.inf","-.inf","-.inf","-.inf"],
".nan": [".nan",".nan",".nan",".nan"],
"dot": [0.1,1.0,0.2e2,10.0,-0.2,-2.0],
"zero": [10,"01"],
"normal": [0.1,0.2e3,4.e5]
}
`
Previously, some inf and nan cases were emitted without quotes; now they are all emitted with the fixed strings .nan and .inf, which helps in cases where the JSON may be loaded in JavaScript. Note also the added zeroes for some floats, eg .1 or -2. turning into 0.1 and -2.0.
Other changes
- Update c4core to v0.2.10
Python improvements
- PR#560 (see also #554): python improvements:
- expose Tree::to_arena() in python. This allows safer and easier programatic creation of trees in python by ensuring scalars are placed into the tree and so have the same lifetime as the tree:
`python
t = ryml.Tree()
s = t.toarena(tempstring()) # Copy/serialize a temporary string to the tree's arena.
# Works also with integers and floats.
t.toval(t.rootid(), s) # Now we can safely use the scalar in the tree:
# there is no longer any risk of it being deallocated
`
- improve behavior of Tree methods accepting scalars: all standard buffer types are now accepted (ie, str, bytes, bytearray and memoryview).
- PR#565 (fixes #564) - Tree arena: allow relocation of zero-length strings when placed at the end (relax assertions triggered in Tree::_relocated())
- PR#563 (fixes #562) - Fix bug in NodeRef::cend()
- PR#568 - Move escapescalar() from c4/yml/extra/scalar.hpp to c4/yml/escapescalar.hpp` (and removed the original header)
Thanks
- @bytecodesky