Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JROOT::JASCIIFileReader< T > Struct Template Reference

Auxiliary class to read objects with ROOT dictionary from ASCII formatted file. More...

#include <JASCIIFileStreamer.hh>

Inheritance diagram for JROOT::JASCIIFileReader< T >:

Public Member Functions

 JASCIIFileReader (const JRootDictionary &dictionary=JRootDictionary::getInstance())
 Constructor.
 
 JASCIIFileReader (const char *const file_name, const JRootDictionary &dictionary=JRootDictionary::getInstance())
 Constructor.
 
JASCIIFileReaderoperator>> (T &object)
 Read object from this file.
 

Private Attributes

object
 internal value
 
value
 default value
 
std::vector< JROOT::JRootReadableClasscolumns
 column count -> data member
 
JRootReader reader
 

Detailed Description

template<class T>
struct JROOT::JASCIIFileReader< T >

Auxiliary class to read objects with ROOT dictionary from ASCII formatted file.

The names of in the first line are one-to-one mapped to the names of the data members of the corresponding data structure using the corresponding ROOT dictionary.

Definition at line 33 of file JASCIIFileStreamer.hh.

Constructor & Destructor Documentation

◆ JASCIIFileReader() [1/2]

template<class T >
JROOT::JASCIIFileReader< T >::JASCIIFileReader ( const JRootDictionary & dictionary = JRootDictionary::getInstance())
inline

Constructor.

Parameters
dictionarydictionary

Definition at line 43 of file JASCIIFileStreamer.hh.

43 :
44 reader(static_cast<std::istream&>(*this), JLANG::JEquationParameters(), dictionary)
45 {}
Simple data structure to support I/O of equations (see class JLANG::JEquation).

◆ JASCIIFileReader() [2/2]

template<class T >
JROOT::JASCIIFileReader< T >::JASCIIFileReader ( const char *const file_name,
const JRootDictionary & dictionary = JRootDictionary::getInstance() )
inline

Constructor.

Parameters
file_namefile name
dictionarydictionary

Definition at line 54 of file JASCIIFileStreamer.hh.

55 :
56 reader(static_cast<std::istream&>(*this), JLANG::JEquationParameters(), dictionary)
57 {
58 this->open(file_name);
59 }
T * open(const std::string &file_name)
Open file.

Member Function Documentation

◆ operator>>()

template<class T >
JASCIIFileReader & JROOT::JASCIIFileReader< T >::operator>> ( T & object)
inline

Read object from this file.

Parameters
objectobject
Returns
this input stream

Definition at line 68 of file JASCIIFileStreamer.hh.

69 {
70 using namespace std;
71 using namespace JPP;
72
73 if (columns.empty()) {
74
75 JRootReadableClass cls(this->object);
76
77 string buffer;
78
79 if (std::getline(*this, buffer)) {
80
81 istringstream is(buffer);
82
83 while (is >> buffer) {
84 columns.push_back(cls.find(buffer.c_str()));
85 }
86 }
87 }
88
89 object = value;
90
91 reader.flags(this->flags());
92
93 string buffer;
94
95 if (std::getline(*this, buffer)) {
96
97 istringstream is(buffer);
98
99 for (size_t i = 0; i != columns.size() && is >> buffer; ++i) {
100
101 if (columns[i].is_valid()) {
102
103 JRedirectString redirect(reader, buffer);
104
106 }
107 }
108
109 object = this->object;
110 }
111
112 return *this;
113 }
This class can be used to temporarily redirect an input stream to an input string.
JRootReader & getObject(T &object)
Read object.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
bool is_valid(const json &js)
Check validity of JSon data.
std::vector< JROOT::JRootReadableClass > columns
column count -> data member
ROOT class for reading into object.

Member Data Documentation

◆ object

template<class T >
T JROOT::JASCIIFileReader< T >::object
private

internal value

Definition at line 116 of file JASCIIFileStreamer.hh.

◆ value

template<class T >
T JROOT::JASCIIFileReader< T >::value
private

default value

Definition at line 117 of file JASCIIFileStreamer.hh.

◆ columns

template<class T >
std::vector<JROOT::JRootReadableClass> JROOT::JASCIIFileReader< T >::columns
private

column count -> data member

Definition at line 119 of file JASCIIFileStreamer.hh.

◆ reader

template<class T >
JRootReader JROOT::JASCIIFileReader< T >::reader
private

Definition at line 121 of file JASCIIFileStreamer.hh.


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