cprover
jsont Class Reference

#include <json.h>

+ Inheritance diagram for jsont:
+ Collaboration diagram for jsont:

Public Types

enum  kindt {
  kindt::J_STRING, kindt::J_NUMBER, kindt::J_OBJECT, kindt::J_ARRAY,
  kindt::J_TRUE, kindt::J_FALSE, kindt::J_NULL
}
 

Public Member Functions

bool is_string () const
 
bool is_number () const
 
bool is_object () const
 
bool is_array () const
 
bool is_boolean () const
 
bool is_true () const
 
bool is_false () const
 
bool is_null () const
 
 jsont ()
 
void output (std::ostream &out) const
 
void swap (jsont &other)
 
void clear ()
 
json_arraytmake_array ()
 
json_objecttmake_object ()
 
const jsontoperator[] (const std::string &key) const
 
void output_rec (std::ostream &, unsigned indent) const
 Recursive printing of the json object. More...
 

Static Public Member Functions

static jsont json_boolean (bool value)
 
static void output_key (std::ostream &out, const std::string &key)
 
static void output_object (std::ostream &out, const objectt &object, unsigned indent)
 Basic handling of the printing of a JSON object. More...
 

Public Attributes

kindt kind
 
std::string value
 

Static Public Attributes

static const jsont null_json_object
 

Protected Types

typedef std::vector< jsontarrayt
 
typedef std::map< std::string, jsontobjectt
 

Protected Member Functions

 jsont (kindt _kind)
 
 jsont (kindt _kind, std::string _value)
 
 jsont (kindt _kind, arrayt &&entries)
 
 jsont (kindt _kind, objectt &&objects)
 

Static Protected Member Functions

static void escape_string (const std::string &, std::ostream &)
 

Protected Attributes

arrayt array
 
objectt object
 

Detailed Description

Definition at line 24 of file json.h.

Member Typedef Documentation

◆ arrayt

typedef std::vector<jsont> jsont::arrayt
protected

Definition at line 27 of file json.h.

◆ objectt

typedef std::map<std::string, jsont> jsont::objectt
protected

Definition at line 28 of file json.h.

Member Enumeration Documentation

◆ kindt

enum jsont::kindt
strong
Enumerator
J_STRING 
J_NUMBER 
J_OBJECT 
J_ARRAY 
J_TRUE 
J_FALSE 
J_NULL 

Definition at line 31 of file json.h.

Constructor & Destructor Documentation

◆ jsont() [1/5]

jsont::jsont ( )
inline

Definition at line 84 of file json.h.

◆ jsont() [2/5]

jsont::jsont ( kindt  _kind)
inlineexplicitprotected

Definition at line 138 of file json.h.

◆ jsont() [3/5]

jsont::jsont ( kindt  _kind,
std::string  _value 
)
inlineprotected

Definition at line 142 of file json.h.

◆ jsont() [4/5]

jsont::jsont ( kindt  _kind,
arrayt &&  entries 
)
inlineprotected

Definition at line 146 of file json.h.

◆ jsont() [5/5]

jsont::jsont ( kindt  _kind,
objectt &&  objects 
)
inlineprotected

Definition at line 150 of file json.h.

Member Function Documentation

◆ clear()

void jsont::clear ( )
inline

Definition at line 100 of file json.h.

◆ escape_string()

void jsont::escape_string ( const std::string &  src,
std::ostream &  out 
)
staticprotected

Definition at line 16 of file json.cpp.

◆ is_array()

bool jsont::is_array ( ) const
inline

Definition at line 59 of file json.h.

◆ is_boolean()

bool jsont::is_boolean ( ) const
inline

Definition at line 64 of file json.h.

◆ is_false()

bool jsont::is_false ( ) const
inline

Definition at line 74 of file json.h.

◆ is_null()

bool jsont::is_null ( ) const
inline

Definition at line 79 of file json.h.

◆ is_number()

bool jsont::is_number ( ) const
inline

Definition at line 49 of file json.h.

◆ is_object()

bool jsont::is_object ( ) const
inline

Definition at line 54 of file json.h.

◆ is_string()

bool jsont::is_string ( ) const
inline

Definition at line 44 of file json.h.

◆ is_true()

bool jsont::is_true ( ) const
inline

Definition at line 69 of file json.h.

◆ json_boolean()

static jsont jsont::json_boolean ( bool  value)
inlinestatic

Definition at line 95 of file json.h.

◆ make_array()

json_arrayt & jsont::make_array ( )
inline

Definition at line 418 of file json.h.

◆ make_object()

json_objectt & jsont::make_object ( )
inline

Definition at line 436 of file json.h.

◆ operator[]()

const jsont& jsont::operator[] ( const std::string &  key) const
inline

Definition at line 112 of file json.h.

◆ output()

void jsont::output ( std::ostream &  out) const
inline

Definition at line 88 of file json.h.

◆ output_key()

void jsont::output_key ( std::ostream &  out,
const std::string &  key 
)
static

Definition at line 152 of file json.cpp.

◆ output_object()

void jsont::output_object ( std::ostream &  out,
const objectt object,
unsigned  indent 
)
static

Basic handling of the printing of a JSON object.

Dispatches to output_rec for most of the hard work.

Parameters
outThe stream that the JSON object is to be printed to.
objectThe JSON object.
indentThe indentation level.

Definition at line 130 of file json.cpp.

◆ output_rec()

void jsont::output_rec ( std::ostream &  out,
unsigned  indent 
) const

Recursive printing of the json object.

Parameters
outThe stream object to have the json printed to.
indentThe indentation level.

Definition at line 57 of file json.cpp.

◆ swap()

void jsont::swap ( jsont other)

Definition at line 159 of file json.cpp.

Member Data Documentation

◆ array

arrayt jsont::array
protected

Definition at line 133 of file json.h.

◆ kind

kindt jsont::kind

Definition at line 42 of file json.h.

◆ null_json_object

const jsont jsont::null_json_object
static

Definition at line 123 of file json.h.

◆ object

objectt jsont::object
protected

Definition at line 134 of file json.h.

◆ value

std::string jsont::value

Definition at line 130 of file json.h.


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