Function sample_emit_nested_node

Synopsis

#include <samples/quickstart.cpp>

void sample_emit_nested_node()

Description

pick a nested node as the root when emitting

just like parsing into a nested node, you can also emit from a nested node.

Mentioned in

Source

Lines 3033-3059 in samples/quickstart.cpp. Line 68 in samples/quickstart.cpp.

void sample_emit_nested_node()
{
    auto tree = ryml::parse(R"(- a
- b
- x0: 1
  x1: 2
- champagne: Dom Perignon
  coffee: Arabica
  more:
    vinho verde: Soalheiro
    vinho tinto: Redoma 2017
  beer:
    - Rochefort 10
    - Busch
    - Leffe Rituel
- foo
- bar
- baz
- bat
)");
    CHECK(ryml::emitrs<std::string>(tree[3]["beer"][0]) == "- Rochefort 10\n");
    CHECK(ryml::emitrs<std::string>(tree[3]["beer"]) == R"(beer:
  - Rochefort 10
  - Busch
  - Leffe Rituel
)");
}





Add Discussion as Guest

Log in