CBMC
jsont Class Reference

#include <json.h>

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

Public Types

enum class  kindt {
  J_STRING , J_NUMBER , J_OBJECT , J_ARRAY ,
  J_TRUE , J_FALSE , 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 26 of file json.h.

Member Typedef Documentation

◆ arrayt

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

Definition at line 29 of file json.h.

◆ objectt

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

Definition at line 30 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 33 of file json.h.

Constructor & Destructor Documentation

◆ jsont() [1/5]

jsont::jsont ( )
inline

Definition at line 86 of file json.h.

◆ jsont() [2/5]

jsont::jsont ( kindt  _kind)
inlineexplicitprotected

Definition at line 140 of file json.h.

◆ jsont() [3/5]

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

Definition at line 144 of file json.h.

◆ jsont() [4/5]

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

Definition at line 148 of file json.h.

◆ jsont() [5/5]

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

Definition at line 152 of file json.h.

Member Function Documentation

◆ clear()

void jsont::clear ( void  )
inline

Definition at line 102 of file json.h.

◆ escape_string()

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

Definition at line 18 of file json.cpp.

◆ is_array()

bool jsont::is_array ( ) const
inline

Definition at line 61 of file json.h.

◆ is_boolean()

bool jsont::is_boolean ( ) const
inline

Definition at line 66 of file json.h.

◆ is_false()

bool jsont::is_false ( ) const
inline

Definition at line 76 of file json.h.

◆ is_null()

bool jsont::is_null ( ) const
inline

Definition at line 81 of file json.h.

◆ is_number()

bool jsont::is_number ( ) const
inline

Definition at line 51 of file json.h.

◆ is_object()

bool jsont::is_object ( ) const
inline

Definition at line 56 of file json.h.

◆ is_string()

bool jsont::is_string ( ) const
inline

Definition at line 46 of file json.h.

◆ is_true()

bool jsont::is_true ( ) const
inline

Definition at line 71 of file json.h.

◆ json_boolean()

static jsont jsont::json_boolean ( bool  value)
inlinestatic

Definition at line 97 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 114 of file json.h.

◆ output()

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

Definition at line 90 of file json.h.

◆ output_key()

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

Definition at line 154 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 132 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 59 of file json.cpp.

◆ swap()

void jsont::swap ( jsont other)

Definition at line 161 of file json.cpp.

Member Data Documentation

◆ array

arrayt jsont::array
protected

Definition at line 135 of file json.h.

◆ kind

kindt jsont::kind

Definition at line 44 of file json.h.

◆ null_json_object

const jsont jsont::null_json_object
static

Definition at line 125 of file json.h.

◆ object

objectt jsont::object
protected

Definition at line 136 of file json.h.

◆ value

std::string jsont::value

Definition at line 132 of file json.h.


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