Jpp  18.5.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 164 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 171 of file JSonSupportkit.hh.

172  {
173  using namespace std;
174  using namespace JPP;
175 
176  JRootWritableClass cls(object);
177 
178  for (unique_ptr<TIterator> i(cls.getClass()->GetListOfDataMembers()->MakeIterator()); const TDataMember* p = (const TDataMember*) i->Next(); ) {
179 
180  if (!JRootClass::is_static(*p)) {
181 
182  JRootWritableClass abc = cls.get(*p);
183 
184  JSonDictionary::getInstance()[abc.getTypename()]->to_json(js[p->GetName()], abc.getAddress());
185  }
186  }
187  }
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 196 of file JSonSupportkit.hh.

197  {
198  using namespace std;
199  using namespace JPP;
200 
201  JRootReadableClass cls(object);
202 
203  for (unique_ptr<TIterator> i(cls.getClass()->GetListOfDataMembers()->MakeIterator()); const TDataMember* p = (const TDataMember*) i->Next(); ) {
204 
205  if (!JRootClass::is_static(*p)) {
206 
207  JRootReadableClass abc = cls.get(*p);
208 
209  if (js.contains(p->GetName()))
210  JSonDictionary::getInstance()[abc.getTypename()]->from_json(js[p->GetName()], abc.getAddress());
211  else
212  THROW(JParserException, "No key word <" << p->GetName() << "> in " << js);
213  }
214  }
215  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
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: