Jpp  17.3.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Friends | List of all members
JDATABASE::JSonHelper< T > Struct Template Reference

Auxiliary base class for JSon I/O based on ROOT dictionary. More...

#include <JSonSupportkit.hh>

Friends

void to_json (json &js, const T &object)
 Convert object to JSon. More...
 
void from_json (const json &js, T &object)
 Convert JSon to object/. More...
 

Detailed Description

template<class T>
struct JDATABASE::JSonHelper< T >

Auxiliary base class for JSon I/O based on ROOT dictionary.

Definition at line 132 of file JSonSupportkit.hh.

Friends And Related Function Documentation

template<class T>
void to_json ( json js,
const T object 
)
friend

Convert object to JSon.

Parameters
jsjson
objectobject

Definition at line 139 of file JSonSupportkit.hh.

140  {
141  using namespace std;
142  using namespace JPP;
143 
144  JRootWritableClass cls(object);
145 
146  for (unique_ptr<TIterator> i(cls.getClass()->GetListOfDataMembers()->MakeIterator()); const TDataMember* p = (const TDataMember*) i->Next(); ) {
147 
148  if (!JRootClass::is_static(*p)) {
149 
150  JRootWritableClass abc = cls.get(*p);
151 
152  JSonDictionary::getInstance()[abc.getTypename()]->to_json(js[p->GetName()], abc.getAddress());
153  }
154  }
155  }
static data_type & getInstance()
Get unique instance of template class.
Definition: JSingleton.hh:27
template<class T>
void from_json ( const json js,
T object 
)
friend

Convert JSon to object/.

Parameters
jsjson
objectobject

Definition at line 164 of file JSonSupportkit.hh.

165  {
166  using namespace std;
167  using namespace JPP;
168 
169  JRootReadableClass cls(object);
170 
171  for (unique_ptr<TIterator> i(cls.getClass()->GetListOfDataMembers()->MakeIterator()); const TDataMember* p = (const TDataMember*) i->Next(); ) {
172 
173  if (!JRootClass::is_static(*p)) {
174 
175  JRootReadableClass abc = cls.get(*p);
176 
177  JSonDictionary::getInstance()[abc.getTypename()]->from_json(js[p->GetName()], abc.getAddress());
178  }
179  }
180  }
static data_type & getInstance()
Get unique instance of template class.
Definition: JSingleton.hh:27

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