oos::json_object Class Reference

Class representing the json object type. More...

#include <json_object.hpp>

Inherits oos::json_type.

Public Types

typedef std::map< json_string,
json_value
t_string_value_map
 
typedef
t_string_value_map::const_iterator 
const_iterator
 
typedef
t_string_value_map::iterator 
iterator
 
typedef
t_string_value_map::size_type 
size_type
 

Public Member Functions

 json_object (const json_value &x)
 
json_objectoperator= (const json_value &x)
 
virtual bool parse (std::istream &in)
 
virtual void print (std::ostream &out) const
 
void clear ()
 
bool empty () const
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
bool contains (const std::string &key)
 
void insert (const json_string &key, const json_value &value)
 
virtual json_valueoperator[] (const std::string &key)
 
virtual size_t size () const
 
- Public Member Functions inherited from oos::json_type
virtual json_valueoperator[] (size_t index)
 
virtual const json_valueoperator[] (size_t index) const
 
virtual void push_back (const json_value &x)
 
std::string type () const
 

Friends

OOS_API std::istream & operator>> (std::istream &str, json_object &obj)
 

Additional Inherited Members

- Protected Member Functions inherited from oos::json_type
 json_type (const std::string &name)
 
void type (const std::string &type)
 
- Static Protected Attributes inherited from oos::json_type
static json_parser parser
 

Detailed Description

Class representing the json object type.

This class represents the json object type.

Member Typedef Documentation

typedef t_string_value_map::const_iterator oos::json_object::const_iterator

Shortcut for the map const iterator

typedef t_string_value_map::iterator oos::json_object::iterator

Shortcut for the map iterator

typedef t_string_value_map::size_type oos::json_object::size_type

Shortcut for the map size type

Shortcut for the string value map

Constructor & Destructor Documentation

oos::json_object::json_object ( const json_value x)

Creates a new json_object and initializes the value with the given json_value.

Parameters
xThe json_value to set.

Member Function Documentation

iterator oos::json_object::begin ( )

Return the begin iterator of the children map.

Returns
The begin iterator.
const_iterator oos::json_object::begin ( ) const

Return the constant begin iterator of the children map.

Returns
The constant begin iterator.
void oos::json_object::clear ( )

Removes every children of the json_object.

bool oos::json_object::contains ( const std::string &  key)

Returns true if the json_object contains a child element with the given key.

Parameters
keyThe key to validate.
Returns
True if the key exists.
bool oos::json_object::empty ( ) const

Returns true if the json_object doesn't have a child element.

Returns
True if json_object is empty.
iterator oos::json_object::end ( )

Return the end iterator of the children map.

Returns
The end iterator.
const_iterator oos::json_object::end ( ) const

Return the constant end iterator of the children map.

Returns
The constant end iterator.
void oos::json_object::insert ( const json_string key,
const json_value value 
)

Inserts a json_value with a given key.

Parameters
keyThe key of the json_value to insert.
valueThe json_value to insert.
json_object& oos::json_object::operator= ( const json_value x)

Assign from a json_value

Parameters
xThe json_value to assign from.
Returns
This.
virtual json_value& oos::json_object::operator[] ( const std::string &  key)
virtual

Returns a json_value with the given key.

Parameters
keyThe key of the json_value.
Returns
the corresponding json_value.

Reimplemented from oos::json_type.

virtual bool oos::json_object::parse ( std::istream &  in)
virtual

Parses in json input stream

Parameters
inThe json input stream
Returns
True if stream was parsed correctly

Implements oos::json_type.

virtual void oos::json_object::print ( std::ostream &  out) const
virtual

Prints the json type (tree) to a output stream.

Parameters
outThe stream to write on.

Implements oos::json_type.

virtual size_t oos::json_object::size ( ) const
inlinevirtual

Returns the size of the json_object

Returns
The size of the json_object.

Reimplemented from oos::json_type.

Friends And Related Function Documentation

OOS_API std::istream& operator>> ( std::istream &  str,
json_object obj 
)
friend

Input operator for a json_object.

Parameters
strThe input stream to read from.
objThe json_object read in.
Returns
The modified input stream.

The documentation for this class was generated from the following file:
  • json/json_object.hpp