HoverRace  2.0
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
HoverRace::Util::yaml::Emitter Class Reference

Wrapper for the LibYAML emitter. More...

#include <Emitter.h>

Public Member Functions

 Emitter (FILE *file, bool versionDirective=true)
 Create a new emitter for a file handle. More...
 
 Emitter (std::ostream &os, bool versionDirective=true)
 Create a new emitter for an output stream. More...
 
 Emitter (std::string &s, bool versionDirective=true)
 Create a new emitter for a string. More...
 
virtual ~Emitter ()
 Destructor. More...
 
void EndMap ()
 End the current map. More...
 
void EndSeq ()
 End the current sequence. More...
 
void MapKey (const std::string &s)
 Write the key of a map. More...
 
void StartMap ()
 Start a map. More...
 
void StartSeq ()
 Start a sequence. More...
 
void Value (const std::string &val)
 Write a single string value. More...
 
void Value (const char *val)
 Write a single string value. More...
 
void Value (bool val)
 Write a single boolean value. More...
 
void Value (int val)
 Write a single integer value. More...
 
void Value (double val)
 Write a single floating-point value. More...
 
void Value (float val)
 Write a single floating-point value. More...
 
void Value (const HoverRace::Util::OS::path_t &path)
 Write a single path value. More...
 
template<class T >
void Value (const T &val)
 

Protected Member Functions

void InitEmitter ()
 Initialize the LibYAML emitter. More...
 
void InitStream (bool versionDirective)
 Initialize the stream and document. More...
 

Private Member Functions

 Emitter ()=delete
 

Private Attributes

yaml_emitter_t emitter
 

Detailed Description

Wrapper for the LibYAML emitter.

Constructor & Destructor Documentation

HoverRace::Util::yaml::Emitter::Emitter ( )
privatedelete
HoverRace::Util::yaml::Emitter::Emitter ( FILE *  file,
bool  versionDirective = true 
)

Create a new emitter for a file handle.

Parameters
fileAn open file for writing (may not be null). It is the caller's job to close the file when the emitter is destroyed.
versionDirectiveInclude the YAML version directive at the start.
HoverRace::Util::yaml::Emitter::Emitter ( std::ostream &  os,
bool  versionDirective = true 
)

Create a new emitter for an output stream.

Parameters
osThe output stream.
versionDirectiveInclude the YAML version directive at the start.
HoverRace::Util::yaml::Emitter::Emitter ( std::string &  s,
bool  versionDirective = true 
)

Create a new emitter for a string.

Parameters
sThe output string.
versionDirectiveInclude the YAML version directive at the start.
HoverRace::Util::yaml::Emitter::~Emitter ( )
virtual

Destructor.

Member Function Documentation

void HoverRace::Util::yaml::Emitter::EndMap ( )

End the current map.

void HoverRace::Util::yaml::Emitter::EndSeq ( )

End the current sequence.

void HoverRace::Util::yaml::Emitter::InitEmitter ( )
protected

Initialize the LibYAML emitter.

This should only be called from the constructor.

void HoverRace::Util::yaml::Emitter::InitStream ( bool  versionDirective)
protected

Initialize the stream and document.

This should only be called from the constructor.

Parameters
versionDirectiveInclude the YAML version directive at the start.
void HoverRace::Util::yaml::Emitter::MapKey ( const std::string &  s)

Write the key of a map.

Parameters
sThe key name (may not be empty).
void HoverRace::Util::yaml::Emitter::StartMap ( )

Start a map.

Writing a map involves:

  • First, call StartMap().
  • For each key-value pair, first write the key with MapKey(), then write the value (e.g. Value(), another map, a sequence, etc.)
  • Finally, call EndMap() to close the map.
void HoverRace::Util::yaml::Emitter::StartSeq ( )

Start a sequence.

Writing a sequence involves:

  • First, call StartSeq().
  • For each element: call Value() for a single scalar value, or add a map or a sub-sequence.
  • Finally, call EndSeq() to close the sequence.
void HoverRace::Util::yaml::Emitter::Value ( const std::string &  val)

Write a single string value.

Parameters
valThe value.
void HoverRace::Util::yaml::Emitter::Value ( const char *  val)

Write a single string value.

Parameters
valThe value (may not be nullptr).
void HoverRace::Util::yaml::Emitter::Value ( bool  val)

Write a single boolean value.

Parameters
valThe value.
void HoverRace::Util::yaml::Emitter::Value ( int  val)

Write a single integer value.

Parameters
valThe value.
void HoverRace::Util::yaml::Emitter::Value ( double  val)

Write a single floating-point value.

Parameters
valThe value.
void HoverRace::Util::yaml::Emitter::Value ( float  val)

Write a single floating-point value.

Parameters
valThe value.
void HoverRace::Util::yaml::Emitter::Value ( const HoverRace::Util::OS::path_t path)

Write a single path value.

Parameters
pathThe value.
template<class T >
void HoverRace::Util::yaml::Emitter::Value ( const T &  val)
inline

Member Data Documentation

yaml_emitter_t HoverRace::Util::yaml::Emitter::emitter
private

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