Current
Changes since latest release: https://github.com/biojppm/rapidyaml/blob/master/changelog/current.md "current.md"
0.16.0
Github release: 0.16.2
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.
Significant effort went into maintaining backward compatibility. Nevertheless 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. For the details refer to this release's full changelog, below the migration guide.
Migration guide
This is the list of migration changes, linking to the relevant section below:
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.
Deprecate .to_val() family
For tree building, methods .to_*() were deprecated in favour of the newly-added .set_*() methods. See next section.
Deprecate operators |= and =
For tree building, operator|= and operator= were deprecated in favour of the newly-added .set_*() methods:
2 c4::yml::Tree tree = ...;
3 c4::yml::id_type node_id = ...;
4 c4::yml::NodeRef node = ...;
9 node["key"] |= VAL_SQUO;
10 node["seq"] |= SEQ|FLOW;
12 node.append_child().to_seq("map");
14 // now, same as above:
16 node["key"].set_val("val", VAL_SQUO);
17 node["seq"].set_seq(FLOW);
18 node["seq2"].set_seq();
19 c4::yml::NodeRef child = node.append_child();
22 // or now, same as above, but from the tree:
23 // more code, but also more efficient
24 tree.set_map(node_id, BLOCK);
25 c4::yml::id_type id_key = tree.append_child(node_id),
26 id_seq = tree.append_child(node_id),
27 id_seq2 = tree.append_child(node_id),
28 id_map = tree.append_child(node_id);
29 tree.set_key(id_key, "key");
30 tree.set_val(id_key, "val", VAL_SQUO);
31 tree.set_key(id_seq, "seq");
32 tree.set_seq(id_seq, FLOW);
33 tree.set_key(id_seq2, "seq2");
34 tree.set_seq(id_seq2);
35 tree.set_key(id_map, "map");
If you prefer to keep on using the legacy operators =, |=, <<, >>, you can enable the cmake symbol (or define the macro) RYML_WITH_LEGACY_OPERATORS.
Do not use 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):
2 c4::yml::Tree tree = ...;
3 c4::yml::id_type node_id = ...;
4 c4::yml::NodeRef node = ...;
14 // now - save() and load() do checks and call error on failure
19 // or now, without exceptional flow: use .set_serialized() and .deserialize()
20 node.set_serialized(var1);
21 if( ! node.deserialize(&var2))
23 node.set_key_serialized(var1);
24 if( ! node.deserialize_key(&var2))
27 // also now possible from tree!
28 tree.save(node_id, var1);
29 tree.load(node_id, &var2);
30 tree.save_key(node_id, var1);
31 tree.load_key(node_id, &var2);
32 tree.set_serialized(node_id, var1);
33 if( ! tree.deserialize(node_id, &var2))
35 tree.set_key_serialized(node_id, var1);
36 if( ! tree.deserialize_key(node_id, &var2))
If you prefer to keep on using the legacy operators =, |=, <<, >>, you can enable the cmake variable (or define the macro) RYML_WITH_LEGACY_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.
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 troubles in YAML source (especially with location tracking):
2 // optional: your implementation of read() should be changed from...
3 bool read(c4::yml::ConstNodeRef const& node, T *var)
8 // optional: change to this:
9 c4::yml::ReadResult read(c4::yml::ConstNodeRef const& node, T *var)
12 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.
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:
2 // optional: your implementation of write()/read() should be changed from...
3 void write(c4::yml::NodeRef *node, T const& var)
7 c4::yml::ReadResult read(c4::yml::ConstNodeRef const& node, T *var)
10 return c4::yml::ReadResult(success, node.id());
13 // optional: change to this to enable serialization from/to both Tree and NodeRef:
14 void write(c4::yml::Tree* tree, c4::yml::id_type id, T const& var)
18 c4::yml::ReadResult read(c4::yml::Tree const* tree, c4::yml::id_type id, T *var)
21 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:
2 c4::yml::ReadResult read(c4::yml::Tree const* tree, c4::yml::id_type id, T *var)
4 c4::yml::ConstNodeRef n(tree, id);
5 ... // this way you can keep the function body as before
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.
If you want to avoid exceptional flow and write code such as
2 struct Inner { int foo, bar; };
3 struct Outer { Inner inner1, inner2; }
6 if( ! node.deserialize(&outer))
7 ... // we want to enter this branch without triggering an error
... then your read(tree,id,Inner*) implementation should not use .load():
2 c4::yml::ReadResult read(c4::yml::Tree const* tree, c4::yml::id_type id, Inner *inner)
4 c4::yml::ReadResult result(tree->is_map(id), id);
5 if(result) result = tree->deserialize_child(id, "foo", &inner->foo);
6 if(result) result = tree->deserialize_child(id, "bar", &inner->foo);
9 // Likewise for the outer type. Note how an Inner error will be
10 // transparently returned:
11 c4::yml::ReadResult read(c4::yml::Tree const* tree, c4::yml::id_type id, Outer *outer)
13 c4::yml::ReadResult result(tree->is_map(id), id);
14 if(result) result = tree->deserialize_child(id, "inner1", &outer->inner1);
15 if(result) result = tree->deserialize_child(id, "inner2", &outer->inner2);
In short, implementing read() with .deserialize() plays nice with both upper .deserialize() and .load() calls, whereas implementing read() with .load() will only work with upper .load() calls.
Recommended: use new methods .deserialize_child() in read()
Inside your read() implementation, you should now use the new methods .deserialize_child().
This release also adds a family of tree and node methods returning c4::yml::ReadResult to simplify read() implementations. Each of these returns a ReadResult object that is ready to return on error. Consider the following node-based read(), already using .deserialize():
2 ryml::ReadResult read(ryml::ConstNodeRef const& n, my_type *val)
4 ryml::ReadResult r(n.is_map(), n.id());
5 if(r) r = n["v2"].deserialize(&val->v2); // don't. using [] will throw error if "v2" is not a child
6 if(r) r = n["v3"].deserialize(&val->v3);
7 if(r) r = n["v4"].deserialize(&val->v4);
8 if(r) r = n["seq"].deserialize(&val->seq);
9 if(r) r = n["map"].deserialize(&val->map);
Note that any of the operator[] calls (or more precisely the .deserialize() calls on its result) may trigger a visit error when no such node exists. To avoid exceptional flow in case of error, you should now use .deserialize_child(). The function below will gracefully return an appropriate error status when any of the child nodes does not exist:
2 ryml::ReadResult read(ryml::ConstNodeRef const& n, my_type *val)
4 ryml::ReadResult r(n.is_map(), n.id());
5 if(r) r = n.deserialize_child(n, "v2", &val->v2); // there is also a fall-back overload
6 // receiving a default value when
7 // no such child exists
8 if(r) r = n.deserialize_child(n, "v3", &val->v3);
9 if(r) r = n.deserialize_child(n, "v4", &val->v4);
10 if(r) r = n.deserialize_child(n, "seq", &val->seq);
11 if(r) r = n.deserialize_child(n, "map", &val->map);
Here's the list of new ReadResult-returning methods that may be of use in similar scenarios:
Full changelog
- Update c4core to v0.6.0
- PR#649 commit to ABI stability on patch releases before 0.x, then on minor releases after 1.x
- PR#648 improve documentation, add benchmark results
- PR#647 remove support for UTF16 and UTF32 encoded files
- PR#646 improve Doxygen docs, update yamlscript version
- PR#645 tools: unify ryml-parse-emit and ryml-yaml-events, remove ryml-yaml-events
- PR#644 amalgamate: add
--fastfloat_sys to use fastfloat from system
- PR#643 reduce source archive size: move large data files used in benchmarks to rapidyaml-data repo.
- PR#642 amalgamate: add option to create single source+header.
- PR#641: change uses of
C4_LIKELY() / C4_UNLIKELY() to turn into [[likely]] / [[unlikely]]. No logic changes.
- PR#640: add
.deserialize_child() methods to simplify read() implementations
- PR#639: fix names using leading/double underscore (renames only, no logic changes).
- PR#638: improve quickstart-ints.
- PR#637: add cmake option
RYML_SYSTEM_C4CORE to consume c4core from find_package(). Thanks @uilianries!
- PR#636 remove c4core submodule, and copy c4core files to rapidyaml (and manage sync):
ext/c4core.src/: c4core code used in the rapidyaml library
ext/c4core.dev/: c4core code used by tests/benchmarks
proj/: project files like cmake files and toolchains
RYML_STANDALONE can still be set to OFF to compile against an out-of-source c4core (see also the newly added RYML_SYSTEM_C4CORE)
- the amalgamation tool now adds only the files in
c4core.src files, and has new option --c4core-dev to include the c4core.dev files
- adds (internal) tools to manage c4core synchronization scenarios. See ext/README.md for details with this.
- PR#635 API cleanup:
NodeType and extra::ievt::EventFlags:
- On
Tree and NodeRef, overloads taking NodeType_e are now receiving type_bits.
- This saves operator calls on type queries.
- Remove bitwise operators, no longer needed.
- Rename
NodeType_e to NodeTypeBits (deprecate NodeType_e)
- Low impact, no changes should be needed on user code, other than renaming unlikely uses of
NodeType_e.
- Also, for int events: rename
extra::ievt::EventFlags to extra::ievt::EventBits
- PR#620 API cleanup:
Tree and NodeRef:
- Deprecate
NodeInit
Tree and NodeRef:
- deprecate
.to_val() and friends – add .set_val() and friends.
- deprecate
operator=(csubstr) and friends – use .set_val() instead.
- deprecate
operator|=(NodeType) and operator=(NodeType) – use appropriate overload .set_*(T, NodeType).
- You can disable compiler deprecation warnings from use of these operators: by enabling the cmake variable (or defining the macro)
RYML_WITH_LEGACY_OPERATORS.
- deprecate
NodeInit and NodeScalar methods in Tree and NodeRef (use .set_*())
- deprecate single-arg
NodeRef::{duplicate,move}(ConstNodeRef)
- deprecate
NodeRef::visit() and NodeRef::visit_stacked()
- add
Tree::arena_rem()
- add
RYML_DEFAULT_TREE_ARENA_CAPACITY_START with default value of 256
parse_*(): internal simplification, no semantic changes
- PR#589 API cleanup: serialization and tree building
- Refactor serialization code:
- Deprecate
operator<<, use .load() / .load_key() or .deserialize() / .deserialize_key()
- Deprecate
operator>>, use .save() / .save_key() or .set_serialized() / .set_key_serialized()
- Deprecate
key() tag function and Key tag type (needed only for the operators above)
- Migration of code triggering serialization:
- If you don't want to migrate yet, use
RYML_WITH_LEGACY_OPERATORS to disable compiler deprecation warnings from use of these operators.
- Serialization with
Tree API is now fully implemented, working exactly the same as NodeRef
- serialization:
NodeRef serialized with write(NodeRef *, T const&) and write_key()
Tree serialized with write(Tree *, id_type, T const&) and write_key()
- No changes in types using
to_chars() serialization
- deserialization:
ConstNodeRef deserialized with read(ConstNodeRef const&, T *) and read_key()
Tree deserialized with read(Tree const*, id_type, T *) and read_key() (removed old readkey() approach.)
- No changes in types using
from_chars() serialization
- Enables bypass of
NodeRef serialization to use the tree API, which is faster to compile.
- Organize serialization in layers, ensuring use of free functions to enable the user to override at all levels with ADL, for total control of type behavior (explained in the doxygen documentation).
- Added many more unit tests to ensure all scenarios are working.
- Move scalar specific code to new top-level headers
c4/yml/scalar_charconv.hpp and c4/yml/scalar_style.hpp
- Relax deserialization of nodes with
VALNIL or KEYNIL, such that non-fundamental types can now be null-initialized (eg initialize a string from a null scalar). Fundamental types such as ints or floats will still report an error.
2 Tree tree = parse_in_arena("{empty: }");
4 tree["empty"].load(&str); // relaxed: no longer a deserialization error
7 tree["empty"].load(&val); // ERROR! as before.
- PR#626: ensure accurate reporting of nodes causing deeply nested serialization error. This enables reporting the inner-most node causing the error! To profit from this,
read() user functions should now return ReadResult instead of bool. This change is backwards-compatible with legacy read() functions returning bool, but the legacy version will remain less precise: it will report an inner error on the upmost node returning false, possibly the root if all levels are returning bool. See the new sample_deserialize_error() on the quickstart, and the latest doxygen documentation. The user functions should change (but not mandatory):
3 bool read(ryml::ConstNodeRef n, T *var) { ... }
4 // now (should be changed, but not mandatory)
5 ryml::ReadResult read(ryml::ConstNodeRef n, T *var) { ... }
- PR#625: Set plain scalar style when serializing arithmetic scalars: improves emit speed of numeric-heavy data payloads.
- PR#616 API cleanup: emit
WriterFile and WriterOStream no longer track the number of emitted bytes.
error_on_excess is now used in the emit-to-buffer overloads, and no longer in the main Emitter::emit_as() driver function.
- PR#617 API cleanup: emit, part 2
- Tidy emit classes among new top-level header files:
- The old
c4/yml/emit.hpp is now a pure umbrella header, including all of the above. For better compilation speed, avoid the umbrella header, and prefer including the concrete header (container, buf, file or stream).
- The rest of the emit code was split over these new implementation headers:
- There are no semantic changes: all the
emit_*() functions remain the same.
- Other changes in this PR:
- Added
Tree::root_id_maybe() which is safe to call on an empty tree.
- Deprecate
Emitter::max_depth()
- Deprecate
Emitter::options() setter
- PR#618: API cleanup: emit, part 3
- Improve handling of
NaN and Inf in json emitting.
- Expose scalar style helpers for json emitting:
2 bool scalar_is_plain_number_json();
3 bool scalar_is_special_json();
6 bool scalar_is_inf_or_nan3();
- Writers: add
C4_ALWAYS_INLINE. Results in ~10-20% emit improvements.
file_put_contents(): add FILE* overloads
- PR#621 API cleanup:
NodeRef:
- Simplify internal implementation of
{Const}NodeRef::{iterator,children_view}.
- Stop using SFINAE on Node CRTP to distinguish const vs non const, by duplicating the functions in
NodeRef vs ConstNodeRef. No semantic changes. This should improve compilation speed of code containing many node calls.
- PR#622 API cleanup: remove preprocess utilities.
- PR#623: YAML fuzzing fixes, and close to 1 billion fuzz runs without any errors. These were the only two problems found:
- Ensure parse error on multiline keys opening YAML:
- Fix parse error on Byte Order Mark opening containers:
- PR#628: Add serialization fuzzing. Relax
c4::atof() / c4::atod(), disable redundant assertions that prevent returning false on bad strings.
- PR#629: int events:
- Rename
to_chars(substr,DataType) to to_str() (the existing c4 overload would always win because it's an int)
- Do not use c4/bitmask.hpp
- PR#633: improve coverage to ~99.5%:
- Add tests to cover missed lines
- Change some errors to assertions; those errors are caught before calling.
Tree and NodeRef: deprecate .type_str(). Use .type().type_str()
- Tools: add ints parsing to ryml-emit-parse
- PR#634: int events: add sample containing ints-only library
- PR#590: minor: prefer calling some predicates from
NodeType
Thanks
0.15.2
Github release: 0.15.2
- Workaround for Doxygen changelog (use of HTML anchors in .md: doxy 1.15 fails but 1.16 succeeds).
0.15.1
Github release: 0.15.1
0.15.0
Github release: 0.15.0
- PR#615: add flow style customization:
- Add FLOW_SPC to force space after comma in flow style containers:
2 c4::yml::Tree tree = c4::yml::parse_in_arena("[0,1,2,3,4,5,6]");
3 CHECK(c4::yml::emitrs_yaml<std::string>(tree), "[0,1,2,3,4,5,6]");
5 tree.rootref().set_container_style(c4::yml::FLOW_SL|c4::yml::FLOW_SPC);
6 CHECK(c4::yml::emitrs_yaml<std::string>(tree), "[0, 1, 2, 3, 4, 5, 6]");
- Add FLOW_MLN (flow multiline, multi-values per line, wrapped at max columns). The old
FLOW_ML was deprecated, and is now known as FLOW_ML1 (flow multiline, 1 value per line):
2 tree.rootref().set_container_style(c4::yml::FLOW_ML1);
3 CHECK(c4::yml::emitrs_yaml<std::string>(tree),
13 tree.rootref().set_container_style(c4::yml::FLOW_MLN);
14 CHECK(c4::yml::emitrs_yaml<std::string>(tree),
- Add FLOW_MLX mask to match both FLOW_ML1 and FLOW_MLN
- Add c4::yml::EmitOptions::max_cols( "EmitOptions::max_cols()") to control wrapping of FLOW_MLN:
2 auto maxcols8 = c4::yml::EmitOptions{}.max_cols(8);
3 CHECK(c4::yml::emitrs_yaml<std::string>(tree, maxcols8),
- Add c4::yml::EmitOptions::force_flow_spc( "EmitOptions::force_flow_spc()") to override all per-node settings of FLOW_SPC when emitting:
2 auto force_spaces = c4::yml::EmitOptions{}.force_flow_spc(true);
3 CHECK(c4::yml::emitrs_yaml<std::string>(tree, force_spaces),
5 " 0, 1, 2, 3, 4, 5, 6\n"
- Add c4::yml::ParserOptions::flow_ml_style( "ParserOptions::flow_ml_style()") to choose the multiline flow style to assign while parsing. The default value is still FLOW_ML1 (the old behavior), but this option allows picking any of FLOW_MLN or FLOW_ML1.
- See sample_style_flow_formatting( "sample_style_flow_formatting()") in the quickstart for more info.
0.14.0
Github release: 0.14.0
- PR#607: add file utilities:
- 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 >:
- PR#614 improve base64 serialization facilities:
3 tree["node"] >> fmt::base64(decoded); // now possible
4 // also can now obtain the size explicitly:
7 tree["node"] >> fmt::base64(buf, &required);
- Update c4core to 0.4.0.
Thanks
0.13.0
Github release: 0.13.0
- 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:
1 # these scalars were previously emitted as single-quoted style
2 # because they were conservatively assumed to be in flow mode.
3 - doe: a deer, a female deer
5 - also scalars containing [] and {}
- PR#605: fix parse errors:
: and # on continuation lines of multiline plain scalars:
2 :scalar] # leading colon belongs to the scalar
- Tabs inside quoted scalars opening a map were mistook for indentation tabs:
- 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
0.12.1
Github release: 0.12.1
- 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.
0.12.0
Github release: 0.12.0
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.
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 c4::yml::ParserOptions::resolve_tags( "ParserOptions::resolve_tags()") and c4::yml::ParserOptions::resolve_tags_all( "ParserOptions::resolve_tags_all()") options to allow controling resolution of tags while parsing. When disabled (which is the default), the tree still has
Tree::resolve_tags() 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 m_tag_directives[] 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 c4::yml::Tree::ancestor_doc( "Tree::ancestor_doc(node_id)") and c4::yml::ConstNodeRef::ancestor_doc( "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 c4::yml::Tree::resolve_tags( "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):
- flow tags/anchors with omitted plain scalar (PR#587):
1 # ... likewise for !tag
4 - [&anchor :,&anchor :]
5 - {&anchor :,&anchor :}
6 - [: &anchor,: &anchor]
7 - {: &anchor,: &anchor}
- flow tags/anchors terminating with
: (the colon is part of the tag/anchor) (PR#587): 1 # ... likewise for !tag:
4 - [&anchor: :,&anchor: :]
5 - {&anchor: :,&anchor: :}
6 - [: &anchor:,: &anchor:]
7 - {: &anchor:,: &anchor:}
- Fix corner cases of explicit keys now allow same-line containers (PR#587):
1 ? - a # same-line container key now parses successfully. both seqs and maps
2 : - b # same-line container val now parses successfully. both seqs and maps
3 ? ? - c # nested explicit keys were also fixed
- 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).
3 --- !m!second a # error: %TAG directive out of scope here
6 --- !m!second a # ok: %TAG provided now.
- colon on newline at top level (PR#585):
- colon on newline generally in block containers (PR#585):
- colon on newline in flow sequences (PR#586):
- tokens after explicit document end (PR#585):
- is invalid scalar in flow sequences (PR#586):
- doc start/begin tokens at zero indentation in seq flow and quoted scalars (PR#587):
- nested flow containers now enforce the contextual parent indentation (PR#587):
2 a # now this is a parse error
- single/double-quoted scalars now enforce the contextual parent indentation (PR#587):
2 b" # now this is a parse error
- plain scalars in block mode starting with
, (PR#587):
- references with anchors or tags (PR#587):
- directives with extra tokens (PR#587):
1 %YAML 1.2 blabla # invalid
3 %TAG ! my- ! blabla # this is also wrong
- multiline implicit keys are invalid (PR#587):
- invalid block containers after document open (PR#592):
- invalid block containers after in-block open (PR#592):
- same-line repeated annotations (PR#592):
7 !a !b foo: bar # invalid
9 &a &b foo: bar # invalid
- Fix parsing of invalid YAML: block scalars with deindented first line (PR#593):
1 # the _ characters are not part of the YAML;
2 # they are used here only to show the leading whitespace
0.11.1
Github release: 0.11.1
- PR#583: Fix corner cases of container keys. Eg, parsing of explicit keys forming valid YAML like:
2 ? # was causing a parse error
3 ? # popping was also causing a parse error
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
RYML_NO_DEFAULT_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
0.11.0
Github release: 0.11.0
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 c4::yml::ParserOptions::detect_flow_ml( "ParserOptions::detect_flow_ml()") to enable/disable this behavior
- Added c4::yml::EmitOptions::indent_flow_ml( "EmitOptions::indent_flow_ml()") 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: pfn_error_parse, ErrorDataParse, ExceptionParse, c4::yml::err_parse_format( "err_parse_format()"), sample_error_parse.
- visit error: when visiting a tree (reading or writing). See: pfn_error_visit, ErrorDataVisit, ExceptionVisit, c4::yml::err_visit_format( "err_visit_format()"), sample_error_visit.
- basic error: other, non specific errors. See: pfn_error_basic, ErrorDataBasic, ExceptionBasic, c4::yml::err_basic_format( "err_basic_format()"), sample_error_basic.
- 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:
- 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: sample_error_basic, sample_error_parse and sample_error_visit.
- There are breaking user-facing changes in the Callbacks structure:
- BREAKING PR#557 - Tree is now non-empty by default, and c4::yml::Tree::root_id( ".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:
2 // breaking change: default-constructed tree is now non-empty
4 assert(!tree.empty()); // MODIFIED! was empty on previous version
5 id_type root = tree.root_id(); // OK. default-constructed tree is now non-empty
7 // to create an empty tree (as happened before):
8 Tree tree(0); // pass capacity of zero
9 assert(tree.empty()); // as expected
10 // but watchout, this is no longer possible:
11 //id_type root = tree.root_id(); // 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::set_root_as_stream(): 1 [] # this container was lost during parsing
- PR#576 -
extra::events_ints_print(): 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
2 inf: [inf, infinity, .inf, .Inf, .INF, -inf, -infinity, -.inf, -.Inf, -.INF],
3 nan: [nan, .nan, .NaN, .NAN],
4 dot: [.1, 1., .2e2, 10., -.2, -2.],
6 normal: [0.1, 0.2e3, 4.e5],
is now emitted to JSON as:
2 ".inf": [".inf",".inf",".inf",".inf","-.inf","-.inf","-.inf","-.inf","-.inf","-.inf"],
3 ".nan": [".nan",".nan",".nan",".nan"],
4 "dot": [0.1,1.0,0.2e2,10.0,-0.2,-2.0],
6 "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
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:
2 s = t.to_arena(temp_string()) # Copy/serialize a temporary string to the tree's arena.
3 # Works also with integers and floats.
4 t.to_val(t.root_id(), s) # Now we can safely use the scalar in the tree:
5 # 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
escape_scalar() from c4/yml/extra/scalar.hpp to c4/yml/escape_scalar.hpp (and removed the original header)
Thanks
0.10.0
Github release: 0.10.0
Extra event handlers
PR#536 adds a new major extra feature: a parser event handler that creates a compact representation of the YAML tree in a buffer of integers containing masks (to represent events) and offset+length (to represent strings in the source buffer).
This handler is meant for use by other programming languages, and it supports container keys (unlike the ryml tree). You can find this handler among the other headers in the new `src_extra` folder.
Changes
- In PR#536 the location functions were moved from
ParserEngine to Tree and ConstNodeRef. The parser engine is now fully agnostic vis-a-vis the type of the event-handler. (The location functions in the parser engine were a legacy of the initial implementation of the parser which was meant to create only ryml trees).
- The tool ryml-yaml-events was updated to also dump integer events (and its command line options were changed to enable the different choices).
Fixes
- Fix #524 (PR#525): problem parsing nested map value in complex map. Kudos to @MatthewSteel!
- PR#542:
\x Unicode sequences were not decoded. Thanks to @mutativesystems!
- PR#541:
std::is_trivial deprecated in c++26. Thanks to @P3RK4N!
- Fix #529 (PR#530): double-quoted
"\<\<" was mistaken for an inheriting reference.
- PR#543: improvements to experimental style API:
- Add getters to NodeType, Tree, NodeRef, and ConstNodeRef:
.key_style(): get the style flags in a node's key
.val_style(): get the style flags in a node's val
.container_style(): get the style flags in a node's container
- Add style modifiers to NodeType, Tree, NodeRef, and ConstNodeRef:
.clear_style(bool recurse)
.set_style_conditionally(bool recurse)
- Fix argument handling in ryml-parse-emit.
Thanks
0.9.0
Github release: 0.9.0
Fixes
- Fix #400 (PR#506): clear anchors after resolving.
- Fix #484 (PR#506): fix merge key order for last element to be overriden.
- PR#503: ensure parse error on
a: b: c and similar cases containing nested maps opening on the same line.
- PR#502: fix parse errors or missing tags:
- missing tags in empty documents:
- trailing empty keys or vals:
- missing tags in trailing empty keys or vals:
- missing tags in complex maps:
- PR#501: fix missing tag in
- !!seq [].
- PR#508: fix build with cmake 4.
- PR#517 (fixes #516): fix python wheels for windows and macosx.
- Fix #120 (again): add workaround for
#define emit in Qt
Thanks
0.8.0
Github release: 0.8.0
Breaking changes
- [BREAKING] Fix #480 (PR#489):
- Deserializing an empty quoted string will not cause an error.
- Deserializing an empty string will cause an error: the empty string is read in as an empty scalar.
- Ensure keys are deserialized using all the rules applying to vals.
- Added KEYNIL and VALNIL to NodeType_e, used by the parser to mark the key or val as empty. This changed the values of the NodeType_e enumeration.
- Added
.key_is_null() and .val_is_null():
- [BREAKING] Fix #477 (PR#479): changed `read<std::map>()` to overwrite existing entries. The provided implementations had an inconsistency between `read<std::map>()` (which wasn't overwriting) and `read<std:vector>()` (which was overwriting).
Fixes
- PR#488:
- add workarounds for problems with codegen of gcc 11,12,13.
- improve CI coverage of gcc and clang optimization levels.
- PR#496 and c4core PR#148: Add CI-proven support for CPU architectures:
- mips, mipsel, mips64, mips64el
- sparc, sparc64
- riscv64
- loongarch64
- Fix #476 (PR#493): add handling of Byte Order Marks.
- PR#492: fix emit of explicit keys when indented:
6 : value # this was not indented
- PR#492: fix parser reset for full reuse (
m_doc_empty was not resetted), which would cause problems under specific scenarios in subsequent reuse.
- PR#485: improve the CI workflows (thanks to @ingydotnet):
- amazing code reuse and organization, thanks to the use of YamlScript to generate the final workflows
- all optimization levels are now covered for gcc, clang and Visual Studio.
- PR#499: fix warnings with
-Wundef.
Thanks
0.7.2
Fixes
- Fix #464: test failures with g++14 -O2 in ppc64le (PR#467)
Thanks
0.7.1
Github release: 0.7.1
New features
Fixes
- Fix #455: parsing of trailing val-less nested maps when deindented to maps (PR#460)
- Fix filtering of double-quoted keys in block maps (PR#452)
- Fix #440: some tests failing with gcc -O2 (hypothetically due to undefined behavior)
- This was accomplished by refactoring some internal parser functions; see the comments in #440 for further details.
- Also, fix all warnings from
scan-build.
- Use malloc.h instead of alloca.h on MinGW (PR#447)
- Fix #442 (PR#443):
- Ensure leading
+ is accepted when deserializing numbers.
- Ensure numbers are not quoted by fixing the heuristics in
scalar_style_query_plain() and scalar_style_choose().
- Add quickstart sample for overflow detection (only of integral types).
- Parse engine: cleanup unused macros
Thanks
0.7.0
Github release: 0.7.0
Most of the changes are from the giant Parser refactor described below. Before getting to that, some other minor changes first.
Fixes
- PR#431 - Emitter: prevent stack overflows when emitting malicious trees by providing a max tree depth for the emit visitor. This was done by adding an
EmitOptions structure as an argument both to the emitter and to the emit functions, which is then forwarded to the emitter. This EmitOptions structure has a max tree depth setting with a default value of 64.
- PR#431 - Fix
_RYML_CB_ALLOC() using (T) in parenthesis, making the macro unusable.
- #434 - Ensure empty vals are not deserialized (PR#436).
- PR#433:
- Fix some corner cases causing read-after-free in the tree's arena when it is relocated while filtering scalars.
- Improve YAML error conformance - detect YAML-mandated parse errors when:
- directives are misplaced (eg 9MMA, 9HCY, B63P, EB22, SF5V).
- comments are misplaced (eg MUS6/00, 9JBA, SU5Z)
- a node has both an anchor and an alias (eg SR86, SU74).
- tags contain invalid characters
,{}[] (eg LHL4, U99R, WZ62).
New features
- PR#431 - append-emitting to existing containers in the
emitrs_ functions, suggested in #345. This was achieved by adding a bool append=false as the last parameter of these functions.
- PR#431 - add depth query methods:
2 Tree::depth_asc(id_type) const; // O(log(num_tree_nodes)) get the depth of a node ascending (ie, from root to node)
3 Tree::depth_desc(id_type) const; // O(num_tree_nodes) get the depth of a node descending (ie, from node to deep-most leaf node)
4 ConstNodeRef::depth_asc() const; // likewise
5 ConstNodeRef::depth_desc() const;
6 NodeRef::depth_asc() const;
7 NodeRef::depth_desc() const;
- PR#432 - Added a function to estimate the required tree capacity, based on yaml markup:
2 size_t estimate_tree_capacity(csubstr); // estimate number of nodes resulting from yaml
All other changes come from PR#414.
Parser refactor
The parser was completely refactored (PR#414). This was a large and hard job carried out over several months, but it brings important improvements.
- The new parser is an event-based parser, based on an event dispatcher engine. This engine is templated on event handler, where each event is a function call, which spares branches on the event handler. The parsing code was fully rewritten, and is now much more simple (albeit longer), and much easier to work with and fix.
- YAML standard-conformance was improved significantly. Along with many smaller fixes and additions, (too many to list here), the main changes are the following:
- The parser engine can now successfully parse container keys, emitting all the events in correctly, but as before, the ryml tree cannot accomodate these (and this constraint is no longer enforced by the parser, but instead by
EventHandlerTree). For an example of a handler which can accomodate key containers, see the one which is used for the test suite at test/test_suite/test_suite_event_handler.hpp
- Anchor keys can now be terminated with colon (eg,
&anchor: key: val), as dictated by the standard.
- The parser engine can now be used to create native trees in other programming languages, or in cases where the user must have container keys.
- Performance of both parsing and emitting improved significantly; see some figures below.
Strict JSON parser
- A strict JSON parser was added. Use the
parse_json_...() family of functions to parse json in stricter mode (and faster) than flow-style YAML.
YAML style preserved while parsing
- The YAML style information is now fully preserved through parsing/emitting round trips. This was made possible because the event model of the new parsing engine now incorporates style varieties. So, for example:
- a scalar parsed from a plain/single-quoted/double-quoted/block-literal/block-folded scalar will be emitted always using its original style in the YAML source
- a container parsed in block-style will always be emitted in block-style
- a container parsed in flow-style will always be emitted in flow-style Because of this, the style of YAML emitted by ryml changes from previous releases.
- Scalar filtering was improved and is now done directly in the source being parsed (which may be in place or in the arena), except in the cases where the scalar expands and does not fit its initial range, in which case the scalar is filtered out of place to the tree's arena.
- Filtering can now be disabled while parsing, to ensure a fully-readonly parse (but this feature is still experimental and somewhat untested, given the scope of the rewrite work).
- The parser now offers methods to filter scalars in place or out of place.
- Style flags were added to
NodeType_e:
2 FLOW_SL ///< mark container with single-line flow style (seqs as '[val1,val2], maps as '{key: val,key2: val2}')
3 FLOW_ML ///< mark container with multi-line flow style (seqs as '[\n val1,\n val2\n], maps as '{\n key: val,\n key2: val2\n}')
4 BLOCK ///< mark container with block style (seqs as '- val\n', maps as 'key: val')
5 KEY_LITERAL ///< mark key scalar as multiline, block literal |
6 VAL_LITERAL ///< mark val scalar as multiline, block literal |
7 KEY_FOLDED ///< mark key scalar as multiline, block folded >
8 VAL_FOLDED ///< mark val scalar as multiline, block folded >
9 KEY_SQUO ///< mark key scalar as single quoted '
10 VAL_SQUO ///< mark val scalar as single quoted '
11 KEY_DQUO ///< mark key scalar as double quoted "
12 VAL_DQUO ///< mark val scalar as double quoted "
13 KEY_PLAIN ///< mark key scalar as plain scalar (unquoted, even when multiline)
14 VAL_PLAIN ///< mark val scalar as plain scalar (unquoted, even when multiline)
- Style predicates were added to
NodeType, Tree, ConstNodeRef and NodeRef:
2 bool is_container_styled() const;
4 bool is_flow_sl() const;
5 bool is_flow_ml() const;
8 bool is_key_styled() const;
9 bool is_val_styled() const;
10 bool is_key_literal() const;
11 bool is_val_literal() const;
12 bool is_key_folded() const;
13 bool is_val_folded() const;
14 bool is_key_squo() const;
15 bool is_val_squo() const;
16 bool is_key_dquo() const;
17 bool is_val_dquo() const;
18 bool is_key_plain() const;
19 bool is_val_plain() const;
- Style modifiers were also added:
2 void set_container_style(NodeType_e style);
3 void set_key_style(NodeType_e style);
4 void set_val_style(NodeType_e style);
- Emit helper predicates were added, and are used when an emitted node was built programatically without style flags:
2 /** choose a YAML emitting style based on the scalar's contents */
3 NodeType_e scalar_style_choose(csubstr scalar) noexcept;
4 /** query whether a scalar can be encoded using single quotes.
5 * It may not be possible, notably when there is leading
6 * whitespace after a newline. */
7 bool scalar_style_query_squo(csubstr s) noexcept;
8 /** query whether a scalar can be encoded using plain style (no
9 * quotes, not a literal/folded block scalar). */
10 bool scalar_style_query_plain(csubstr s) noexcept;
Breaking changes
As a result of the refactor, there are some limited changes with impact in client code. Even though this was a large refactor, effort was directed at keeping maximal backwards compatibility, and the changes are not wide. But they still exist:
- The existing
parse_...() methods in the Parser class were all removed. Use the corresponding parse_...(Parser*, ...) function from the header `c4/yml/parse.hpp`.
- When instantiated by the user, the parser now needs to receive a
EventHandlerTree object, which is responsible for building the tree. Although fully functional and tested, the structure of this class is still somewhat experimental and is still likely to change. There is an alternative event handler implementation responsible for producing the events for the YAML test suite in test/test_suite/test_suite_event_handler.hpp.
- The declaration and definition of
NodeType was moved to a separate header file c4/yml/node_type.hpp (previously it was in c4/yml/tree.hpp).
- Some of the node type flags were removed, and several flags (and combination flags) were added.
- Most of the existing flags are kept, as well as their meaning.
KEYQUO and VALQUO are now masks of the several style flags for quoted scalars. In general, however, client code using these flags and .is_val_quoted() or .is_key_quoted() is not likely to require any changes.
New type for node IDs
A type id_type was added to signify the integer type for the node id, defaulting to the backwards-compatible size_t which was previously used in the tree. In the future, this type is likely to change, and probably to a signed type, so client code is encouraged to always use id_type instead of the size_t, and specifically not to rely on the signedness of this type.
Reference resolver is now exposed
The reference (ie, alias) resolver object is now exposed in `c4/yml/reference_resolver.hpp`. Previously this object was temporarily instantiated in Tree::resolve(). Exposing it now enables the user to reuse this object through different calls, saving a potential allocation on every call.
Tag utilities
Tag utilities were moved to the new header `c4/yml/tag.hpp`. The types Tree::tag_directive_const_iterator and Tree::TagDirectiveProxy were deprecated. Fixed also an unitialization problem with Tree::m_tag_directives.
Performance improvements
To compare performance before and after this changeset, the benchmark runs were run (in the same PC), and the results were collected into these two files:
- https://github.com/biojppm/rapidyaml/blob/master/bm/results/results_before_newparser.md "results before newparser"
- https://github.com/biojppm/rapidyaml/blob/master/bm/results/results_after_newparser.md "results after newparser"
- (suggestion: compare these files in a diff viewer)
There are a lot of results in these files, and many insights can be obtained by browsing them; too many to list here. Below we show only some selected results.
Parsing
Here are some figures for parsing performance, for bm_ryml_inplace_reuse (name before) / bm_ryml_yaml_inplace_reuse (name after):
|---—|---------—|--------—|-----—|
Some conclusions:
- parse performance improved by ~30%-50% for YAML without filtering-heavy parsing.
- parse performance decreased by ~10%-15% for YAML with filtering-heavy parsing. There is still some scope for improvement in the parsing code, so this cost may hopefully be minimized in the future.
Emitting
Here are some figures emitting performance improvements retrieved from these files, for bm_ryml_str_reserve (name before) / bm_ryml_yaml_str_reserve (name after):
|---—|---------—|--------—|
Emit performance improved everywhere by over 1.5x and as much as 3x-4x for YAML without filtering-heavy parsing.
0.6.0
Github release: 0.6.0
Add API documentation
- PR#423: add Doxygen-based API documentation, now hosted in https://rapidyaml.readthedocs.io/!
- It uses the base doxygen docs, as I couldn't get doxyrest or breathe or exhale to produce anything meaningful using the doxygen groups already defined in the source code.
Error handling
Fix major error handling problem reported in #389 (PR#411):
- The NodeRef and ConstNodeRef classes are now conditional
noexcept using RYML_NOEXCEPT, which evaluates either to nothing when assertions are enabled, and to noexcept otherwise. The problem was that these classes had many methods explicitly marked noexcept, but were doing assertions which could throw exceptions, causing an abort instead of a throw whenever the assertion called an exception-throwing error callback.
- This problem was compounded by assertions being enabled in every build type – despite the intention to have them only in debug builds. There was a problem in the preprocessor code to enable assertions which led to assertions being enabled in release builds even when
RYML_USE_ASSERT was defined to 0. Thanks to @jdrouhard for reporting this.
- Although the code is and was extensively tested, the testing was addressing mostly the happy path. Tests were added to ensure that the error behavior is as intended.
- Together with this changeset, a major revision was carried out of the asserting/checking status of each function in the node classes. In most cases, assertions were added to functions that were missing them. So beware - some user code that was invalid will now assert or error out. Also, assertions and checks are now directed as much as possible to the callbacks of the closest scope: ie, if a tree has custom callbacks, errors within the tree class should go through those callbacks.
- Also, the intended assertion behavior is now in place: no assertions in release builds. Beware as well - user code which was relying on this will now silently succeed and return garbage in release builds. See the next points, which may help.
- Added new methods to the NodeRef/ConstNodeRef classes:
- The state for NodeRef was refined, and now there are three mutually exclusive states (and class predicates) for an object of this class:
- c4::yml::NodeRef::invalid( ".invalid()") when the object was not initialized to any node
- c4::yml::NodeRef::readable( ".readable()") when the object points at an existing tree+node
- c4::yml::NodeRef::is_seed( ".is_seed()") when the object points at an hypotethic tree+node
- The previous state
.valid() was deprecated: its semantics were confusing as it actually could be any of .readable() or .is_seed()
- Deprecated also the following methods for NodeRef/ConstNodeRef:
2 RYML_DEPRECATED() bool operator== (std::nullptr_t) const;
3 RYML_DEPRECATED() bool operator!= (std::nullptr_t) const;
4 RYML_DEPRECATED() bool operator== (csubstr val) const;
5 RYML_DEPRECATED() bool operator!= (csubstr val) const;
- Added macros and respective cmake options to control error handling:
RYML_USE_ASSERT - enable assertions regardless of build type. This is disabled by default. This macro was already defined; the current PR adds the cmake option.
RYML_DEFAULT_CALLBACK_USES_EXCEPTIONS - make the default error handler provided by ryml throw exceptions instead of calling std::abort(). This is disabled by default.
- Also,
RYML_DEBUG_BREAK() is now enabled only if RYML_DBG is defined, as reported in #362.
- As part of PR#423, to improve linters and codegen:
- annotate the error handlers with
[[noreturn]]/C4_NORETURN
- annotate some error sites with
C4_UNREACHABLE_AFTER_ERR()
More fixes
Tree::arena() const was returning a substr; this was an error. This function was changed to: 1 csubstr Tree::arena() const;
- Fix #390 -
csubstr::first_real_span() failed on scientific numbers with one digit in the exponent (PR#415).
- Fix #361 - parse error on map scalars containing
: and starting on the next line:
- PR#368 - fix pedantic compiler warnings.
- Fix #373 - false parse error with empty quoted keys in block-style map (PR#374).
- Fix #356 - fix overzealous check in
emit_as(). An id may be larger than the tree's size, eg when nodes were removed. (PR#357).
- Fix #417 - add quickstart example explaining how to avoid precision loss while serializing floats (PR#420).
- Fix #380 - Debug visualizer .natvis file for Visual Studio was missing ConstNodeRef (PR#383).
- FR #403 - install is now optional when using cmake. The relevant option is
RYML_INSTALL.
Python
- Fix #428/#412 - Parse errors now throw
RuntimeError instead of aborting.
Thanks
0.5.0
Github release: 0.5.0
Breaking changes
- Make the node API const-correct (PR#267): added
ConstNodeRef to hold a constant reference to a node. As the name implies, a ConstNodeRef object cannot be used in any tree-mutating operation. It is also smaller than the existing NodeRef (and faster because it does not need to check its own validity on every access). As a result of this change, there are now some constraints when obtaining a ref from a tree, and existing code is likely to break in this type of situation:
2 const Tree const_tree = ...;
3 NodeRef nr = const_tree.rootref(); // ERROR (was ok): cannot obtain a mutating NodeRef from a const Tree
4 ConstNodeRef cnr = const_tree.rootref(); // ok
7 NodeRef nr = tree.rootref(); // ok
8 ConstNodeRef cnr = tree.rootref(); // ok (implicit conversion from NodeRef to ConstNodeRef)
9 // to obtain a ConstNodeRef from a mutable Tree
10 // while avoiding implicit conversion, use the `c`
12 ConstNodeRef cnr = tree.crootref();
13 // likewise for tree.ref() and tree.cref().
15 nr = cnr; // ERROR: cannot obtain NodeRef from ConstNodeRef
The use of ConstNodeRef also needs to be propagated through client code. One such place is when deserializing types:
2 // needs to be changed from:
3 template<class T> bool read(ryml::NodeRef const& n, T *var);
5 template<class T> bool read(ryml::ConstNodeRef const& n, T *var);
- The initial version of
ConstNodeRef/NodeRef had the problem that const methods in the CRTP base did not participate in overload resolution (#294), preventing calls from const NodeRef objects. This was fixed by moving non-const methods to the CRTP base and disabling them with SFINAE (PR#295).
- Also added disambiguation iteration methods:
.cbegin(), .cend(), .cchildren(), .csiblings() (PR#295).
- Deprecate
emit() and emitrs() (#120, PR#303): use emit_yaml() and emitrs_yaml() instead. This was done to improve compatibility with Qt, which leaks a macro named emit. For more information, see #120.
- In the Python API:
- Deprecate
emit(), add emit_yaml() and emit_json().
- Deprecate
compute_emit_length(), add compute_emit_yaml_length() and compute_emit_json_length().
- Deprecate
emit_in_place(), add emit_yaml_in_place() and emit_json_in_place().
- Calling the deprecated functions will now trigger a warning.
- Location querying is no longer done lazily (#260, PR#307). It now requires explicit opt-in when instantiating the parser. With this change, the accelerator structure for location querying is now built when parsing:
2 Parser parser(ParserOptions().locations(true));
3 // now parsing also builds location lookup:
4 Tree t = parser.parse_in_arena("myfile.yml", "foo: bar");
5 assert(parser.location(t["foo"]).line == 0u);
- Locations are disabled by default:
3 assert(parser.options().locations() == false);
- Deprecate
Tree::arena_pos(): use Tree::arena_size() instead (PR#290).
- Deprecate pointless
has_siblings(): use Tree::has_other_siblings() instead (PR#330.
Performance improvements
- Improve performance of integer serialization and deserialization (in c4core). Eg, on Linux/g++11.2, with integral types:
c4::to_chars() can be expected to be roughly...
- ~40% to 2x faster than
std::to_chars()
- ~10x-30x faster than
sprintf()
- ~50x-100x faster than a naive
stringstream::operator<<() followed by stringstream::str()
c4::from_chars() can be expected to be roughly...
- ~10%-30% faster than
std::from_chars()
- ~10x faster than
scanf()
- ~30x-50x faster than a naive
stringstream::str() followed by stringstream::operator>>() For more details, see the changelog for c4core 0.1.10.
- Fix #289 and #331 - parsing of single-line flow-style sequences had quadratic complexity, causing long parse times in ultra long lines PR#293/PR#332.
- This was due to scanning for the token
: before scanning for , or ], which caused line-length scans on every scalar scan. Changing the order of the checks was enough to address the quadratic complexity, and the parse times for flow-style are now in line with block-style.
- As part of this changeset, a significant number of runtime branches was eliminated by separating
Parser::_scan_scalar() into several different {seq,map}x{block,flow} functions specific for each context. Expect some improvement in parse times.
- Also, on Debug builds (or assertion-enabled builds) there was a paranoid assertion calling
Tree::has_child() in Tree::insert_child() that caused quadratic behavior because the assertion had linear complexity. It was replaced with a somewhat equivalent O(1) assertion.
- Now the byte throughput is independent of line size for styles and containers. This can be seen in the table below, which shows parse troughputs in MB/s of 1000 containers of different styles and sizes (flow containers are in a single line):
| Container | Style | 10elms | 100elms | 1000elms |
| 1000 Maps | block | 50.8MB/s | 57.8MB/s | 63.9MB/s |
| 1000 Maps | flow | 58.2MB/s | 65.9MB/s | 74.5MB/s |
| 1000 Seqs | block | 55.7MB/s | 59.2MB/s | 60.0MB/s |
| 1000 Seqs | flow | 52.8MB/s | 55.6MB/s | 54.5MB/s |
- Fix #329: complexity of has_sibling() and has_child() is now O(1), previously was linear (PR#330).
Fixes
- Fix #233 - accept leading colon in the first key of a flow map (
UNK node) PR#234: 1 :foo: # parse error on the leading colon
2 :bar: a # parse error on the leading colon
- Fix #253: double-quoted emitter should encode carriage-return
\r to preserve roundtrip equivalence:
3 NodeRef root = tree.rootref();
6 root["s"] |= _WIP_VAL_DQUO;
7 std::string s = emitrs<std::string>(tree);
8 EXPECT_EQ(s, "s: \"t\\rt\"\n");
9 Tree tree2 = parse_in_arena(to_csubstr(s));
10 EXPECT_EQ(tree2["s"].val(), tree["s"].val());
- Fix parsing of empty block folded+literal scalars when they are the last child of a container (part of PR#264):
5 - | # error, the resulting val included all the YAML from the next node
10 - > # error, the resulting val included all the YAML from the next node
15 d: | # error, the resulting val included all the YAML from the next node
20 d: > # error, the resulting val included all the YAML from the next node
- Fix #274 (PR#296): Lists with unindented items and trailing empty values parse incorrectly: was wrongly parsed as
- Fix #277 (PR#340): merge fails with duplicate keys.
- Fix #337 (PR#338): empty lines in block scalars shall not have tab characters
\t.
- Fix #268 (PR#339): don't override key type_bits when copying val. This was causing problematic resolution of anchors/references.
- Fix #309 (PR#310): emitted scalars containing
@ or ` should be quoted.
- The quotes should be added only when they lead the scalar. See #320 and PR#334.
- Fix #297 (PR#298): JSON emitter should escape control characters.
- Fix #292 (PR#299): JSON emitter should quote version string scalars like
0.1.2.
- Fix #291 (PR#299): JSON emitter should quote scalars with leading zero, eg
048.
- Fix #280 (PR#281): deserialization of
std::vector<bool> failed because its operator[] returns a reference instead of value_type.
- Fix #288 (PR#290): segfault on successive calls to
Tree::_grow_arena(), caused by using the arena position instead of its length as starting point for the new arena capacity.
- Fix #324 (PR#328): eager assertion prevented moving nodes to the first position in a parent.
- Fix
Tree::_clear_val(): was clearing key instead (PR#335).
- YAML test suite events emitter: fix emission of inheriting nodes. The events for
{<<: *anchor, foo: bar} are now correctly emitted as: 1 =VAL :<< # previously was =ALI <<
- Fix #246: add missing
#define for the include guard of the amalgamated header.
- Fix #326: honor runtime settings for calling debugbreak, add option to disable any calls to debugbreak.
- Fix cmake#8:
SOVERSION missing from shared libraries.
Python
- The Python packages for Windows and MacOSX are causing problems in the CI, and were mostly disabled. The problematic packages are successfully made, but then fail to be imported. This was impossible to reproduce outside of the CI, and they were disabled since they were delaying the release. As a consequence, the Python release will have very limited compiled packages for Windows (only Python 3.6 and 3.7) or MacOSX. Help would be appreciated from those interested in these packages.
Thanks
0.4.1
Github release: 0.4.1
Fixes
- Fix #223: assertion peeking into the last line when it was whitespaces only.
0.4.0
Github release: 0.4.0
This release improves compliance with the YAML test suite (thanks @ingydotnet and @perlpunk for extensive and helpful cooperation), and adds node location tracking using the parser.
Breaking changes
As part of the new feature to track source locations, opportunity was taken to address a number of pre-existing API issues. These changes consisted of:
- Deprecate
c4::yml::parse() and c4::yml::Parser::parse() overloads; all these functions will be removed in short order. Until removal, any call from client code will trigger a compiler warning.
- Add
parse() alternatives, either parse_in_place() or parse_in_arena():
parse_in_place() receives only substr buffers, ie mutable YAML source buffers. Trying to pass a csubstr buffer to parse_in_place() will cause a compile error:
2 substr readwrite = /*...*/;
3 Tree tree = parse_in_place(readwrite); // OK
5 csubstr readonly = /*...*/;
6 Tree tree = parse_in_place(readonly); // compile error
parse_in_arena() receives only csubstr buffers, ie immutable YAML source buffers. Prior to parsing, the buffer is copied to the tree's arena, then the copy is parsed in place. Because parse_in_arena() is meant for immutable buffers, overloads receiving a substr YAML buffer are now declared but marked deprecated, and intentionally left undefined, such that calling parse_in_arena() with a substr will cause a linker error as well as a compiler warning.
2 substr readwrite = /*...*/;
3 Tree tree = parse_in_arena(readwrite); // compile warning+linker error
This is to prevent an accidental extra copy of the mutable source buffer to the tree's arena: substr is implicitly convertible to csubstr. If you really intend to parse an originally mutable buffer in the tree's arena, convert it first explicitly to immutable by assigning the substr to a csubstr prior to calling parse_in_arena():
2 substr readwrite = /*...*/;
3 csubstr readonly = readwrite; // ok
4 Tree tree = parse_in_arena(readonly); // ok
This problem does not occur with parse_in_place() because csubstr is not implicitly convertible to substr.
- In the python API,
ryml.parse() was removed and not just deprecated; the parse_in_arena() and parse_in_place() now replace this.
Callbacks: changed behavior in Parser and Tree:
- When a tree is copy-constructed or move-constructed to another, the receiving tree will start with the callbacks of the original.
- When a tree is copy-assigned or move-assigned to another, the receiving tree will now change its callbacks to the original.
- When a parser creates a new tree, the tree will now use a copy of the parser's callbacks object.
- When an existing tree is given directly to the parser, both the tree and the parser now retain their own callback objects; any allocation or error during parsing will go through the respective callback object.
New features
- Add tracking of source code locations. This is useful for reporting semantic errors after the parsing phase (ie where the YAML is syntatically valid and parsing is successful, but the tree contents are semantically invalid). The locations can be obtained lazily from the parser when the first location is queried:
2 // To obtain locations, use of the parser is needed:
4 ryml::Tree tree = parser.parse_in_arena("source.yml", R"({
6 foo: [one, [two, three]]
8 // After parsing, on the first call to obtain a location,
9 // the parser will cache a lookup structure to accelerate
10 // tracking the location of a node, with complexity
11 // O(numchars(srcbuffer)). Then it will do the lookup, with
12 // complexity O(log(numlines(srcbuffer))).
13 ryml::Location loc = parser.location(tree.rootref());
14 assert(parser.location_contents(loc).begins_with("{"));
15 // note the location members are zero-based:
16 assert(loc.offset == 0u);
17 assert(loc.line == 0u);
18 assert(loc.col == 0u);
19 // On the next call to location(), the accelerator is reused
20 // and only the lookup is done.
21 loc = parser.location(tree["aa"]);
22 assert(parser.location_contents(loc).begins_with("aa"));
23 assert(loc.offset == 2u);
24 assert(loc.line == 1u);
25 assert(loc.col == 0u);
26 // KEYSEQ in flow style: points at the key
27 loc = parser.location(tree["foo"]);
28 assert(parser.location_contents(loc).begins_with("foo"));
29 assert(loc.offset == 16u);
30 assert(loc.line == 2u);
31 assert(loc.col == 0u);
32 loc = parser.location(tree["foo"][0]);
33 assert(parser.location_contents(loc).begins_with("one"));
34 assert(loc.line == 2u);
35 assert(loc.col == 6u);
36 // SEQ in flow style: location points at the opening '[' (there's no key)
37 loc = parser.location(tree["foo"][1]);
38 assert(parser.location_contents(loc).begins_with("["));
39 assert(loc.line == 2u);
40 assert(loc.col == 11u);
41 loc = parser.location(tree["foo"][1][0]);
42 assert(parser.location_contents(loc).begins_with("two"));
43 assert(loc.line == 2u);
44 assert(loc.col == 12u);
45 loc = parser.location(tree["foo"][1][1]);
46 assert(parser.location_contents(loc).begins_with("three"));
47 assert(loc.line == 2u);
48 assert(loc.col == 17u);
49 // NOTE: reusing the parser with a new YAML source buffer
50 // will invalidate the accelerator.
See more details in the quickstart sample. Thanks to @cschreib for submitting a working example proving how simple it could be to achieve this.
Parser:
- add
source() and filename() to get the latest buffer and filename to be parsed
- add
callbacks() to get the parser's callbacks
- Add
from_tag_long() and normalize_tag_long():
2 assert(from_tag_long(TAG_MAP) == "<tag:yaml.org,2002:map>");
3 assert(normalize_tag_long("!!map") == "<tag:yaml.org,2002:map>");
- Add an experimental API to resolve tags based on the tree's tag directives. This API is still imature and will likely be subject to changes, so we won't document it yet.
- Regarding emit styles (see issue #37): add an experimental API to force flow/block style on container nodes, as well as block-literal/block-folded/double-quoted/single-quoted/plain styles on scalar nodes. This API is also immature and will likely be subject to changes, so we won't document it yet. But if you are desperate for this functionality, the new facilities will let you go further.
- Add preliminary support for bare-metal ARM architectures, with CI tests pending implementation of QEMU action. (#193, c4core#63).
- Add preliminary support for RISC-V architectures, with CI tests pending availability of RISC-V based github actions. (c4core#69).
Fixes
- Fix edge cases of parsing of explicit keys (ie keys after
?) (PR#212): 1 # all these were fixed:
3 ? explicit key # this comment was not parsed correctly
4 ? # trailing empty key was not added to the map
- Fixed parsing of tabs used as whitespace tokens after
: or -. This feature is costly (see some benchmark results here) and thus it is disabled by default, and requires defining a macro or cmake option RYML_WITH_TAB_TOKENS to enable (PR#211).
- Allow tab indentation in flow seqs (PR#215) (6CA3).
- ryml now parses successfully compact JSON code
{"like":"this"} without any need for preprocessing. This code was not valid YAML 1.1, but was made valid in YAML 1.2. So the preprocess_json() functions, used to insert spaces after : are no longer necessary and have been removed. If you were using these functions, remove the calls and just pass the original source directly to ryml's parser (PR#210).
- Fix handling of indentation when parsing block scalars (PR#210):
- Fix parsing of maps when opening a scope with whitespace before the colon (PR#210):
3 foo1 : bar # the " :" was causing an assert
- Ensure container keys preserve quote flags when the key is quoted (PR#210).
- Ensure scalars beginning with
% are emitted with quotes ((PR#216).
- Fix #203: when parsing, do not convert
null or ~ to null scalar strings. Now the scalar strings contain the verbatim contents of the original scalar; to query whether a scalar value is null, use Tree::key_is_null()/val_is_null() and NodeRef::key_is_null()/val_is_null() which return true if it is empty or any of the unquoted strings ~, null, Null, or NULL. (PR#207):
- Fix #205: fix parsing of escaped characters in double-quoted strings:
"\\\\\\"\n\r\t\<TAB>\/\<SPC>\0\b\f\a\v\e\_\N\L\P"</tt> (<a href="https://github.com/biojppm/rapidyaml/pulls/207">PR#207</a>).
- Fix <a href="https://github.com/biojppm/rapidyaml/issues/204">#204</a>: add decoding of unicode codepoints \c " " \c "" \c "" in double-quoted scalars:
2 Tree tree = parse_in_arena(R"(["\u263A \xE2\x98\xBA \u2705 \U0001D11E"])");
3 assert(tree[0].val() == "☺ ☺ ✅ 𝄞");
This is mandated by the YAML standard and was missing from ryml (PR#207).
Fix emission of nested nodes which are sequences: when these are given as the emit root, the - from the parent node was added (PR#210):
2 const ryml::Tree tree = ryml::parse_in_arena(R"(
10 // before (error), YAML valid but not expected
11 //assert(ryml::emitrs<std::string>(tree[0][3]) == R"(- - and so
15 // now: YAML valid and expected
16 assert(ryml::emitrs<std::string>(tree[0][3]) == R"(- and so
Fix parsing of isolated !: should be an empty val tagged with ! (UKK06-02) (PR#215).
Fix #193: amalgamated header missing \#include <stdarg.h> which prevented compilation in bare-metal arm-none-eabi (PR #195, requiring also c4core #64).
Accept infinity,inf and nan as special float values (but not mixed case: eg InFiNiTy or Inf or NaN are not accepted) (PR #186).
Accept special float values with upper or mixed case: .Inf, .INF, .NaN, .NAN. Previously, only low-case .inf and .nan were accepted (PR #186).
Accept null with upper or mixed case: Null or NULL. Previously, only low-case null was accepted (PR #186).
Fix #182: add missing export of DLL symbols, and document requirements for compiling shared library from the amalgamated header. PR #183, also PR c4core#56 and PR c4core#57.
Fix #185: compilation failures in earlier Xcode versions (PR #187 and PR c4core#61):
c4/substr_fwd.hpp: (failure in Xcode 12 and earlier) forward declaration for std::allocator is inside the inline namespace __1, unlike later versions.
c4/error.hpp: (failure in debug mode in Xcode 11 and earlier) __clang_major__ does not mean the same as in the common clang, and as a result the warning -Wgnu-inline-cpp-without-extern does not exist there.
Ensure error messages do not wrap around the buffer when the YAML source line is too long (PR#210).
Ensure error is emitted on unclosed flow sequence characters eg [[[ (PR#210). Same thing for []].
Refactor error message building and parser debug logging to use the new dump facilities in c4core (PR#212).
Parse: fix read-after-free when duplicating a parser state node, when pushing to the stack requires a stack buffer resize (PR#210).
Add support for legacy gcc 4.8 (PR#217).
Improvements
- Rewrite filtering of scalars to improve parsing performance (PR #188). Previously the scalar strings were filtered in place, which resulted in quadratic complexity in terms of scalar length. This did not matter for small scalars fitting the cache (which is the more frequent case), but grew in cost as the scalars grew larger. To achieve linearity, the code was changed so that the strings are now filtered to a temporary scratch space in the parser, and copied back to the output buffer after filtering, if any change occurred. The improvements were large for the folded scalars; the table below shows the benchmark results of throughput (MB/s) for several files containing large scalars of a single type:
| scalar type | before | after | improvement |
| block folded | 276 | 561 | 103% |
| block literal | 331 | 611 | 85% |
| single quoted | 247 | 267 | 8% |
| double quoted | 212 | 230 | 8% |
| plain (unquoted) | 173 | 186 | 8% |
The cost for small scalars is negligible, with benchmark improvement in the interval of -2% to 5%, so well within the margin of benchmark variability in a regular OS. In the future, this will be optimized again by copying each character in place, thus completely avoiding the staging arena.
Callbacks: add operator==() and operator!=() (PR #168).
Tree: on error or assert prefer the error callback stored into the tree's current Callbacks, rather than the global Callbacks (PR #168).
detail::stack<>: improve behavior when assigning from objects Callbacks, test all rule-of-5 scenarios (PR #168).
- Improve formatting of error messages.
Thanks
0.3.0
Github release: 0.3.0
Breaking changes
Despite ryml being still in a non-stable 0.x.y version, considerable effort goes into trying to avoid breaking changes. However, this release has to collect on the semantic versioning prerogative for breaking changes. This is a needed improvement, so sorry for any nuisance!
The allocation and error callback logic was revamped on the amalgamation PR. Now trees and parsers receive (and store) a full ryml::Callbacks object instead of the (now removed) ryml::Allocator which had a pointer to a (now removed) ryml::MemoryResourceCallbacks, which was a (now removed) ryml::MemoryResource. To be clear, the Callbacks class is unchanged, other than removing some unneeded helper methods.
These changes were motivated by unfortunate name clashes between c4::Allocator/ryml::Allocator and c4::MemoryResource/ryml::MemoryResource, occurring if <c4/allocator.hpp> or <c4/memory_resource.hpp> were included before <c4/yml/common.hpp>. They also significantly simplify this part of the API, making it really easier to understand.
As a consequence of the above changes, the global memory resource getters and setters for ryml were also removed: ryml::get_memory_resource()/ryml::set_memory_resource().
Here's an example of the required changes in client code. First the old client code (from the quickstart):
2 struct PerTreeMemoryExample : public ryml::MemoryResource
4 void *allocate(size_t len, void * hint) override;
5 void free(void *mem, size_t len) override;
8 PerTreeMemoryExample mrp;
9 PerTreeMemoryExample mr1;
10 PerTreeMemoryExample mr2;
12 ryml::Parser parser = {ryml::Allocator(&mrp)};
13 ryml::Tree tree1 = {ryml::Allocator(&mr1)};
14 ryml::Tree tree2 = {ryml::Allocator(&mr2)};
Should now be rewritten to:
2 struct PerTreeMemoryExample
4 ryml::Callbacks callbacks() const; // helper to create the callbacks
7 PerTreeMemoryExample mrp;
8 PerTreeMemoryExample mr1;
9 PerTreeMemoryExample mr2;
11 ryml::Parser parser = {mrp.callbacks()};
12 ryml::Tree tree1 = {mr1.callbacks()};
13 ryml::Tree tree2 = {mr2.callbacks()};
New features
- Add amalgamation into a single header file (PR #172):
- The amalgamated header will be available together with the deliverables from each release.
- To generate the amalgamated header:
1 $ python tools/amalgamate.py ryml_all.hpp
3 - To use the amalgamated header:
4 - Include at will in any header of your project.
5 - In one - and only one - of your project source files, `#define RYML_SINGLE_HDR_DEFINE_NOW` and then `#include <ryml_all.hpp>`. This will enable the function and class definitions in the header file. For example, here's a sample program:
8 #define RYML_SINGLE_HDR_DEFINE_NOW // do this before the include
9 #include <ryml_all.hpp>
12 auto tree = ryml::parse("{foo: bar}");
13 std::cout << tree["foo"].val() << "\n";
- Add
Tree::change_type() and NodeRef::change_type() (PR #171):
2 // clears a node and sets its type to a different type (one of `VAL`, `SEQ`, `MAP`):
3 Tree t = parse("{keyval0: val0, keyval1: val1, keyval2: val2}");
7 Tree expected = parse("{keyval0: val0, keyval1: {}, keyval2: []}");
8 assert(emitrs<std::string>(t) == emitrs<std::string>(expected));
- Add support for compilation with emscripten (WebAssembly+javascript) (PR #176).
Fixes
- Take block literal indentation as relative to current indentation level, rather than as an absolute indentation level (PR #178):
5 child2 # indentation is 4, not 2
- Fix parsing when seq member maps start without a key (PR #178):
1 # previously this resulted in a parse error
3 - - : another empty key
- Prefer passing
substr and csubstr by value instead of const reference (PR #171)
- Fix #173: add alias target
ryml::ryml (PR #174)
- Speedup compilation of tests by removing linking with yaml-cpp and libyaml. (PR #177)
- Fix c4core#53: cmake install targets were missing call to
export() (PR #179).
- Add missing export to
Tree (PR #181).
Thanks
0.2.3
Github release: 0.2.3
This release is focused on bug fixes and compliance with the YAML test suite.
New features
- Add support for CPU architectures aarch64, ppc64le, s390x.
- Update c4core to 0.1.7
Tree and NodeRef: add document getter doc() and docref()
2 Tree tree = parse(R"(---
7 NodeRef stream = t.rootref();
8 assert(stream.is_stream());
9 // tree.doc(i): get the index of the i-th doc node.
10 // Equivalent to tree.child(tree.root_id(), i)
11 assert(tree.doc(0) == 1u);
12 assert(tree.doc(1) == 2u);
13 // tree.docref(i), same as above, return NodeRef
14 assert(tree.docref(0).val() == "doc0");
15 assert(tree.docref(1).val() == "doc1");
16 // stream.doc(i), same as above, given NodeRef
17 assert(stream.doc(0).val() == "doc0");
18 assert(stream.doc(1).val() == "doc1");
Fixes
- Fix compilation with
C4CORE_NO_FAST_FLOAT (PR #163)
Flow maps
- Fix parse of multiline plain scalars inside flow maps (PR #161):
2 # all parsed as "matches %": 20
Tags
- Fix parsing of tags followed by comments in sequences (PR #161):
2 - !!map # Block collection
Quoted scalars
- Fix filtering of tab characters in quoted scalars (PR #161):
6 # now correctly parsed as "Empty line\nas a line feed"
11 <SPC>2nd non-empty<SPC>
13 # now correctly parsed as " 1st non-empty\n2nd non-empty 3rd non-empty "
- Fix filtering of backslash characters in double-quoted scalars (PR #161):
1 # test cases NP9H, Q8AD
5 to a line feed, or <TAB>\
7 # now correctly parsed as "folded to a space,\nto a line feed, or \t \tnon-content"
- Ensure filtering of multiline quoted scalars (PR #161):
1 # all scalars now correctly parsed as "quoted string",
2 # both for double and single quotes
Block scalars
- Ensure no newlines are added when emitting block scalars (PR #161)
- Fix parsing of block spec with both chomping and indentation: chomping may come before or after the indentation (PR #161):
1 # the block scalar specs below now have the same effect.
2 # test cases: D83L, P2AD
4 explicit indent and chomp
6 chomp and explicit indent
- Fix inference of block indentation with leading blank lines (PR #161):
1 # test cases: 4QFQ, 7T8X
6 # parsed as "\n\n child1"
17 # parsed as "\n\nliteral\n \n\ntext\n"
- Fix parsing of same-indentation block scalars (PR #161):
2 # all docs have the same value: "%!PS-Adobe-2.0"
- Folded block scalars: fix folding of newlines at the border of indented parts (PR #161):
2 # now correctly parsed as "Sammy Sosa completed another fine season with great stats.\n\n 63 Home Runs\n 0.288 Batting Average\n\nWhat a year!\n"
4 Sammy Sosa completed another
5 fine season with great stats.
13 # now correctly parsed as "foo \n\n \t bar\n\nbaz\n"
- Folded block scalars: fix folding of newlines when the indented part is at the begining of the scalar (PR #161):
5 # parsed as a: " more indented\nregular\n"
11 # parsed as b: "\n\n more indented\nregular\n"
Plain scalars
- Fix parsing of whitespace within plain scalars (PR #161):
15 # is now correctly parsed as "value with\ntabs tabs\nfoo\nbar baz"
17 # test case 9YRD, EX5H (trailing whitespace)
24 # is now correctly parsed as "a b c d\ne"
- Fix parsing of unindented plain scalars at the root level scope (PR #161)
5 # was correctly parsed as "Bare scalar is indented"
6 --- # but this failed to parse successfully:
10 # is now correctly parsed as "Bare scalar is not indented"
23 # now correctly parsed as "value with\ntabs tabs\nfoo\nbar baz"
25 --- # test cases EXG3, 82AN
28 # now correctly parsed as "---word1 word2"
- Fix parsing of comments within plain scalars
2 --- # now correctly parsed as "word1"
5 --- # now correctly parsed as [word1, word2]
Python API
- Add missing node predicates in SWIG API definition (PR #166):
is_anchor_or_ref()
is_key_quoted()
is_val_quoted()
is_quoted()
Thanks
0.2.2
Github release: 0.2.2
Yank python package 0.2.1, was accidentally created while iterating the PyPI submission from the Github action. This release does not add any change, and is functionally the same as 0.2.1.
0.2.1
Github release: 0.2.1
This release is focused on bug fixes and compliance with the YAML test suite.
Breaking changes
- Fix parsing behavior of root-level scalars: now these are parsed into a DOCVAL, not SEQ->VAL (5ba0d56, from PR #144). Eg,
3 --- # previously this was parsed as
- Cleanup type predicate API (PR #155)):
- ensure all type predicates from
Tree and NodeRef forward to the corresponding predicate in NodeType
- remove all type predicates and methods from
NodeData; use the equivalent call from Tree or NodeRef. For example, for is_map():
2 Tree t = parse("{foo: bar}");
3 size_t map_id = t.root_id();
4 NodeRef map = t.rootref();
5 t.get(map_id)->is_map(); // compile error: no longer exists
6 assert(t.is_map(map_id)); // OK
7 assert(map.is_map()); // OK
- Further cleanup to the type predicate API will be done in the future, especially around the
.has_*() vs corresponding .is_*() naming scheme.
New features & improvements
Tree::lookup_path_or_modify(): add overload to graft existing branches (PR #141)
- Callbacks: improve test coverage (PR #141)
- YAML test suite (PR #144, PR #145): big progress towards compliance with the suite. There are still a number of existing problems, which are the subject of ongoing work. See the list of current known failures in the test suite file.
- Python wheels and source package are now uploaded to PyPI as part of the release process.
Fixes
Anchors and references
- Fix resolving of nodes with keyref+valref (PR #144):
{&a a: &b b, *b: *a}
- Fix parsing of implicit scalars when tags are present (PR #145):
- Fix #151: scalars beginning with
* or & or << are now correctly quoted when emitting (PR #156).
- Also from PR #156, map inheritance nodes like
<<: *anchor or <<: [*anchor1, *anchor2] now have a KEYREF flag in their type (until a call to Tree::resolve()):
2 Tree tree = parse("{map: &anchor {foo: bar}, copy: {<<: *anchor}}");
3 assert(tree["copy"]["<<"].is_key_ref()); // previously this did not hold
4 assert(tree["copy"]["<<"].is_val_ref()); // ... but this did
Tags
- Fix parsing of tag dense maps and seqs (PR #144):
2 k: !!seq [ a, !!str b],
10 !!str foo: !!map # there was a parse error with the multiple tags
Whitespace
- Fix parsing of double-quoted scalars with tabs (PR #145):
2 # is now correctly parsed as "This has a<TAB>tab"
- Fix filtering of leading and trailing whitespace within double-quoted scalars (PR #145):
1 # test case 4ZYM, 7A4E, TL85
8 # is now correctly parsed as " foo\nbar\nbaz "
- Fix parsing of tabs within YAML tokens (PR #145):
1 ---<TAB>scalar # test case K54U
2 ---<TAB>{} # test case Q5MG
- Fix parsing of flow-style maps with ommitted values without any space (PR #145):
2 - {foo: , bar: , baz: } # this was parsed correctly as {foo: ~, bar: ~, baz: ~}
3 - {foo:, bar:, baz:} # ... but this was parsed as {'foo:': , 'bar:': ~, 'baz:': ~}
Scalars
- Unescape forward slashes in double quoted string (PR #145):
1 --- escaped slash: "a\/b" # test case 3UYS
3 --- escaped slash: "a/b"
- Fix filtering of indented regions in folded scalars (PR #145): is now correctly parsed as
\nfolded line\nnext line\n * bullet\n\n * list\n * lines\n\nlast line\n.
- Fix parsing of special characters within plain scalars (PR #145):
5 # now correctly parsed as "k:#foo &a !t s !t s"
- Fix parsing of comments after complex keys (PR #145):
5 # now correctly parsed as {key: value}
- Fix parsing of consecutive complex keys within maps (PR #145)
7 # now correctly parsed as {a: ~, b: ~, c: ~, d: ~, e: ~}
- Fix #152: parse error with folded scalars that are the last in a container (PR #157):
3 # before the fix, this folded scalar failed to parse
5 exec pg_isready -U "dog" -d "dbname=dog" -h 127.0.0.1 -p 5432
- Fix: documents consisting of a quoted scalar now retain the VALQUO flag (PR #156)
2 Tree tree = parse("'this is a quoted scalar'");
3 assert(tree.rootref().is_doc());
4 assert(tree.rootref().is_val());
5 assert(tree.rootref().is_val_quoted());
Document structure
- Empty docs are now parsed as a docval with a null node:
1 --- # test cases 6XDY, 6ZKB, 9BXL, PUW8
is now parsed as
- Prevent creation of DOC nodes from stream-level comments or tags (PR #145):
4 %TAG ! tag:example.com,2000:app/
was parsed as
4 # notice the empty doc in here
and it is now correctly parsed as (other than the known limitation that ryml does not do tag lookup).
General
- Fix #147: serialize/deserialize special float values
.nan, .inf, -.inf (PR #149)
- Fix #142:
preprocess_json(): ensure quoted ranges are skipped when slurping containers
- Ensure error macros expand to a single statement (PR #141)
- Update c4core to 0.1.4
Special thanks
0.2.0
Github release: 0.2.0
New features & improvements
- Enable parsing into nested nodes (87f4184)
as_json() can now be called with tree and node id (4c23041)
- Add
Parser::reserve_stack() (f31fb9f)
- Add uninstall target (PR #122)
- Update c4core to v0.1.1
- Add a quickstart sample with build examples.
- Update README.md to refer to the quickstart
- Add gdb visualizers
- Add
SO_VERSION to shared builds
Fixes
- Fix #139: substr and csubstr not found in ryml namespace
- Fix #131: resolve references to map keys
- Fix #129: quoted strings starting with * parsed as references
- Fix #128: segfault on nonexistent anchor
- Fix #124: parse failure in comments with trailing colon
- Fix #121: preserve quotes when emitting scalars
- Fix #103: ambiguous parsing of null/empty scalars
- Fix #90: CMAKE_CXX_STANDARD ignored
- Fix #40: quadratic complexity from use of
sscanf(f)
- Fix emitting json to streams (dc6af83)
- Set the global memory resource when setting global callbacks (511cba0)
- Fix python packaging (PR #102)
Special thanks
0.1.0
Github release: 0.1.0
This is the first ryml release. Future releases will have a more organized changelog; for now, only recent major changes are listed.
Please be aware that there are still some anticipated breaking changes in the API before releasing the 1.0 major version. These are highlighted in https://github.com/biojppm/rapidyaml/blob/v0.1.0/ROADMAP.md "the repo ROADMAP".
- 2020/October
- MR#89:
- fix python API generation in windows
- use github actions for testing and releasing
- MR#88: fix MacOS compilation and installs. This is a fix from c4core.
- MR#88: fix boolean handling. This is a fix from c4core.
true and false are now parsed correctly into bool variables:
2 auto tree = parse("{foo: true, bar: false}");
Emitting bool variables still defaults to 0/1, like the default behaviour in the STL. To explicitly request true/false use c4::fmt::boolalpha():
2 node << var; // "1" or "0"
3 node << c4::fmt::boolalpha(var); // "true" or "false"
- 2020/September
- [***Breaking change***] MR#85 null values in YAML are now parsed to null strings instead of YAML null token "~":
2 auto tree = parse("{foo: , bar: ''}");
4 assert(tree["foo"].val() == "~");
5 assert(tree["bar"].val() == "");
7 assert(tree["foo"].val() == nullptr); // notice that this is now null
8 assert(tree["bar"].val() == "");
- MR#85 Commas after tags are now allowed:
1 {foo: !!str, bar: ''} # now the comma does not cause an error
- MR#81: Always compile with extra pedantic warnings.
- 2020/May
- [***Breaking change***] the error callback now receives a source location object:
3 using pfn_error = void (*)(const char* msg, size_t msg_len, void *user_data);
5 using pfn_error = void (*)(const char* msg, size_t msg_len, Location location, void *user_data);
- Parser fixes to improve test suite success: MR#73, MR#71, MR#68, MR#67, MR#66
- Fix compilation as DLL on windows MR#69