oos::json_array Class Reference

Class representing the json array type. More...

#include <json_array.hpp>

Inherits oos::json_type.

Public Types

typedef std::vector< json_valuet_value_vector
 
typedef
t_value_vector::const_iterator 
const_iterator
 
typedef t_value_vector::iterator iterator
 
typedef t_value_vector::size_type size_type
 

Public Member Functions

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

Friends

OOS_API std::istream & operator>> (std::istream &str, json_array &ary)
 

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 array type.

This class represents the json array type.

Member Typedef Documentation

typedef t_value_vector::const_iterator oos::json_array::const_iterator

Shortcut for value vector iterator.

typedef t_value_vector::iterator oos::json_array::iterator

Shortcut for value vector const iterator.

typedef t_value_vector::size_type oos::json_array::size_type

Shortcut for value vector size type.

Shortcut for value vector.

Constructor & Destructor Documentation

oos::json_array::json_array ( size_t  size)
explicit

Create a new json_array with a predefined size.

Parameters
sizeThe size of the array.
oos::json_array::json_array ( const json_value x)

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

Parameters
xThe json_value to set.

Member Function Documentation

iterator oos::json_array::begin ( )

Return the begin iterator

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

Return the constant begin iterator

Returns
The constant begin iterator.
bool oos::json_array::empty ( ) const

Returns true on empty array.

Returns
True on empty array.
iterator oos::json_array::end ( )

Return the end iterator

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

Return the constant end iterator

Returns
The constant end iterator.
json_array& oos::json_array::operator= ( const json_value x)

Assign from a json_value

Parameters
xThe json_value to assign from.
Returns
This.
virtual json_value& oos::json_array::operator[] ( size_t  index)
inlinevirtual

Returns a json_value at the given index.

Parameters
indexThe index of the json_value.
Returns
the corresponding json_value.

Reimplemented from oos::json_type.

virtual const json_value& oos::json_array::operator[] ( size_t  index) const
inlinevirtual

Returns a json_value at the given index.

Parameters
indexThe index of the json_value.
Returns
the corresponding json_value.

Reimplemented from oos::json_type.

virtual bool oos::json_array::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_array::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 void oos::json_array::push_back ( const json_value x)
inlinevirtual

Adds a json_value to the current value.

Parameters
xThe json_value to add.

Reimplemented from oos::json_type.

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

Returns the size of the json_value. If the concrete type doesn't support this method an exception is thrown.

Returns
The size of the json_value.

Reimplemented from oos::json_type.

Friends And Related Function Documentation

OOS_API std::istream& operator>> ( std::istream &  str,
json_array ary 
)
friend

Input operator for a json_array.

Parameters
strThe input stream to read from.
aryThe json_array read in.
Returns
The modified input stream.

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