rapidyaml  0.16.0
parseandemitYAML,anddoitfast
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>

Inheritance diagram for c4::yml::Emitter< Writer >:

Public Member Functions

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

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

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.

45  : Writer(std::forward<WriterArgs>(args)...)
46  , m_tree()
47  , m_opts(opts)
48  , m_col()
49  , m_depth()
50  , m_ilevel()
51  , m_pws()
52  , m_flow_pws()
53  {}

Member Function Documentation

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 48 of file emitter.def.hpp.

Referenced by c4::yml::emit_json(), c4::yml::emit_yaml(), and c4::yml::operator<<().

49 {
50  RYML_ASSERT_BASIC_CB_(tree->callbacks(), !tree || !tree->empty() || id == NONE);
51  if(!tree || tree->empty())
52  return;
53  if(id == NONE)
54  id = tree->root_id();
55  RYML_CHECK_VISIT_CB_(tree->callbacks(), id < tree->capacity(), tree, id);
56  m_tree = tree;
57  m_col = 0;
58  m_depth = 0;
59  m_ilevel = 0;
60  m_pws = PWS_NONE_;
61  m_flow_pws = {};
62  if(type == EMIT_YAML)
63  emit_yaml_(id);
64  else if(type == EMIT_JSON)
65  json_emit_(id);
66  else
67  RYML_ERR_BASIC_CB_(m_tree->callbacks(), "unknown emit type"); // LCOV_EXCL_LINE
68  m_tree = nullptr;
69 }
an index to none
Definition: common.hpp:131
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: