Function sample_emit_to_file

Synopsis

#include <samples/quickstart.cpp>

void sample_emit_to_file()

Description

emit to a FILE*

demonstrates how to emit to a FILE*

Mentioned in

Source

Lines 3000-3027 in samples/quickstart.cpp. Line 67 in samples/quickstart.cpp.

void sample_emit_to_file()
{
    ryml::csubstr yml = 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
)";
    auto tree = ryml::parse(yml);
    // this is emitting to stdout, but of course you can pass in any
    // FILE* obtained from fopen()
    size_t len = ryml::emit(tree, tree.root_id(), stdout);
    // the return value is the number of characters that were written
    // to the file
    CHECK(len == yml.len);
}





Add Discussion as Guest

Log in