1 #ifndef __JROOT__JROOTSTREAMER__
2 #define __JROOT__JROOTSTREAMER__
30 namespace JPP {
using namespace JROOT; }
74 std::istream(in.rdbuf()),
119 const JEquationFacet& facet = use_facet<JEquationFacet>(this->getloc());
121 for (
JEquation equation; *
this >> equation; ) {
131 if (facet.
isDivision (equation.getSeparator()))
133 else if (facet.
isSeparator(equation.getSeparator()))
138 status &= (!this->
fail() || this->eof());
178 i->second->getObject(*
this, cls.
getAddress());
180 }
else if (cls.
getClass() != NULL) {
182 if (cls.
getClass()->GetListOfBases() != NULL) {
184 std::unique_ptr<TIterator> i(cls.
getClass()->GetListOfBases()->MakeIterator());
186 for (
const TBaseClass* p; (p = (
const TBaseClass*) i->Next()) != NULL && (
bool) (*this); ) {
191 if (cls.
getClass()->GetListOfDataMembers() != NULL) {
193 std::unique_ptr<TIterator> i(cls.
getClass()->GetListOfDataMembers()->MakeIterator());
195 for (
const TDataMember* p; (p = (
const TDataMember*) i->Next()) != NULL && (
bool) (*this); ) {
255 template<
class JElement_t,
class JAllocator_t>
262 for (JElement_t element;
n != 0 && this->
getObject(element); --
n) {
263 object.push_back(element);
307 std::ostream(out.rdbuf()),
315 precision(out.precision());
364 return this->put(
JEquation(key, os.str()));
376 return this->put(
"", cls,
false);
407 const JEquationFacet& facet = use_facet<JEquationFacet>(this->getloc());
413 i->second->put(*
this, prefix, cls.
getAddress());
427 }
else if (cls.
getClass() != NULL) {
429 if (cls.
getClass()->GetListOfBases() != NULL) {
431 std::unique_ptr<TIterator> i(cls.
getClass()->GetListOfBases()->MakeIterator());
433 for (
const TBaseClass* p; (p = (
const TBaseClass*) i->Next()) != NULL; ) {
434 this->put(prefix, cls.
get(*p),
false);
438 if (cls.
getClass()->GetListOfDataMembers() != NULL) {
440 std::unique_ptr<TIterator> i(cls.
getClass()->GetListOfDataMembers()->MakeIterator());
442 for (
const TDataMember* p; (p = (
const TDataMember*) i->Next()) != NULL; ) {
444 this->put(facet.
getPrefix(prefix,p->GetName()), cls.
get(*p),
false);
498 i->second->putObject(*
this, cls.
getAddress());
500 }
else if (cls.
getClass() != NULL) {
502 if (cls.
getClass()->GetListOfBases() != NULL) {
504 std::unique_ptr<TIterator> i(cls.
getClass()->GetListOfBases()->MakeIterator());
506 for (
const TBaseClass* p; (p = (
const TBaseClass*) i->Next()) != NULL; ) {
511 if (cls.
getClass()->GetListOfDataMembers() != NULL) {
513 std::unique_ptr<TIterator> i(cls.
getClass()->GetListOfDataMembers()->MakeIterator());
515 for (
const TDataMember* p; (p = (
const TDataMember*) i->Next()) != NULL; ) {
568 template<
class JElement_t,
class JAllocator_t>
630 return writer.
put(key, value);
This file contains the basic interface for ASCII I/O of ROOT objects.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Facet class to specify parsing of equations in currect locale (see class JLANG::JEquation).
const std::string getPrefix(const std::string &prefix, const std::string &name) const
Get combined prefix for output.
Simple data structure to support I/O of equations (see class JLANG::JEquation).
bool isSeparator(const char c) const
Test for separator character.
bool isDivision(const char c) const
Test for division character.
General purpose equation class.
This class can be used to temporarily redirect one output (input) stream to another output (input) st...
This class can be used to temporarily redirect an input stream to an input string.
This class can be used to temporarily exchange the states between streams.
Forward declaration of writer object.
virtual JRootWriter & put(JRootWriter &out, const std::string &prefix, const void *address) const
Stream output.
virtual JRootWriter & putObject(JRootWriter &out, const void *address) const
Stream output.
virtual JRootReader & getObject(JRootReader &in, void *address) const
Stream input.
Implementation for ASCII input of objects with ROOT dictionary.
const JRootDictionary_t & dictionary
JRootReader & get(T &object)
Read object according equation format.
JRootReader & getObject(const JRootReadableClass &cls)
Read ROOT class.
JRootReader & getObject(T &object, const JBool< true > &option)
Read object.
JRootReader & getObject(T &object)
Read object.
JRootReader & getObject(T &object, const JBool< false > &option)
Read object.
JRootReader & getObject(std::vector< JElement_t, JAllocator_t > &object, const JBool< false > &option)
Read object.
const JRootDictionary_t & getDictionary() const
Get dictionary.
JRootReader(std::istream &in, const JEquationParameters ¶meters, const JRootDictionary_t &dictionary)
Constructor.
JRootReader & getObject(JRootReadableClass &cls)
Read ROOT class.
JRootReader & get(const JRootReadableClass &cls)
Read ROOT class according equation format.
Implementation for ASCII output of objects with ROOT dictionary.
JRootWriter & putObject(const T &object, const JBool< false > &option)
Write object.
JRootWriter & put(JRootWritableClass &cls)
Write ROOT class according equation format.
const JRootDictionary_t & getDictionary() const
Get dictictionary.
JRootWriter(std::ostream &out, const JEquationParameters ¶meters, const JRootDictionary_t &dictionary)
Constructor.
virtual JRootWriter & put(const JEquation &equation)
Write equation.
JRootWriter & putObject(const std::vector< JElement_t, JAllocator_t > &object, const JBool< false > option)
Write object.
JRootWriter & put(const T &object)
Write object according equation format.
JRootWriter & putObject(const JRootWritableClass &cls)
Write ROOT class.
JRootWriter & put(const JRootWritableClass &cls)
Write ROOT class according equation format.
JRootWriter & put(const std::string &prefix, const JRootWritableClass &cls, bool eol)
Write ROOT class according equation format.
JRootWriter & put(const std::string &key, const T &value)
Write given key and value according equation format.
JRootWriter & putObject(const T &object)
Write object.
JRootWriter & putObject(const T &object, const JBool< true > &option)
Write object.
const JRootDictionary_t & dictionary
Test availability of stream operators.
std::ostream & white_space(std::ostream &out)
Print white space.
bool fail(std::istream &in)
Check for stream state.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary classes and methods for ROOT I/O.
bool putObject(TDirectory &dir, const TObject &object)
Write object to ROOT directory.
Auxiliary template class for type bool.
bool is_valid() const
Check validity of this addressable class.
pointer_type getAddress() const
Get address.
JRootAddressableClass get(const TDataMember &data_member) const
Get addressable class of given data member.
JRootAddressableClass find(const char *const name) const
Find addressable base class or data member with given name within current class.
static bool is_static(const TDataMember &data_member)
Check if data member is static.
TClass * getClass() const
Get class.
const char * getTypename() const
Get type name.
Type definition of ROOT based dictionary for ASCII I/O.
ROOT class for reading object.
Auxiliary template class to define default implementation of the ROOT streamer.
static JRootWriter & putObject(JRootWriter &writer, const T &object)
Write object.
static JRootReader & getObject(JRootReader &reader, T &object)
Read object.
static JRootWriter & put(JRootWriter &writer, const std::string &key, const T &value)
Write given key and value according equation format.
ROOT class for writing object.