Rosetta Utilities  2015.09
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>

Public Member Functions

 YamlEmitter (std::ostream &out)
 
virtual ~YamlEmitter ()
 
virtual void start_doc ()
 Start a new YAML document, ending the previous one first if necessary. More...
 
- Public Member Functions inherited from basic::Emitter
 Emitter (std::ostream &out)
 
virtual ~Emitter ()
 
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::pointer::ReferenceCount
 ReferenceCount ()
 Default constructor. More...
 
virtual ~ReferenceCount ()
 

Protected Member Functions

virtual std::string quote_string (std::string const &s)
 YAML only quotes strings when they contain special characters. More...
 
virtual void do_indent (bool write_comma=true)
 Handle pretty-printing indentation. Don't want to use commas for opening/closing brace/bracket. More...
 
virtual void write_list_marker ()
 YAML uses "-" for list items when in block (indented) mode. More...
 
virtual void start_raw (bool is_map, bool indent)
 
virtual void end_raw ()
 
- 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

- Public Types inherited from utility::pointer::ReferenceCount
typedef platform::Size Size
 
typedef platform::Size size_type
 
- Protected Attributes inherited from basic::Emitter
std::ostream & out_
 
std::string indent_str_
 
std::vector< boolin_map_
 
std::vector< boolfirst_
 
std::vector< boolindent_
 
std::vector< intindent_depth_
 

Detailed Description

Emitter for more classically formatted YAML.

Constructor & Destructor Documentation

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

References start_raw().

virtual basic::YamlEmitter::~YamlEmitter ( )
inlinevirtual
basic::YamlEmitter::YamlEmitter ( )
private
basic::YamlEmitter::YamlEmitter ( YamlEmitter const &  )
private

Member Function Documentation

virtual void basic::YamlEmitter::do_indent ( bool  write_comma = true)
inlineprotectedvirtual

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

Implements basic::Emitter.

References basic::Emitter::depth(), basic::Emitter::first_, basic::Emitter::indent_, basic::Emitter::indent_depth_, basic::Emitter::indent_str_, and basic::Emitter::out_.

virtual void basic::YamlEmitter::end_raw ( )
inlineprotectedvirtual

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

Implements basic::Emitter.

References basic::Emitter::first_, basic::Emitter::in_map_, basic::Emitter::indent_, basic::Emitter::indent_depth_, and basic::Emitter::out_.

virtual std::string basic::YamlEmitter::quote_string ( std::string const &  s)
inlineprotectedvirtual

YAML only quotes strings when they contain special characters.

Implements basic::Emitter.

References basic::Emitter::escape_string().

virtual void basic::YamlEmitter::start_doc ( )
inlinevirtual

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().

virtual void basic::YamlEmitter::start_raw ( bool  is_map,
bool  indent 
)
inlineprotectedvirtual

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

Implements basic::Emitter.

References basic::Emitter::first_, basic::Emitter::in_map_, basic::Emitter::indent_, basic::Emitter::indent_depth_, and basic::Emitter::out_.

Referenced by start_doc(), and YamlEmitter().

virtual void basic::YamlEmitter::write_list_marker ( )
inlineprotectedvirtual

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

Implements basic::Emitter.

References basic::Emitter::indent_, and basic::Emitter::out_.


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