1 #ifndef __JROOTSTREAMER__
2 #define __JROOTSTREAMER__
29 namespace JPP {
using namespace JROOT; }
108 std::istream(in.rdbuf()),
110 dictionary(dictionary)
179 using namespace JLANG;
181 if (cls.is_valid()) {
183 const JEquationFacet& facet = use_facet<JEquationFacet>(this->getloc());
185 for (
JEquation equation; *
this >> equation; ) {
195 if (facet.
isDivision (equation.getSeparator()))
197 else if (facet.
isSeparator(equation.getSeparator()))
202 okay &= (!this->
fail() || this->eof());
206 throw JException(
"Error parsing: " + equation.toString());
229 i->second->getObject(*
this, cls.
getAddress());
231 }
else if (cls.
getClass() != NULL) {
233 if (cls.
getClass()->GetListOfBases() != NULL) {
235 TIterator* i = cls.
getClass()->GetListOfBases()->MakeIterator();
237 for (
const TBaseClass* p; (p = (
const TBaseClass*) i->Next()) != NULL && (
bool) (*this); ) {
242 if (cls.
getClass()->GetListOfDataMembers() != NULL) {
244 TIterator* i = cls.
getClass()->GetListOfDataMembers()->MakeIterator();
246 for (
const TDataMember* p; (p = (
const TDataMember*) i->Next()) != NULL && (
bool) (*this); ) {
295 template<
class JElement_t,
class JAllocator_t>
302 for (JElement_t element; n != 0 && this->
getObject(element); --n) {
303 object.push_back(element);
364 return writer.
put(key, value);
390 std::ostream(out.rdbuf()),
392 dictionary(dictionary)
478 using namespace JLANG;
482 const JEquationFacet& facet = use_facet<JEquationFacet>(this->getloc());
488 i->second->put(*
this, prefix, cls.
getAddress());
499 }
else if (cls.
getClass() != NULL) {
501 if (cls.
getClass()->GetListOfBases() != NULL) {
503 TIterator* i = cls.
getClass()->GetListOfBases()->MakeIterator();
505 for (
const TBaseClass* p; (p = (
const TBaseClass*) i->Next()) != NULL; ) {
506 this->put(prefix, cls.
get(*p),
false);
510 if (cls.
getClass()->GetListOfDataMembers() != NULL) {
512 TIterator* i = cls.
getClass()->GetListOfDataMembers()->MakeIterator();
514 for (
const TDataMember* p; (p = (
const TDataMember*) i->Next()) != NULL; ) {
516 this->put(facet.
getPrefix(prefix,p->GetName()), cls.
get(*p),
false);
543 i->second->putObject(*
this, cls.
getAddress());
545 }
else if (cls.
getClass() != NULL) {
547 if (cls.
getClass()->GetListOfBases() != NULL) {
549 TIterator* i = cls.
getClass()->GetListOfBases()->MakeIterator();
551 for (
const TBaseClass* p; (p = (
const TBaseClass*) i->Next()) != NULL; ) {
556 if (cls.
getClass()->GetListOfDataMembers() != NULL) {
558 TIterator* i = cls.
getClass()->GetListOfDataMembers()->MakeIterator();
560 for (
const TDataMember* p; (p = (
const TDataMember*) i->Next()) != NULL; ) {
598 using namespace JLANG;
621 using namespace JLANG;
642 template<
class JElement_t,
class JAllocator_t>
663 using namespace JLANG;
693 template<
class JElement_t,
class JAllocator_t>
771 inline void print(std::ostream& out,
773 const std::string& key,
786 for (string::size_type i = 0, j = 0; j != string::npos && cls.
is_valid(); i = j + 1) {
788 cls = cls.
find(key.substr(i, j - i).c_str());
const JRootDictionary_t & getDictionary() const
Get dictictionary.
JRootWriter & put(const std::string &key, const T &value)
Write given key and value according equation format.
JRootWriter & putObject(const T &object, const JBool< true > &option)
Write object.
JRootReader & getObject(T &object, const JBool< false > &option)
Read object.
Facet class to specify parsing of equations in currect locale (see class JLANG::JEquation).
Implementation for ASCII output of objects with ROOT dictionary.
Helper class for user formatting.
const char * getTypename() const
Get type name.
const std::string getPrefix(const std::string &prefix, const std::string &name) const
Get combined prefix for output.
Default helper class for formatting.
pointer_type getAddress() const
Get address.
This class can be used to temporarily exchange the states between streams.
std::ostream & white_space(std::ostream &out)
Print white space.
static JRootWriter & putObject(JRootWriter &writer, const T &object)
Write object.
Simple data structure to support I/O of equations (see class JLANG::JEquation).
virtual JRootReader & getObject(JRootReader &in, void *address) const
Stream input.
JRootWriter & putObject(const JRootClassWriter &cls)
ROOT class output.
Forward declaration of writer object.
virtual JRootWriter & putObject(JRootWriter &out, const void *address) const
Stream output.
static JRootReader & getObject(JRootReader &reader, T &object)
Read object.
JRootWriter & putObject(const T &object)
Write object.
bool is_valid() const
Check validity of this addressable class.
JRootWriter & put(const std::string &key, const T &value, const JBool< false > option)
Write given key and value according equation format.
General purpose equation class.
ROOT class for writing object.
void print(const TH1 &h1, std::ostream &out)
Print histogram parameters.
virtual JRootWriter & put(JRootWriter &out, const std::string &prefix, const void *address) const
Stream output.
static JRootWriter & put(JRootWriter &writer, const std::string &key, const T &value)
Write given key and value according equation format.
Implementation for ASCII input of objects with ROOT dictionary.
Auxiliary template class for type bool.
The template JSharedPointer class can be used to share a pointer to an object.
const JRootDictionary_t & dictionary
std::ostream & separator(std::ostream &out)
Print separator.
ROOT class for reading object.
static JRootWriter & put(JRootWriter &writer, const std::string &key, const T &value)
Write given key and value according equation format.
JRootWriter(std::ostream &out, const JEquationParameters ¶meters, const JRootDictionary_t &dictionary)
Constructor.
JRootReader(std::istream &in, const JEquationParameters ¶meters, const JRootDictionary_t &dictionary)
Constructor.
JRootWriter & put(const std::string &key, const std::vector< JElement_t, JAllocator_t > &value, const JBool< false > option)
Write given key and value according equation format.
JRootReader & getObject(T &object)
Read object.
Default helper class for formatting.
JRootReader & getObject(std::vector< JElement_t, JAllocator_t > &object, const JBool< false > &option)
Read object.
JRootAddressableClass get(const TDataMember &data_member) const
Get addressable class of given data member.
bool fail(std::istream &in)
Check for stream state.
This file contains the basic interface for ASCII I/O of ROOT objects.
JRootWriter & putObject(const T &object, const JBool< false > &option)
Write object.
JRootWriter & put(const std::string &prefix, const JRootClassWriter &cls, bool eol)
ROOT class output.
TClass * getClass() const
Get class.
static JRootReader & getObject(JRootReader &reader, T &object)
Read object.
bool isSeparator(const char c) const
Test for separator character.
static const JLANG::JEndOfLine end_of_line
Print end of line.
bool isDivision(const char c) const
Test for division character.
static JRootWriter & putObject(JRootWriter &writer, const T &object)
Write object.
JRootReader & getObject(T &object, const JBool< true > &option)
Read object.
std::map< std::string, JSharedPointer< JAbstractStreamer > > JRootDictionary_t
Type definition of ROOT dictionary.
const JRootDictionary_t & dictionary
Helper class for user formatting.
JRootWriter & put(const T &object)
Write object according equation format.
JRootReader & getObject(const JRootClassReader &cls)
Read ROOT class.
JRootAddressableClass find(const char *name) const
Find addressable base class or data member with given name within current class.
JRootWriter & put(const std::string &key, const T &value, const JBool< true > option)
Write given key and value according equation format.
This class can be used to temporarily redirect an input stream to an input string.
const JRootDictionary_t & getDictionary() const
Get dictionary.
Test availability of redirect operators.
static bool is_static(const TDataMember &data_member)
Check if data member is static.
bool putObject(TDirectory *dir, const T &object)
Write object to ROOT directory.
JRootWriter & putObject(const std::vector< JElement_t, JAllocator_t > &object, const JBool< false > option)
Write object.