Rapidyaml

Latest version: v0.5.0

Safety actively analyzes 624134 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 2

0.4.1

Fixes

- Fix [223](https://github.com/biojppm/rapidyaml/issues/223): assertion peeking into the last line when it was whitespaces only.

0.4.0

This release improves compliance with the [YAML test suite](https://github.com/yaml/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](https://github.com/biojppm/rapidyaml/pull/168), 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:
c++
substr readwrite = /*...*/;
Tree tree = parse_in_place(readwrite); // OK

csubstr readonly = /*...*/;
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.
c++
substr readwrite = /*...*/;
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()`:
c++
substr readwrite = /*...*/;
csubstr readonly = readwrite; // ok
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:
c++
// To obtain locations, use of the parser is needed:
ryml::Parser parser;
ryml::Tree tree = parser.parse_in_arena("source.yml", R"({
aa: contents,
foo: [one, [two, three]]
})");
// After parsing, on the first call to obtain a location,
// the parser will cache a lookup structure to accelerate
// tracking the location of a node, with complexity
// O(numchars(srcbuffer)). Then it will do the lookup, with
// complexity O(log(numlines(srcbuffer))).
ryml::Location loc = parser.location(tree.rootref());
assert(parser.location_contents(loc).begins_with("{"));
// note the location members are zero-based:
assert(loc.offset == 0u);
assert(loc.line == 0u);
assert(loc.col == 0u);
// On the next call to location(), the accelerator is reused
// and only the lookup is done.
loc = parser.location(tree["aa"]);
assert(parser.location_contents(loc).begins_with("aa"));
assert(loc.offset == 2u);
assert(loc.line == 1u);
assert(loc.col == 0u);
// KEYSEQ in flow style: points at the key
loc = parser.location(tree["foo"]);
assert(parser.location_contents(loc).begins_with("foo"));
assert(loc.offset == 16u);
assert(loc.line == 2u);
assert(loc.col == 0u);
loc = parser.location(tree["foo"][0]);
assert(parser.location_contents(loc).begins_with("one"));
assert(loc.line == 2u);
assert(loc.col == 6u);
// SEQ in flow style: location points at the opening '[' (there's no key)
loc = parser.location(tree["foo"][1]);
assert(parser.location_contents(loc).begins_with("["));
assert(loc.line == 2u);
assert(loc.col == 11u);
loc = parser.location(tree["foo"][1][0]);
assert(parser.location_contents(loc).begins_with("two"));
assert(loc.line == 2u);
assert(loc.col == 12u);
loc = parser.location(tree["foo"][1][1]);
assert(parser.location_contents(loc).begins_with("three"));
assert(loc.line == 2u);
assert(loc.col == 17u);
// NOTE: reusing the parser with a new YAML source buffer
// will invalidate the accelerator.

See more details in the [quickstart sample](https://github.com/biojppm/rapidyaml/blob/bfb073265abf8c58bbeeeed7fb43270e9205c71c/samples/quickstart.cpp#L3759). 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()`:
c++
assert(from_tag_long(TAG_MAP) == "<tag:yaml.org,2002:map>");
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](https://github.com/biojppm/rapidyaml/issues/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. See [PR#191](https://github.com/biojppm/rapidyaml/issues/191).
- Add preliminary support for bare-metal ARM architectures, with CI tests pending implementation of QEMU action. ([193](https://github.com/biojppm/rapidyaml/issues/193), [c4core#63](https://github.com/biojppm/c4core/issues/63)).
- Add preliminary support for RISC-V architectures, with CI tests pending availability of RISC-V based github actions. ([c4core69](https://github.com/biojppm/c4core/pulls/69)).


Fixes

- Fix edge cases of parsing of explicit keys (ie keys after `?`) ([PR212](https://github.com/biojppm/rapidyaml/pulls/212)):
yaml
all these were fixed:
? : empty
? explicit key this comment was not parsed correctly
? 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)](https://github.com/biojppm/rapidyaml/pull/211#issuecomment-1030688035) and thus it is disabled by default, and requires defining a macro or cmake option `RYML_WITH_TAB_TOKENS` to enable ([PR211](https://github.com/biojppm/rapidyaml/pulls/211)).
- Allow tab indentation in flow seqs ([PR215](https://github.com/biojppm/rapidyaml/pulls/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 ([PR210](https://github.com/biojppm/rapidyaml/pulls/210)).
- Fix handling of indentation when parsing block scalars ([PR210](https://github.com/biojppm/rapidyaml/pulls/210)):
yaml
---
|
hello
there
---
|
ciao
qua
---
- |
hello
there
- |
ciao
qua
---
foo: |
hello
there
bar: |
ciao
qua

- Fix parsing of maps when opening a scope with whitespace before the colon ([PR210](https://github.com/biojppm/rapidyaml/pulls/210)):
yaml
foo0 : bar
---
foo1 : bar the " :" was causing an assert
---
foo2 : bar
---
foo3 : bar
---
foo4 : bar

- Ensure container keys preserve quote flags when the key is quoted ([PR210](https://github.com/biojppm/rapidyaml/pulls/210)).
- Ensure scalars beginning with `%` are emitted with quotes (([PR216](https://github.com/biojppm/rapidyaml/pulls/216)).
- Fix [203](https://github.com/biojppm/rapidyaml/issues/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](https://github.com/biojppm/rapidyaml/pulls/207)):
- Fix [205](https://github.com/biojppm/rapidyaml/issues/205): fix parsing of escaped characters in double-quoted strings: `"\\\"\n\r\t\<TAB>\/\<SPC>\0\b\f\a\v\e\_\N\L\P"` ([PR#207](https://github.com/biojppm/rapidyaml/pulls/207)).
- Fix [204](https://github.com/biojppm/rapidyaml/issues/204): add decoding of unicode codepoints `\x` `\u` `\U` in double-quoted scalars:
c++
Tree tree = parse_in_arena(R"(["\u263A \xE2\x98\xBA \u2705 \U0001D11E"])");
assert(tree[0].val() == "☺ ☺ ✅ 𝄞");

This is mandated by the YAML standard and was missing from ryml ([PR207](https://github.com/biojppm/rapidyaml/pulls/207)).
- Fix emission of nested nodes which are sequences: when these are given as the emit root, the `- ` from the parent node was added ([PR210](https://github.com/biojppm/rapidyaml/pulls/210)):
c++
const ryml::Tree tree = ryml::parse_in_arena(R"(
- - Rochefort 10
- Busch
- Leffe Rituel
- - and so
- many other
- wonderful beers
)");
// before (error), YAML valid but not expected
//assert(ryml::emitrs<std::string>(tree[0][3]) == R"(- - and so
// - many other
// - wonderful beers
//)");
// now: YAML valid and expected
assert(ryml::emitrs<std::string>(tree[0][3]) == R"(- and so
- many other
- wonderful beers
)");

- Fix parsing of isolated `!`: should be an empty val tagged with `!` (UKK06-02) ([PR215](https://github.com/biojppm/rapidyaml/pulls/215)).
- Fix [193](https://github.com/biojppm/rapidyaml/issues/193): amalgamated header missing `#include <stdarg.h>` which prevented compilation in bare-metal `arm-none-eabi` ([PR 195](https://github.com/biojppm/rapidyaml/pull/195), requiring also [c4core #64](https://github.com/biojppm/c4core/pull/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](https://github.com/biojppm/rapidyaml/pull/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](https://github.com/biojppm/rapidyaml/pull/186)).
- Accept `null` with upper or mixed case: `Null` or `NULL`. Previously, only low-case `null` was accepted ([PR 186](https://github.com/biojppm/rapidyaml/pull/186)).
- Fix [182](https://github.com/biojppm/rapidyaml/issues/182): add missing export of DLL symbols, and document requirements for compiling shared library from the amalgamated header. [PR #183](https://github.com/biojppm/rapidyaml/pull/183), also [PR c4core#56](https://github.com/biojppm/c4core/pull/56) and [PR c4core#57](https://github.com/biojppm/c4core/pull/57).
- Fix [185](https://github.com/biojppm/rapidyaml/issues/185): compilation failures in earlier Xcode versions ([PR #187](https://github.com/biojppm/rapidyaml/pull/187) and [PR c4core#61](https://github.com/biojppm/c4core/pull/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 ([PR210](https://github.com/biojppm/rapidyaml/pulls/210)).
- Ensure error is emitted on unclosed flow sequence characters eg `[[[` ([PR210](https://github.com/biojppm/rapidyaml/pulls/210)). Same thing for `[]]`.
- Refactor error message building and parser debug logging to use the new dump facilities in c4core ([PR212](https://github.com/biojppm/rapidyaml/pulls/212)).
- Parse: fix read-after-free when duplicating a parser state node, when pushing to the stack requires a stack buffer resize ([PR210](https://github.com/biojppm/rapidyaml/pulls/210)).
- Add support for legacy gcc 4.8 ([PR217](https://github.com/biojppm/rapidyaml/pulls/217)).


Improvements

- Rewrite filtering of scalars to improve parsing performance ([PR 188](https://github.com/biojppm/rapidyaml/pull/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](https://github.com/biojppm/rapidyaml/pull/168)).
- `Tree`: on error or assert prefer the error callback stored into the tree's current `Callbacks`, rather than the global `Callbacks` ([PR 168](https://github.com/biojppm/rapidyaml/pull/168)).
- `detail::stack<>`: improve behavior when assigning from objects `Callbacks`, test all rule-of-5 scenarios ([PR 168](https://github.com/biojppm/rapidyaml/pull/168)).
- Improve formatting of error messages.


Thanks

- ingydotnet
- perlpunk
- cschreib
- fargies
- Xeonacid
- aviktorov
- xTVaser

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](https://semver.org/) 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](https://github.com/biojppm/rapidyaml/pull/172). 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):

c++
struct PerTreeMemoryExample : public ryml::MemoryResource
{
void *allocate(size_t len, void * hint) override;
void free(void *mem, size_t len) override;
};

PerTreeMemoryExample mrp;
PerTreeMemoryExample mr1;
PerTreeMemoryExample mr2;

ryml::Parser parser = {ryml::Allocator(&mrp)};
ryml::Tree tree1 = {ryml::Allocator(&mr1)};
ryml::Tree tree2 = {ryml::Allocator(&mr2)};


Should now be rewritten to:

c++
struct PerTreeMemoryExample
{
ryml::Callbacks callbacks() const; // helper to create the callbacks
};

PerTreeMemoryExample mrp;
PerTreeMemoryExample mr1;
PerTreeMemoryExample mr2;

ryml::Parser parser = {mrp.callbacks()};
ryml::Tree tree1 = {mr1.callbacks()};
ryml::Tree tree2 = {mr2.callbacks()};



New features
- Add amalgamation into a single header file ([PR 172](https://github.com/biojppm/rapidyaml/pull/172)):
- The amalgamated header will be available together with the deliverables from each release.
- To generate the amalgamated header:
console
$ python tools/amalgamate.py ryml_all.hpp

- To use the amalgamated header:
- Include at will in any header of your project.
- 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:
c++
include <iostream>
define RYML_SINGLE_HDR_DEFINE_NOW // do this before the include
include <ryml_all.hpp>
int main()
{
auto tree = ryml::parse("{foo: bar}");
std::cout << tree["foo"].val() << "\n";
}

- Add `Tree::change_type()` and `NodeRef::change_type()` ([PR 171](https://github.com/biojppm/rapidyaml/pull/171)):
c++
// clears a node and sets its type to a different type (one of `VAL`, `SEQ`, `MAP`):
Tree t = parse("{keyval0: val0, keyval1: val1, keyval2: val2}");
t[0].change_type(VAL);
t[1].change_type(MAP);
t[2].change_type(SEQ);
Tree expected = parse("{keyval0: val0, keyval1: {}, keyval2: []}");
assert(emitrs<std::string>(t) == emitrs<std::string>(expected));

- Add support for compilation with emscripten (WebAssembly+javascript) ([PR 176](https://github.com/biojppm/rapidyaml/pull/176)).

Fixes

- Take block literal indentation as relative to current indentation level, rather than as an absolute indentation level ([PR 178](https://github.com/biojppm/rapidyaml/pull/178)):
yaml
foo:
- |
child0
- |2
child2 indentation is 4, not 2

- Fix parsing when seq member maps start without a key ([PR 178](https://github.com/biojppm/rapidyaml/pull/178)):
yaml
previously this resulted in a parse error
- - : empty key
- - : another empty key

- Prefer passing `substr` and `csubstr` by value instead of const reference ([PR 171](https://github.com/biojppm/rapidyaml/pull/171))
- Fix [173](https://github.com/biojppm/rapidyaml/issues/173): add alias target `ryml::ryml` ([PR #174](https://github.com/biojppm/rapidyaml/pull/174))
- Speedup compilation of tests by removing linking with yaml-cpp and libyaml. ([PR 177](https://github.com/biojppm/rapidyaml/pull/177))
- Fix [c4core53](https://github.com/biojppm/c4core/issues/53): cmake install targets were missing call to `export()` ([PR #179](https://github.com/biojppm/c4core/pull/179)).
- Add missing export to `Tree` ([PR 181](https://github.com/biojppm/c4core/pull/181)).


Thanks

- aviktorov

0.2.3

This release is focused on bug fixes and compliance with the [YAML test suite](https://github.com/yaml/yaml-test-suite).

New features
- Add support for CPU architectures aarch64, ppc64le, s390x.
- Update c4core to [0.1.7](https://github.com/biojppm/c4core/releases/tag/v0.1.7)
- `Tree` and `NodeRef`: add document getter `doc()` and `docref()`
c++
Tree tree = parse(R"(---
doc0
---
doc1
)");
NodeRef stream = t.rootref();
assert(stream.is_stream());
// tree.doc(i): get the index of the i-th doc node.
// Equivalent to tree.child(tree.root_id(), i)
assert(tree.doc(0) == 1u);
assert(tree.doc(1) == 2u);
// tree.docref(i), same as above, return NodeRef
assert(tree.docref(0).val() == "doc0");
assert(tree.docref(1).val() == "doc1");
// stream.doc(i), same as above, given NodeRef
assert(stream.doc(0).val() == "doc0");
assert(stream.doc(1).val() == "doc1");


Fixes

- Fix compilation with `C4CORE_NO_FAST_FLOAT` ([PR 163](https://github.com/biojppm/rapidyaml/pull/163))

Flow maps

- Fix parse of multiline plain scalars inside flow maps ([PR 161](https://github.com/biojppm/rapidyaml/pull/161)):
yaml
test case UT92
all parsed as "matches %": 20
- { matches
% : 20 }
- { matches
%: 20 }
- { matches
%:
20 }



Tags

- Fix parsing of tags followed by comments in sequences ([PR 161](https://github.com/biojppm/rapidyaml/pull/161)):
yaml
test case 735Y
- !!map Block collection
foo : bar


Quoted scalars
- Fix filtering of tab characters in quoted scalars ([PR 161](https://github.com/biojppm/rapidyaml/pull/161)):
yaml
---
test case 5GBF
"Empty line
<TAB>
as a line feed"
now correctly parsed as "Empty line\nas a line feed"
---
test case PRH3
' 1st non-empty

<SPC>2nd non-empty<SPC>
<TAB>3rd non-empty '
now correctly parsed as " 1st non-empty\n2nd non-empty 3rd non-empty "

- Fix filtering of backslash characters in double-quoted scalars ([PR 161](https://github.com/biojppm/rapidyaml/pull/161)):
yaml
test cases NP9H, Q8AD
"folded<SPC>
to a space,<TAB>
<SPC>
to a line feed, or <TAB>\
\ <TAB>non-content"
now correctly parsed as "folded to a space,\nto a line feed, or \t \tnon-content"

- Ensure filtering of multiline quoted scalars ([PR 161](https://github.com/biojppm/rapidyaml/pull/161)):
yaml
all scalars now correctly parsed as "quoted string",
both for double and single quotes
---
"quoted
string"
--- "quoted
string"
---
- "quoted
string"
---
- "quoted
string"
---
"quoted
string": "quoted
string"
---
"quoted
string": "quoted
string"



Block scalars
- Ensure no newlines are added when emitting block scalars ([PR 161](https://github.com/biojppm/rapidyaml/pull/161))
- Fix parsing of block spec with both chomping and indentation: chomping may come before or after the indentation ([PR 161](https://github.com/biojppm/rapidyaml/pull/161)):
yaml
the block scalar specs below now have the same effect.
test cases: D83L, P2AD
- |2-
explicit indent and chomp
- |-2
chomp and explicit indent

- Fix [inference of block indentation](https://yaml.org/spec/1.2.2/#8111-block-indentation-indicator) with leading blank lines ([PR 161](https://github.com/biojppm/rapidyaml/pull/161)):
yaml
test cases: 4QFQ, 7T8X
- >


child1
parsed as "\n\n child1"
--- test case DWX9
|


literal


text

Comment
parsed as "\n\nliteral\n \n\ntext\n"

- Fix parsing of same-indentation block scalars ([PR 161](https://github.com/biojppm/rapidyaml/pull/161)):
yaml
test case W4TN
all docs have the same value: "%!PS-Adobe-2.0"
--- |
%!PS-Adobe-2.0
...
--- >
%!PS-Adobe-2.0
...
--- |
%!PS-Adobe-2.0
...
--- >
%!PS-Adobe-2.0
...
--- |
%!PS-Adobe-2.0
--- >
%!PS-Adobe-2.0
--- |
%!PS-Adobe-2.0
--- >
%!PS-Adobe-2.0

- Folded block scalars: fix folding of newlines at the border of indented parts ([PR 161](https://github.com/biojppm/rapidyaml/pull/161)):
yaml
test case 6VJK
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"
>
Sammy Sosa completed another
fine season with great stats.

63 Home Runs
0.288 Batting Average

What a year!
---
test case MJS9
now correctly parsed as "foo \n\n \t bar\n\nbaz\n"
>
foo<SPC>
<SPC>
<SPC><TAB><SPC>bar

baz

- Folded block scalars: fix folding of newlines when the indented part is at the begining of the scalar ([PR 161](https://github.com/biojppm/rapidyaml/pull/161)):
yaml
test case F6MC
a: >2
more indented
regular
parsed as a: " more indented\nregular\n"
b: >2


more indented
regular
parsed as b: "\n\n more indented\nregular\n"


Plain scalars
- Fix parsing of whitespace within plain scalars ([PR 161](https://github.com/biojppm/rapidyaml/pull/161)):
yaml
---
test case NB6Z
key:
value
with

tabs
tabs

foo

bar
baz

is now correctly parsed as "value with\ntabs tabs\nfoo\nbar baz"
---
test case 9YRD, EX5H (trailing whitespace)
a
b
c
d

e
is now correctly parsed as "a b c d\ne"

- Fix parsing of unindented plain scalars at the root level scope ([PR 161](https://github.com/biojppm/rapidyaml/pull/161))
yaml
--- this parsed
Bare
scalar
is indented
was correctly parsed as "Bare scalar is indented"
--- but this failed to parse successfully:
Bare
scalar
is not indented
is now correctly parsed as "Bare scalar is not indented"
--- test case NB6Z
value
with

tabs
tabs

foo

bar
baz

now correctly parsed as "value with\ntabs tabs\nfoo\nbar baz"
---
--- test cases EXG3, 82AN
---word1
word2
now correctly parsed as "---word1 word2"

- Fix parsing of comments within plain scalars
yaml
test case 7TMG
--- now correctly parsed as "word1"
word1
comment
--- now correctly parsed as [word1, word2]
[ word1
comment
, word2]


Python API
- Add missing node predicates in SWIG API definition ([PR 166](https://github.com/biojppm/rapidyaml/pull/166)):
- `is_anchor_or_ref()`
- `is_key_quoted()`
- `is_val_quoted()`
- `is_quoted()`


Thanks

--- mbs-c
--- simu
--- QuellaZhang

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](https://github.com/biojppm/rapidyaml/releases/tag/v0.2.1).

0.2.1

This release is focused on bug fixes and compliance with the [YAML test suite](https://github.com/yaml/yaml-test-suite).

Breaking changes

- Fix parsing behavior of root-level scalars: now these are parsed into a DOCVAL, not SEQ->VAL ([5ba0d56](https://github.com/biojppm/rapidyaml/pull/144/commits/5ba0d56904daef1509f0073695145c4835ab1b30), from [PR #144](https://github.com/biojppm/rapidyaml/pull/144)). Eg,
yaml
---
this is a scalar
--- previously this was parsed as
- this is a scalar

- Cleanup type predicate API ([PR 155](https://github.com/biojppm/rapidyaml/pull/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()`:
c++
Tree t = parse("{foo: bar}");
size_t map_id = t.root_id();
NodeRef map = t.rootref();
t.get(map_id)->is_map(); // compile error: no longer exists
assert(t.is_map(map_id)); // OK
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](https://github.com/biojppm/rapidyaml/pull/141))
- Callbacks: improve test coverage ([PR 141](https://github.com/biojppm/rapidyaml/pull/141))
- [YAML test suite](https://github.com/yaml/yaml-test-suite) ([PR #144](https://github.com/biojppm/rapidyaml/pull/144), [PR #145](https://github.com/biojppm/rapidyaml/pull/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](../test/test_suite/test_suite_parts.cpp) in the test suite file.
- Python wheels and source package are now [uploaded to PyPI](https://pypi.org/project/rapidyaml/) as part of the release process.


Fixes

Anchors and references
- Fix resolving of nodes with keyref+valref ([PR 144](https://github.com/biojppm/rapidyaml/pull/144)): `{&a a: &b b, *b: *a}`
- Fix parsing of implicit scalars when tags are present ([PR 145](https://github.com/biojppm/rapidyaml/pull/145)):
yaml
- &a test case PW8X
- a
- &a : a
b: &b
- &c : &a
- ? &d
- ? &e
: &a

- Fix [151](https://github.com/biojppm/rapidyaml/issues/151): scalars beginning with `*` or `&` or `<<` are now correctly quoted when emitting ([PR #156](https://github.com/biojppm/rapidyaml/pull/156)).
- Also from [PR 156](https://github.com/biojppm/rapidyaml/pull/156), map inheritance nodes like `<<: *anchor` or `<<: [*anchor1, *anchor2]` now have a `KEYREF` flag in their type (until a call to `Tree::resolve()`):
c++
Tree tree = parse("{map: &anchor {foo: bar}, copy: {<<: *anchor}}");
assert(tree["copy"]["<<"].is_key_ref()); // previously this did not hold
assert(tree["copy"]["<<"].is_val_ref()); // ... but this did


Tags
- Fix parsing of tag dense maps and seqs ([PR 144](https://github.com/biojppm/rapidyaml/pull/144)):
yaml
--- !!map {
k: !!seq [ a, !!str b],
j: !!seq
[ a, !!str b]
--- !!seq [
!!map { !!str k: v},
!!map { !!str ? k: v}
]
--- !!map
!!str foo: !!map there was a parse error with the multiple tags
!!int 1: !!float 20.0
!!int 3: !!float 40.0
--- !!seq
- !!map
!!str k1: v1
!!str k2: v2
!!str k3: v3


Whitespace
- Fix parsing of double-quoted scalars with tabs ([PR 145](https://github.com/biojppm/rapidyaml/pull/145)):
yaml
"This has a\ttab"
is now correctly parsed as "This has a<TAB>tab"

- Fix filtering of leading and trailing whitespace within double-quoted scalars ([PR 145](https://github.com/biojppm/rapidyaml/pull/145)):
yaml
test case 4ZYM, 7A4E, TL85
"
<SPC><SPC>foo<SPC>
<SPC>
<SPC><TAB><SPC>bar
<SPC><SPC>baz
"
is now correctly parsed as " foo\nbar\nbaz "

- Fix parsing of tabs within YAML tokens ([PR 145](https://github.com/biojppm/rapidyaml/pull/145)):
yaml
---<TAB>scalar test case K54U
---<TAB>{} test case Q5MG
--- test case DC7X
a: b<TAB>
seq:<TAB>
- a<TAB>
c: d<TAB>X

- Fix parsing of flow-style maps with ommitted values without any space ([PR 145](https://github.com/biojppm/rapidyaml/pull/145)):
yaml
test case 4ABK
- {foo: , bar: , baz: } this was parsed correctly as {foo: ~, bar: ~, baz: ~}
- {foo:, bar:, baz:} ... but this was parsed as {'foo:': , 'bar:': ~, 'baz:': ~}


Scalars
- Unescape forward slashes in double quoted string ([PR 145](https://github.com/biojppm/rapidyaml/pull/145)):
yaml
--- escaped slash: "a\/b" test case 3UYS
is now parsed as:
--- escaped slash: "a/b"

- Fix filtering of indented regions in folded scalars ([PR 145](https://github.com/biojppm/rapidyaml/pull/145)):
yaml
test case 7T8X
- >

folded
line

next
line
* bullet

* list
* lines

last
line

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](https://github.com/biojppm/rapidyaml/pull/145)):
yaml
test case 3MYT
k:foo
&a !t s
!t s
now correctly parsed as "k:foo &a !t s !t s"

- Fix parsing of comments after complex keys ([PR 145](https://github.com/biojppm/rapidyaml/pull/145)):
yaml
test case X8DW
? key
comment
: value
now correctly parsed as {key: value}

- Fix parsing of consecutive complex keys within maps ([PR 145](https://github.com/biojppm/rapidyaml/pull/145))
yaml
test case 7W2P, ZWK4
? a
? b
c:
? d
e:
now correctly parsed as {a: ~, b: ~, c: ~, d: ~, e: ~}

- Fix [152](https://github.com/biojppm/rapidyaml/issues/152): parse error with folded scalars that are the last in a container ([PR #157](https://github.com/biojppm/rapidyaml/pull/157)):
yaml
exec:
command:
before the fix, this folded scalar failed to parse
- |
exec pg_isready -U "dog" -d "dbname=dog" -h 127.0.0.1 -p 5432
parses: no

- Fix: documents consisting of a quoted scalar now retain the VALQUO flag ([PR 156](https://github.com/biojppm/rapidyaml/pull/156))
c++
Tree tree = parse("'this is a quoted scalar'");
assert(tree.rootref().is_doc());
assert(tree.rootref().is_val());
assert(tree.rootref().is_val_quoted());



Document structure
- Empty docs are now parsed as a docval with a null node:
yaml
--- test cases 6XDY, 6ZKB, 9BXL, PUW8
---
---

is now parsed as
yaml
--- ~
--- ~
--- ~

- Prevent creation of DOC nodes from stream-level comments or tags ([PR 145](https://github.com/biojppm/rapidyaml/pull/145)):
yaml
!foo "bar"
...
Global
%TAG ! tag:example.com,2000:app/
---
!foo "bar"

was parsed as
yaml
---
!foo "bar"
---
notice the empty doc in here
---
!foo "bar"

and it is now correctly parsed as
yaml
---
!foo "bar"
---
!foo "bar"

(other than the known limitation that ryml does not do tag lookup).


General

- Fix [147](https://github.com/biojppm/rapidyaml/issues/147): serialize/deserialize special float values `.nan`, `.inf`, `-.inf` ([PR #149](https://github.com/biojppm/rapidyaml/pull/149))
- Fix [142](https://github.com/biojppm/rapidyaml/issues/142): `preprocess_json()`: ensure quoted ranges are skipped when slurping containers
- Ensure error macros expand to a single statement ([PR 141](https://github.com/biojppm/rapidyaml/pull/141))
- Update c4core to [0.1.4](https://github.com/biojppm/c4core/releases/tag/v0.1.4)


Special thanks

- Gei0r

Page 1 of 2

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.