rapidyaml 0.15.2
parse and emit YAML, and do it fast
Loading...
Searching...
No Matches
c4::yml::as_json Struct Reference

tag type to mark a tree or node to be emitted as yaml when using operator<<, with options. More...

#include <emit_ostream.hpp>

Public Member Functions

 as_json (Tree const &t, EmitOptions const &opts={}) noexcept
 as_json (Tree const &t, id_type id, EmitOptions const &opts={}) noexcept
 as_json (ConstNodeRef const &n, EmitOptions const &opts={}) noexcept

Public Attributes

Tree const * tree
id_type node
EmitOptions options

Detailed Description

tag type to mark a tree or node to be emitted as yaml when using operator<<, with options.

For example:

Tree t = parse_in_arena("{foo: bar}");
std::cout << t; // emits YAML
std::cout << as_yaml(t, id); // emits YAML from nested node
std::cout << as_yaml(t, EmitOptions{}.flow_spc(true)); // emits YAML forcing spaces after flow commas
void parse_in_arena(Parser *parser, csubstr filename, csubstr yaml, Tree *tree, id_type node_id)
(1) parse YAML into an existing tree node. The filename will be used in any error messages arising du...
Definition parse.cpp:209
A lightweight object containing options to be used when emitting.
tag type to mark a tree or node to be emitted as yaml when using operator<< .

Definition at line 43 of file emit_ostream.hpp.

Constructor & Destructor Documentation

◆ as_json() [1/3]

c4::yml::as_json::as_json ( Tree const & t,
EmitOptions const & opts = {} )
inlinenoexcept

Definition at line 48 of file emit_ostream.hpp.

48{}) noexcept : tree(&t), node(t.root_id_maybe()), options(opts) {}
Tree const * tree
EmitOptions options

◆ as_json() [2/3]

c4::yml::as_json::as_json ( Tree const & t,
id_type id,
EmitOptions const & opts = {} )
inlinenoexcept

Definition at line 49 of file emit_ostream.hpp.

49{}) noexcept : tree(&t), node(id), options(opts) {}

◆ as_json() [3/3]

c4::yml::as_json::as_json ( ConstNodeRef const & n,
EmitOptions const & opts = {} )
inlinenoexcept

Definition at line 50 of file emit_ostream.hpp.

50{}) noexcept : tree(n.tree()), node(n.id()), options(opts) {}

Member Data Documentation

◆ tree

Tree const* c4::yml::as_json::tree

Definition at line 45 of file emit_ostream.hpp.

◆ node

id_type c4::yml::as_json::node

Definition at line 46 of file emit_ostream.hpp.

◆ options

EmitOptions c4::yml::as_json::options

Definition at line 47 of file emit_ostream.hpp.


The documentation for this struct was generated from the following file:
  • /home/docs/checkouts/readthedocs.org/user_builds/rapidyaml/checkouts/latest/src/c4/yml/emit_ostream.hpp