libdballe 9.6
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
dballe::core::JSONWriter Class Reference

JSON serializer. More...

#include <json.h>

Public Member Functions

 JSONWriter (std::ostream &out)
 
void reset ()
 Reset the serializer state, to cancel the current output and prepare for a new one.
 
void start_list ()
 
void end_list ()
 
void start_mapping ()
 
void end_mapping ()
 
void add_null ()
 
void add_bool (bool val)
 
void add_int (int val)
 
void add_double (double val)
 
void add_cstring (const char *val)
 
void add_string (const std::string &val)
 
template<typename T >
void add_ostream (const T &val)
 
void add_number (const std::string &val)
 
void add_level (const Level &val)
 
void add_trange (const Trange &val)
 
void add_datetime (const Datetime &val)
 
void add_datetimerange (const DatetimeRange &val)
 
void add_coords (const Coords &val)
 
void add_ident (const Ident &val)
 
void add_var (const wreport::Var &val)
 
void add_station (const Station &s)
 
void add_dbstation (const DBStation &s)
 
void add_values (const Values &values)
 
void add_dbvalues (const DBValues &values)
 
void add_break ()
 
void add (const std::string &val)
 
void add (const char *val)
 
void add (double val)
 
void add (int val)
 
void add (bool val)
 
void add (size_t val)
 
void add (wreport::Varcode val)
 
void add (const Level &val)
 
void add (const Trange &val)
 
void add (const Datetime &val)
 
void add (const DatetimeRange &val)
 
void add (const Coords &val)
 
void add (const Ident &val)
 
void add (const wreport::Var &val)
 
void add (const Station &s)
 
void add (const DBStation &s)
 
void add (const Values &v)
 
void add (const DBValues &v)
 
template<typename T >
void add (const char *a, T b)
 
template<typename T >
void add_list (const T &val)
 

Protected Types

enum  State {
  LIST_FIRST , LIST , MAPPING_KEY_FIRST , MAPPING_KEY ,
  MAPPING_VAL
}
 

Protected Member Functions

void val_head ()
 Append whatever separator is needed (if any) before a new value.
 
void jputc (char c)
 
void jputs (const char *s)
 

Protected Attributes

std::ostream & out
 
std::vector< State > stack
 

Detailed Description

JSON serializer.

It is called with a sequence of sax-like events, and appends the resulting JSON to a string.

The JSON output is all in one line, so that end of line can be used as separator between distinct JSON records.


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