rapidyaml 0.15.2
parse and emit YAML, and do it fast
Loading...
Searching...
No Matches
c4::yml::Emitter< Writer > Class Template Reference

A YAML/JSON emitter, templated on a writer class such as WriterBuf, WriterFile, or WriterOStream. More...

#include <emitter.hpp>

Public Member Functions

template<class ... WriterArgs>
 Emitter (EmitOptions const &opts, WriterArgs &&...args) noexcept
 Construct the emitter and its internal Writer state.
void emit_as (EmitType_e type, Tree const *tree, id_type id=NONE)
 emit!
EmitOptions const & options () const noexcept
 get the emit options for this object

Detailed Description

template<class Writer>
class c4::yml::Emitter< Writer >

A YAML/JSON emitter, templated on a writer class such as WriterBuf, WriterFile, or WriterOStream.

Definition at line 34 of file emitter.hpp.

Constructor & Destructor Documentation

◆ Emitter()

template<class Writer>
template<class ... WriterArgs>
c4::yml::Emitter< Writer >::Emitter ( EmitOptions const & opts,
WriterArgs &&... args )
inlinenoexcept

Construct the emitter and its internal Writer state.

Parameters
optsEmitOptions
argsarguments to be forwarded to the constructor of the writer.

Definition at line 44 of file emitter.hpp.

46 , m_tree()
47 , m_opts(opts)
48 , m_col()
49 , m_depth()
50 , m_ilevel()
51 , m_pws()
52 , m_flow_pws()
53 {}
A YAML/JSON emitter, templated on a writer class such as WriterBuf, WriterFile, or WriterOStream.
Definition emitter.hpp:35

Member Function Documentation

◆ emit_as()

template<class Writer>
void c4::yml::Emitter< Writer >::emit_as ( EmitType_e type,
Tree const * tree,
id_type id = NONE )

emit!

Parameters
typespecify what to emit (YAML or JSON)
treethe tree to emit
idthe id of the node to emit

Definition at line 52 of file emitter.def.hpp.

53{
54 _RYML_ASSERT_BASIC_(tree->callbacks(), !tree || !tree->empty() || id == NONE);
55 if(!tree || tree->empty())
56 return;
57 if(id == NONE)
58 id = tree->root_id();
59 _RYML_CHECK_VISIT_(tree->callbacks(), id < tree->capacity(), tree, id);
60 m_tree = tree;
61 m_col = 0;
62 m_depth = 0;
63 m_ilevel = 0;
64 m_pws = _PWS_NONE;
65 m_flow_pws = {};
66 if(type == EMIT_YAML)
67 emit_yaml_(id);
68 else if(type == EMIT_JSON)
69 json_emit_(id);
70 else
71 _RYML_ERR_BASIC_(m_tree->callbacks(), "unknown emit type"); // LCOV_EXCL_LINE
72 m_tree = nullptr;
73}

◆ options()

template<class Writer>
EmitOptions const & c4::yml::Emitter< Writer >::options ( ) const
inlinenoexcept

get the emit options for this object

Definition at line 68 of file emitter.hpp.

68{ return m_opts; }

The documentation for this class was generated from the following files:
  • /home/docs/checkouts/readthedocs.org/user_builds/rapidyaml/checkouts/latest/src/c4/yml/emitter.hpp
  • /home/docs/checkouts/readthedocs.org/user_builds/rapidyaml/checkouts/latest/src/c4/yml/emitter.def.hpp