cprover
jsont Class Reference

#include <json.h>

Inheritance diagram for jsont:
[legend]
Collaboration diagram for jsont:
[legend]

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
}
 
typedef std::vector< jsontarrayt
 
typedef std::map< std::string, jsontobjectt
 

Public Member Functions

bool is_string () const
 
bool is_number () const
 
bool is_object () const
 
bool is_array () 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_object (std::ostream &out, const objectt &object, unsigned indent)
 Basic handling of the printing of a JSON object. More...
 
static void output_key (std::ostream &out, const std::string &key)
 

Public Attributes

kindt kind
 
arrayt array
 
objectt object
 
std::string value
 

Static Public Attributes

static const jsont null_json_object
 

Protected Member Functions

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

Static Protected Member Functions

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

Detailed Description

Definition at line 23 of file json.h.

Member Typedef Documentation

◆ arrayt

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

Definition at line 128 of file json.h.

◆ objectt

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

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

Constructor & Destructor Documentation

◆ jsont() [1/3]

jsont::jsont ( )
inline

Definition at line 74 of file json.h.

Referenced by json_boolean(), and json_arrayt::push_back().

◆ jsont() [2/3]

jsont::jsont ( kindt  _kind)
inlineexplicitprotected

Definition at line 118 of file json.h.

◆ jsont() [3/3]

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

Definition at line 122 of file json.h.

Member Function Documentation

◆ clear()

void jsont::clear ( void  )
inline

Definition at line 90 of file json.h.

References array, J_NULL, kind, and value.

◆ escape_string()

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

Definition at line 15 of file json.cpp.

Referenced by output_key(), and output_rec().

◆ is_array()

bool jsont::is_array ( ) const
inline

◆ is_false()

bool jsont::is_false ( ) const
inline

Definition at line 64 of file json.h.

References J_FALSE, and kind.

◆ is_null()

bool jsont::is_null ( ) const
inline

◆ is_number()

bool jsont::is_number ( ) const
inline

Definition at line 44 of file json.h.

References J_NUMBER, and kind.

◆ is_object()

bool jsont::is_object ( ) const
inline

Definition at line 49 of file json.h.

References J_OBJECT, and kind.

Referenced by java_bytecode_languaget::get_language_options().

◆ is_string()

bool jsont::is_string ( ) const
inline

◆ is_true()

bool jsont::is_true ( ) const
inline

Definition at line 59 of file json.h.

References J_TRUE, and kind.

◆ json_boolean()

static jsont jsont::json_boolean ( bool  value)
inlinestatic

◆ make_array()

◆ make_object()

◆ operator[]()

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

Definition at line 102 of file json.h.

References null_json_object.

◆ output()

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

Definition at line 78 of file json.h.

References output_rec().

Referenced by interpretert::command(), and operator<<().

◆ output_key()

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

◆ 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 129 of file json.cpp.

References output_key().

Referenced by json_stream_objectt::output_finalizer(), and output_rec().

◆ 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 56 of file json.cpp.

References array, escape_string(), J_ARRAY, J_FALSE, J_NULL, J_NUMBER, J_OBJECT, J_STRING, J_TRUE, kind, output_object(), and value.

Referenced by output(), and json_stream_arrayt::push_back().

◆ swap()

void jsont::swap ( jsont other)

Definition at line 158 of file json.cpp.

References array, kind, object, and value.

Referenced by parse_json(), and json_parsert::pop().

Member Data Documentation

◆ array

◆ kind

◆ null_json_object

const jsont jsont::null_json_object
static

Definition at line 113 of file json.h.

Referenced by operator[](), json_stream_objectt::operator[](), and json_objectt::operator[]().

◆ object

objectt jsont::object

Definition at line 132 of file json.h.

Referenced by json_irept::convert_from_json(), swap(), and yyjsonparse().

◆ value


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