rapidyaml 0.15.2
parse and emit YAML, and do it fast
Loading...
Searching...
No Matches
Emit to an STL-like ostream

Classes

struct  c4::yml::as_json
 tag type to mark a tree or node to be emitted as yaml when using operator<<, with options. More...
struct  c4::yml::as_yaml
 tag type to mark a tree or node to be emitted as yaml when using operator<< . More...
struct  c4::yml::WriterOStream< OStream >
 A writer that outputs to an STL-like ostream. More...

Typedefs

template<class OStream>
using c4::yml::EmitterOStream = Emitter<WriterOStream<OStream>>

Functions

template<class OStream>
OStream & c4::yml::operator<< (OStream &stream, Tree const &tree)
 emit YAML to an STL-like ostream
template<class OStream>
OStream & c4::yml::operator<< (OStream &stream, ConstNodeRef const &node)
 emit YAML to an STL-like ostream This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class OStream>
OStream & c4::yml::operator<< (OStream &stream, as_json const &json_spec)
 emit JSON to an STL-like ostream
template<class OStream>
OStream & c4::yml::operator<< (OStream &stream, as_yaml const &yaml_spec)
 emit YAML to an STL-like ostream

Detailed Description

Typedef Documentation

◆ EmitterOStream

template<class OStream>
using c4::yml::EmitterOStream = Emitter<WriterOStream<OStream>>

Definition at line 30 of file emit_ostream.hpp.

Function Documentation

◆ operator<<() [1/4]

template<class OStream>
OStream & c4::yml::operator<< ( OStream & stream,
Tree const & tree )

emit YAML to an STL-like ostream

Definition at line 78 of file emit_ostream.hpp.

79{
81 em.emit_as(EMIT_YAML, &tree);
82 return stream;
83}
Emitter< WriterOStream< OStream > > EmitterOStream
A lightweight object containing options to be used when emitting.

◆ operator<<() [2/4]

template<class OStream>
OStream & c4::yml::operator<< ( OStream & stream,
ConstNodeRef const & node )

emit YAML to an STL-like ostream This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 89 of file emit_ostream.hpp.

90{
92 em.emit_as(EMIT_YAML, node.tree(), node.id());
93 return stream;
94}

◆ operator<<() [3/4]

template<class OStream>
OStream & c4::yml::operator<< ( OStream & stream,
as_json const & json_spec )

emit JSON to an STL-like ostream

Definition at line 99 of file emit_ostream.hpp.

100{
101 if(json_spec.tree && !json_spec.tree->empty())
102 {
103 EmitterOStream<OStream> em(json_spec.options, &stream);
104 id_type node_id = json_spec.node != NONE ? json_spec.node : json_spec.tree->root_id();
105 em.emit_as(EMIT_JSON, json_spec.tree, node_id);
106 }
107 return stream;
108}
RYML_ID_TYPE id_type
The type of a node id in the YAML tree; to override the default type, define the macro RYML_ID_TYPE t...
Definition common.hpp:305
@ NONE
an index to none
Definition common.hpp:312

◆ operator<<() [4/4]

template<class OStream>
OStream & c4::yml::operator<< ( OStream & stream,
as_yaml const & yaml_spec )

emit YAML to an STL-like ostream

Definition at line 113 of file emit_ostream.hpp.

114{
115 if(yaml_spec.tree && !yaml_spec.tree->empty())
116 {
117 EmitterOStream<OStream> em(yaml_spec.options, &stream);
118 id_type node_id = yaml_spec.node != NONE ? yaml_spec.node : yaml_spec.tree->root_id();
119 em.emit_as(EMIT_YAML, yaml_spec.tree, node_id);
120 }
121 return stream;
122}