Rosetta
Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
basic::YamlEmitter Class Reference

Emitter for more classically formatted YAML. More...

#include <Emitter.hh>

Inheritance diagram for basic::YamlEmitter:
Inheritance graph
[legend]

Public Member Functions

 YamlEmitter (std::ostream &out)
 
 ~YamlEmitter () override
 
void start_doc () override
 Start a new YAML document, ending the previous one first if necessary. More...
 
- Public Member Functions inherited from basic::Emitter
 Emitter (std::ostream &out)
 
 ~Emitter () override
 
void flush ()
 Flush the underlying output stream. More...
 
template<typename T >
void write (T const &data)
 Write method for use inside lists / arrays. More...
 
void start_list (bool indent=true)
 Write method for use inside lists / arrays. More...
 
void start_map (bool indent=true)
 Write method for use inside lists / arrays. More...
 
template<typename T >
void write (std::string const &label, T const &data)
 Write method for use inside maps / dicts / objects. More...
 
void start_list (std::string const &label, bool indent=true)
 Write method for use inside maps / dicts / objects. More...
 
void start_list (const char *label, bool indent=true)
 Write method for use inside maps / dicts / objects. More...
 
void start_map (std::string const &label, bool indent=true)
 Write method for use inside maps / dicts / objects. More...
 
void start_map (const char *label, bool indent=true)
 Write method for use inside maps / dicts / objects. More...
 
void end_list ()
 Counterpart to start_list() – writes closing bracket. More...
 
void end_map ()
 Counterpart to start_map() – writes closing brace. More...
 
void end (size_t desired_depth=0)
 By default, closes all open maps/lists, ending the document. More...
 
int depth () const
 Number of closing brackets/braces required to end document (non-negative) More...
 
void set_indent (int num_spaces)
 Number of spaces used for indenting. Default is one. More...
 
- Public Member Functions inherited from utility::VirtualBase
 VirtualBase ()=default
 Default constructor. More...
 
virtual ~VirtualBase ()=default
 The virtual destructor is one of the main reasons for the VirtualBase class. More...
 
 VirtualBase (VirtualBase const &)=default
 
 VirtualBase (VirtualBase &&)=default
 
VirtualBaseoperator= (VirtualBase const &)=default
 
VirtualBaseoperator= (VirtualBase &&)=default
 

Protected Member Functions

std::string quote_string (std::string const &s) override
 YAML only quotes strings when they contain special characters. More...
 
void do_indent (bool write_comma=true) override
 Handle pretty-printing indentation. Don't want to use commas for opening/closing brace/bracket. More...
 
void write_list_marker () override
 YAML uses "-" for list items when in block (indented) mode. More...
 
void start_raw (bool is_map, bool indent) override
 
void end_raw () override
 
- Protected Member Functions inherited from basic::Emitter
 Emitter ()
 
 Emitter (Emitter const &)
 
bool assert_in (bool in_map, std::string const &msg)
 Check that we're in the expected context (either map or list) More...
 
void write_label (std::string const &label)
 Write the key part of a key-value pair. More...
 
void write_raw (bool b)
 
void write_raw (int i)
 
void write_raw (long l)
 
void write_raw (float f)
 
void write_raw (double d)
 
void write_raw (std::string const &s)
 
std::string escape_string (std::string const &s, bool &needs_quotes_out)
 Converts special characters (newlines, etc) to escape codes (
, etc). More...
 

Private Member Functions

 YamlEmitter ()
 
 YamlEmitter (YamlEmitter const &)
 

Additional Inherited Members

- Protected Attributes inherited from basic::Emitter
std::ostream & out_
 
std::string indent_str_
 
std::vector< bool > in_map_
 
std::vector< bool > first_
 
std::vector< bool > indent_
 
std::vector< int > indent_depth_
 

Detailed Description

Emitter for more classically formatted YAML.

Constructor & Destructor Documentation

◆ YamlEmitter() [1/3]

basic::YamlEmitter::YamlEmitter ( std::ostream &  out)
inline

References start_raw().

◆ ~YamlEmitter()

basic::YamlEmitter::~YamlEmitter ( )
inlineoverride

◆ YamlEmitter() [2/3]

basic::YamlEmitter::YamlEmitter ( )
private

◆ YamlEmitter() [3/3]

basic::YamlEmitter::YamlEmitter ( YamlEmitter const &  )
private

Member Function Documentation

◆ do_indent()

void basic::YamlEmitter::do_indent ( bool  write_comma = true)
inlineoverrideprotectedvirtual

Handle pretty-printing indentation. Don't want to use commas for opening/closing brace/bracket.

Implements basic::Emitter.

References basic::Emitter::depth(), create_a3b_hbs::first, basic::Emitter::first_, create_a3b_hbs::i, binder::indent(), basic::Emitter::indent_, basic::Emitter::indent_depth_, basic::Emitter::indent_str_, and basic::Emitter::out_.

◆ end_raw()

void basic::YamlEmitter::end_raw ( )
inlineoverrideprotectedvirtual

YAML only uses brackets and braces if data is not being indented.

Implements basic::Emitter.

References basic::Emitter::first_, basic::Emitter::in_map_, binder::indent(), basic::Emitter::indent_, basic::Emitter::indent_depth_, and basic::Emitter::out_.

◆ quote_string()

std::string basic::YamlEmitter::quote_string ( std::string const &  s)
inlineoverrideprotectedvirtual

YAML only quotes strings when they contain special characters.

Implements basic::Emitter.

References basic::Emitter::escape_string(), docking::s, and predPRE::t.

◆ start_doc()

void basic::YamlEmitter::start_doc ( )
inlineoverridevirtual

Start a new YAML document, ending the previous one first if necessary.

Implements basic::Emitter.

References basic::Emitter::end(), basic::Emitter::out_, and start_raw().

◆ start_raw()

void basic::YamlEmitter::start_raw ( bool  is_map,
bool  indent 
)
inlineoverrideprotectedvirtual

YAML only uses brackets and braces if data is not being indented.

Implements basic::Emitter.

References basic::Emitter::first_, basic::Emitter::in_map_, binder::indent(), basic::Emitter::indent_, basic::Emitter::indent_depth_, and basic::Emitter::out_.

Referenced by start_doc(), and YamlEmitter().

◆ write_list_marker()

void basic::YamlEmitter::write_list_marker ( )
inlineoverrideprotectedvirtual

YAML uses "-" for list items when in block (indented) mode.

Implements basic::Emitter.

References binder::indent(), basic::Emitter::indent_, and basic::Emitter::out_.


The documentation for this class was generated from the following file: