GRASP rci-qed
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
cpptoml::toml_writer Class Reference

#include <cpptoml.h>

Public Member Functions

 toml_writer (std::ostream &s, const std::string &indent_space="\)
 
template<class T >
void visit (const value< T > &v, bool=false)
 
void visit (const table &t, bool in_array=false)
 
void visit (const array &a, bool=false)
 
void visit (const table_array &t, bool=false)
 

Static Public Member Functions

static std::string escape_string (const std::string &str)
 

Protected Member Functions

void write (const value< std::string > &v)
 
void write (const value< double > &v)
 
template<class T >
std::enable_if< is_one_of< T, int64_t, local_date, local_time, local_datetime, offset_datetime >::value >::type write (const value< T > &v)
 
void write (const value< bool > &v)
 
void write_table_header (bool in_array=false)
 
void write_table_item_header (const base &b)
 

Private Member Functions

void indent ()
 
template<class T >
void write (const T &v)
 
void endline ()
 

Private Attributes

std::ostream & stream_
 
const std::string indent_
 
std::vector< std::string > path_
 
bool has_naked_endline_
 

Detailed Description

Writer that can be passed to accept() functions of cpptoml objects and will output valid TOML to a stream.

Constructor & Destructor Documentation

◆ toml_writer()

cpptoml::toml_writer::toml_writer ( std::ostream &  s,
const std::string &  indent_space = "\t" 
)
inline

Construct a toml_writer that will write to the given stream

Member Function Documentation

◆ endline()

void cpptoml::toml_writer::endline ( )
inlineprivate

Write an endline out to the stream

◆ escape_string()

static std::string cpptoml::toml_writer::escape_string ( const std::string &  str)
inlinestatic

Escape a string for output.

◆ indent()

void cpptoml::toml_writer::indent ( )
inlineprivate

Indent the proper number of tabs given the size of the path.

◆ visit() [1/4]

template<class T >
void cpptoml::toml_writer::visit ( const value< T > &  v,
bool  = false 
)
inline

Output a base value of the TOML tree.

◆ visit() [2/4]

void cpptoml::toml_writer::visit ( const table t,
bool  in_array = false 
)
inline

Output a table element of the TOML tree

◆ visit() [3/4]

void cpptoml::toml_writer::visit ( const array a,
bool  = false 
)
inline

Output an array element of the TOML tree

Here is the call graph for this function:

◆ visit() [4/4]

void cpptoml::toml_writer::visit ( const table_array t,
bool  = false 
)
inline

Output a table_array element of the TOML tree

Here is the call graph for this function:

◆ write() [1/5]

void cpptoml::toml_writer::write ( const value< std::string > &  v)
inlineprotected

Write out a string.

Here is the call graph for this function:

◆ write() [2/5]

void cpptoml::toml_writer::write ( const value< double > &  v)
inlineprotected

Write out a double.

Here is the call graph for this function:

◆ write() [3/5]

template<class T >
std::enable_if< is_one_of<T, int64_t, local_date, local_time, local_datetime, offset_datetime>::value>::type cpptoml::toml_writer::write ( const value< T > &  v)
inlineprotected

Write out an integer, local_date, local_time, local_datetime, or offset_datetime.

Here is the call graph for this function:

◆ write() [4/5]

void cpptoml::toml_writer::write ( const value< bool > &  v)
inlineprotected

Write out a boolean.

Here is the call graph for this function:

◆ write() [5/5]

template<class T >
void cpptoml::toml_writer::write ( const T &  v)
inlineprivate

Write a value out to the stream.

◆ write_table_header()

void cpptoml::toml_writer::write_table_header ( bool  in_array = false)
inlineprotected

Write out the header of a table.

◆ write_table_item_header()

void cpptoml::toml_writer::write_table_item_header ( const base b)
inlineprotected

Write out the identifier for an item in a table.

Here is the call graph for this function:

Member Data Documentation

◆ has_naked_endline_

bool cpptoml::toml_writer::has_naked_endline_
private

◆ indent_

const std::string cpptoml::toml_writer::indent_
private

◆ path_

std::vector<std::string> cpptoml::toml_writer::path_
private

◆ stream_

std::ostream& cpptoml::toml_writer::stream_
private

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