Guitar
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
jstream::Writer Class Reference

#include <jstream.h>

Public Member Functions

 Writer (std::function< void(char const *p, int n)> fn={})
 
 ~Writer ()
 
void enable_indent (bool enabled)
 
void enable_newline (bool enabled)
 
void allow_nan (bool allow)
 
void print_name (std::string const &name)
 
void start_object (std::string const &name={})
 
void end_object ()
 
void object (std::string const &name, std::function< void()> const &fn)
 
void start_array (std::string const &name={})
 
void end_array ()
 
void array (std::string const &name, std::function< void()> const &fn)
 
bool number (std::string const &name, double v)
 
void number (double v)
 
void string (std::string const &name, std::string const &s)
 
void string (std::string const &s)
 
void symbol (std::string const &name, StateType v)
 
void boolean (std::string const &name, bool b)
 
void null ()
 

Protected Member Functions

void print (char const *p, int n)
 
void print (char c)
 
void print (char const *p)
 
void print (std::string const &s)
 

Private Member Functions

void print_newline ()
 
void print_indent ()
 
bool print_number (double v)
 
void print_string (std::string const &s)
 
bool print_value (std::string const &name, std::function< bool()> const &fn)
 
void print_object (std::string const &name={}, std::function< void()> const &fn={})
 
void print_array (std::string const &name={}, std::function< void()> const &fn={})
 
void end_block ()
 

Private Attributes

std::vector< int > stack
 
std::function< void(char const *p, int n)> output_fn
 
bool enable_indent_ = true
 
bool enable_newline_ = true
 
bool allow_nan_ = false
 

Constructor & Destructor Documentation

◆ Writer()

jstream::Writer::Writer ( std::function< void(char const *p, int n)>  fn = {})
inline

◆ ~Writer()

jstream::Writer::~Writer ( )
inline
Here is the call graph for this function:

Member Function Documentation

◆ allow_nan()

void jstream::Writer::allow_nan ( bool  allow)
inline

◆ array()

void jstream::Writer::array ( std::string const &  name,
std::function< void()> const &  fn 
)
inline
Here is the call graph for this function:

◆ boolean()

void jstream::Writer::boolean ( std::string const &  name,
bool  b 
)
inline
Here is the call graph for this function:

◆ enable_indent()

void jstream::Writer::enable_indent ( bool  enabled)
inline

◆ enable_newline()

void jstream::Writer::enable_newline ( bool  enabled)
inline

◆ end_array()

void jstream::Writer::end_array ( )
inline
Here is the call graph for this function:

◆ end_block()

void jstream::Writer::end_block ( )
inlineprivate
Here is the call graph for this function:

◆ end_object()

void jstream::Writer::end_object ( )
inline
Here is the call graph for this function:

◆ null()

void jstream::Writer::null ( )
inline
Here is the call graph for this function:

◆ number() [1/2]

void jstream::Writer::number ( double  v)
inline
Here is the call graph for this function:

◆ number() [2/2]

bool jstream::Writer::number ( std::string const &  name,
double  v 
)
inline
Here is the call graph for this function:

◆ object()

void jstream::Writer::object ( std::string const &  name,
std::function< void()> const &  fn 
)
inline
Here is the call graph for this function:

◆ print() [1/4]

void jstream::Writer::print ( char  c)
inlineprotected
Here is the call graph for this function:

◆ print() [2/4]

void jstream::Writer::print ( char const *  p)
inlineprotected
Here is the call graph for this function:

◆ print() [3/4]

void jstream::Writer::print ( char const *  p,
int  n 
)
inlineprotected

◆ print() [4/4]

void jstream::Writer::print ( std::string const &  s)
inlineprotected
Here is the call graph for this function:

◆ print_array()

void jstream::Writer::print_array ( std::string const &  name = {},
std::function< void()> const &  fn = {} 
)
inlineprivate

◆ print_indent()

void jstream::Writer::print_indent ( )
inlineprivate
Here is the call graph for this function:

◆ print_name()

void jstream::Writer::print_name ( std::string const &  name)
inline
Here is the call graph for this function:

◆ print_newline()

void jstream::Writer::print_newline ( )
inlineprivate
Here is the call graph for this function:

◆ print_number()

bool jstream::Writer::print_number ( double  v)
inlineprivate
Here is the call graph for this function:

◆ print_object()

void jstream::Writer::print_object ( std::string const &  name = {},
std::function< void()> const &  fn = {} 
)
inlineprivate

◆ print_string()

void jstream::Writer::print_string ( std::string const &  s)
inlineprivate
Here is the call graph for this function:

◆ print_value()

bool jstream::Writer::print_value ( std::string const &  name,
std::function< bool()> const &  fn 
)
inlineprivate
Here is the call graph for this function:

◆ start_array()

void jstream::Writer::start_array ( std::string const &  name = {})
inline

◆ start_object()

void jstream::Writer::start_object ( std::string const &  name = {})
inline

◆ string() [1/2]

void jstream::Writer::string ( std::string const &  name,
std::string const &  s 
)
inline
Here is the call graph for this function:

◆ string() [2/2]

void jstream::Writer::string ( std::string const &  s)
inline
Here is the call graph for this function:

◆ symbol()

void jstream::Writer::symbol ( std::string const &  name,
StateType  v 
)
inline
Here is the call graph for this function:

Member Data Documentation

◆ allow_nan_

bool jstream::Writer::allow_nan_ = false
private

◆ enable_indent_

bool jstream::Writer::enable_indent_ = true
private

◆ enable_newline_

bool jstream::Writer::enable_newline_ = true
private

◆ output_fn

std::function<void (char const *p, int n)> jstream::Writer::output_fn
private

◆ stack

std::vector<int> jstream::Writer::stack
private

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