cxxtools::JsonIOObject< ObjectType > Class Template Reference

Wrapper object to easily read objects as json from a input stream. More...

#include <cxxtools/json.h>

Inheritance diagram for cxxtools::JsonIOObject< ObjectType >:
cxxtools::JsonOObject< ObjectType >

Public Member Functions

 JsonIOObject (ObjectType &object)
ObjectType & object ()
- Public Member Functions inherited from cxxtools::JsonOObject< ObjectType >
 JsonOObject (const ObjectType &object, bool beautify=false)
 Constructor.
JsonOObjectbeautify (bool sw)
 Sets the formatting for json.
bool beautify () const
JsonOObjectplainkey (bool sw)
bool plainkey () const
const ObjectType & object () const

Detailed Description

template<typename ObjectType>
class cxxtools::JsonIOObject< ObjectType >

Wrapper object to easily read objects as json from a input stream.

JsonIObject is a little wrapper which makes it easy to read objects from a istream. For this the JsonIObject expects a reference to the wrapped object and has a input operator for a std::istream, or actually a std::basic_istream, which reads the object from json format.

Example:

std::vector<unsigned> v;
std::istringstream in("[ 45, 23 ]");
in >> cxxtools::Json(v);
for (unsigned n = 0; n < v.size(); ++n)
std::cout << v[n] << '\n'; // prints 45 and 23

Constructor & Destructor Documentation

template<typename ObjectType>
cxxtools::JsonIOObject< ObjectType >::JsonIOObject ( ObjectType &  object)
inlineexplicit

Member Function Documentation

template<typename ObjectType>
ObjectType& cxxtools::JsonIOObject< ObjectType >::object ( )
inline

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