ATLAS Offline Software
Loading...
Searching...
No Matches
ReadCards Class Reference

Get tag-value pairs from a file. More...

#include <ReadCards.h>

Collaboration diagram for ReadCards:

Public Member Functions

 ReadCards ()
 ReadCards (const std::string &filename)
 ~ReadCards ()
int GetNValues () const
bool isTagDefined (const string &tag) const
const std::vector< double > GetVector (unsigned i) const
string GetValueString (unsigned i) const
double GetValue (const string &tag) const
double GetValue (int i) const
std::string GetString (const std::string &tag) const
std::string GetString (const unsigned i) const
const std::vector< double > GetVector (const std::string &tag) const
const std::vector< int > GetIntVector (const std::string &tag) const
std::vector< std::string > GetStringVector (const std::string &tag) const
void Set (const string &tag, double &value) const
void Set (const string &tag, int &value) const
void Set (const std::string &tag, std::string &value) const
void Set (const string &tag, std::vector< double > &value) const
void Set (const string &tag, std::vector< int > &value) const
void Set (const std::string &tag, std::vector< std::string > &value) const
void print ()
std::vector< stringTags (const std::string &pattern="") const
template<class T>
void declareProperty (const std::string &key, T &t)
template<class T>
void declareProperty (const std::string &key, std::vector< T > &t)
void declareProperty (const std::string &key, std::string &t)
void declareProperty (const std::string &key, std::vector< std::string > &t)

Private Member Functions

void ReadParam ()
void clean ()
 remove comments and whitespace
int GetIndex (const std::string &tag) const
bool AddTag (const string &tag, const vector< string > &values)
void Construct (const std::string &filename)
 check for file in cwd or if not, check in the RESPLOTDIR, then read the file
void CreatePath ()
void parse ()
 parse the remaining cleaned input string
string parseleft (string &s)
vector< stringparseright (string &s)
void error (const std::string &s)
double handle (const std::string &s, const std::string &="") const

Private Attributes

std::string m_FileName
ifstream m_File
std::string m_String
std::vector< Valuem_Values
std::vector< int > m_ValuesFlag

Static Private Attributes

static std::vector< std::string > m_Path

Detailed Description

Get tag-value pairs from a file.

Reads in all the tag-value pairs from a file (values can actually be a vector of values) and
makes them available by tagname.

Definition at line 50 of file ReadCards.h.

Constructor & Destructor Documentation

◆ ReadCards() [1/2]

ReadCards::ReadCards ( )
inline

Definition at line 54 of file ReadCards.h.

54{ }

◆ ReadCards() [2/2]

ReadCards::ReadCards ( const std::string & filename)
inline

Definition at line 55 of file ReadCards.h.

55{ Construct(filename); }
void Construct(const std::string &filename)
check for file in cwd or if not, check in the RESPLOTDIR, then read the file
Definition ReadCards.cxx:62

◆ ~ReadCards()

ReadCards::~ReadCards ( )
inline

Definition at line 57 of file ReadCards.h.

57{ }

Member Function Documentation

◆ AddTag()

bool ReadCards::AddTag ( const string & tag,
const vector< string > & values )
inlineprivate

Definition at line 203 of file ReadCards.h.

203 {
204 for ( unsigned i=0 ; i<m_Values.size() ; i++ ) {
205 if ( tag == m_Values[i].Tag() ) {
206 cerr << "ReadCards::addTag() tag " << tag << " already defined in file " << m_FileName << endl;
207 exit(-1);
208 }
209 }
210 m_Values.push_back(Value(tag,values));
211 return true;
212 }
std::string m_FileName
Definition ReadCards.h:217
std::vector< Value > m_Values
Definition ReadCards.h:223

◆ clean()

void ReadCards::clean ( )
private

remove comments and whitespace

Definition at line 122 of file ReadCards.cxx.

122 {
123
124 ostringstream os(ostringstream::out);
125 std::string line;
126
127 // cout << "ReadCards reading from file " << m_FileName << endl;
128
129
130 while ( !m_File.eof() ) {
131 size_t pos;
132
133
134 getline(m_File,line,'\n');
135
136 // cout << ">> " << line << endl;
137
138
139 if ( (pos=line.find("//")) != std::string::npos ) {
140
141 int quotecount = 0;
142
143 for ( unsigned iq=0 ; iq<pos ; iq++ ) {
144 if ( line[iq]=='\"' ) quotecount++;
145 else if ( line[iq]=='"' ) quotecount++;
146 }
147
148 // std::cout << "quotecount " << quotecount << std::endl;
149
150 if ( quotecount%2==0 ) {
151 std::string tmpline = chop(line,"//");
152 // size_t n = std::count(tmpline.begin(), tmpline.end(), "\"");
153 // size_t n = count( tmpline, "\"");
154 // if ( n%2==0 )
155 line = std::move(tmpline);
156 }
157 }
158
159#if 0
161 if ( (pos=line.find('#')) != std::string::npos ) {
162
163 int quotecount = 0;
164
165 for ( unsigned iq=0 ; iq<pos ; iq++ ) {
166 if ( line[iq]=='\"' ) quotecount++;
167 else if ( line[iq]=='"' ) quotecount++;
168 }
169
170 // std::cout << "quotecount " << quotecount << std::endl;
171
172 if ( quotecount%2==0 ) {
173 std::string tmpline = chop(line,"#");
174 // size_t n = count( tmpline, "\"");
175 // size_t n = std::count(tmpline.begin(), tmpline.end(), "\"");
176 // if ( n%2==0 )
177 line = tmpline;
178 }
179 }
180#endif
181
182 // removespace(line);
183
184 if ( line.size() ) os << line;
185 }
186
187 // cout << "ReadCards read " << i << " lines from file " << m_FileName << endl;
188
189 m_String = os.str();
190}
std::string m_String
Definition ReadCards.h:221
ifstream m_File
Definition ReadCards.h:219
std::string chop(std::string &s1, const std::string &s2)
Definition hcg.cxx:161

◆ Construct()

void ReadCards::Construct ( const std::string & filename)
private

check for file in cwd or if not, check in the RESPLOTDIR, then read the file

Definition at line 62 of file ReadCards.cxx.

62 {
63
64 if ( m_Path.size()==0 ) CreatePath();
65 for ( unsigned i=0 ; i<m_Path.size() ; i++ ) {
66 std::string tmp_filename = m_Path[i]+filename;
67 if ( canopen(tmp_filename) ) {
68 m_FileName = std::move(tmp_filename);
69 break;
70 }
71 }
72
73 if ( m_FileName.size()==0 ) {
74 cerr << "ReadCards::Construct() cannot open file " << filename << endl;
75 exit(0);
76 }
77
78
79 int pid = getpid();
80
81 char tfile[1024];
82
83 if ( m_FileName.find('/')==std::string::npos ) std::sprintf( tfile, ".readcards-%s-%d", m_FileName.c_str(), pid );
84 else std::sprintf( tfile, ".readcards-%d", pid );
85
86 char cmd[2056];
87 std::sprintf( cmd, "cpp -I. -P %s > %s", m_FileName.c_str(), tfile );
88
89 std::system( cmd );
90
91 std::cout << "pid: " << pid << " " << tfile << std::endl;
92
93 // ReadCards inputdata(datafile);
94 // m_File.open(m_FileName.c_str());
95 m_File.open(tfile);
96 cout << "ReadCards::Construct() opening " << m_FileName << endl;
97 ReadParam();
98 // cout << "ReadCards::Construct() read "
99 // << m_Values.size() << " entries" << endl;
100 m_File.close();
101
102 std::sprintf( cmd, "rm %s", tfile );
103 std::system( cmd );
104
105 // print();
106}
static std::vector< std::string > m_Path
Definition ReadCards.h:226
void CreatePath()
Definition ReadCards.cxx:45
void ReadParam()
bool canopen(const std::string &s)
Definition utils.cxx:178

◆ CreatePath()

void ReadCards::CreatePath ( )
private

Definition at line 45 of file ReadCards.cxx.

45 {
46 if ( getenv("CONFIG_PATH") ) {
47 std::string config_path = getenv("CONFIG_PATH");
48 std::cout << "ReadCards::CONFIG_PATH " << config_path << std::endl;
49 while ( config_path.size() ) {
50 m_Path.push_back(chop(config_path, ":")+'/');
51 }
52 }
53 m_Path.push_back("");
54 m_Path.push_back(std::string( RESPLOTDIR )+'/');
55 // for ( int i=0 ; i<m_Path.size() ; i++ ) cout << "ReadCards>>CreatePath() m_Path[" << i << "]=" << m_Path[i] << endl;
56}
#define RESPLOTDIR
set up the search path for the config files
Definition ReadCards.cxx:42
std::string getenv(const std::string &variableName)
get an environment variable

◆ declareProperty() [1/4]

void ReadCards::declareProperty ( const std::string & key,
std::string & t )
inline

Definition at line 182 of file ReadCards.h.

182 {
183 if ( isTagDefined(key) ) t = GetString(key);
184 }
bool isTagDefined(const string &tag) const
Definition ReadCards.h:61
std::string GetString(const std::string &tag) const
Definition ReadCards.h:93

◆ declareProperty() [2/4]

void ReadCards::declareProperty ( const std::string & key,
std::vector< std::string > & t )
inline

Definition at line 186 of file ReadCards.h.

186 {
187 if ( isTagDefined(key) ) t = GetStringVector(key);
188 }
std::vector< std::string > GetStringVector(const std::string &tag) const
Definition ReadCards.h:115

◆ declareProperty() [3/4]

template<class T>
void ReadCards::declareProperty ( const std::string & key,
std::vector< T > & t )
inline

Definition at line 176 of file ReadCards.h.

176 {
177 if ( isTagDefined(key) ) t = GetVector(key);
178 }
const std::vector< double > GetVector(unsigned i) const
Definition ReadCards.h:68

◆ declareProperty() [4/4]

template<class T>
void ReadCards::declareProperty ( const std::string & key,
T & t )
inline

Definition at line 171 of file ReadCards.h.

171 {
172 if ( isTagDefined(key) ) t = GetValue(key);
173 }
double GetValue(const string &tag) const
Definition ReadCards.h:84

◆ error()

void ReadCards::error ( const std::string & s)
inlineprivate

Definition at line 240 of file ReadCards.h.

240 {
241 cerr << "ReadCards() syntax error in file " << m_FileName << " : " << s << endl;
242 exit(0);
243 }

◆ GetIndex()

int ReadCards::GetIndex ( const std::string & tag) const
inlineprivate

Definition at line 196 of file ReadCards.h.

196 {
197 for ( int i=GetNValues() ; i-- ; ) if ( tag == m_Values[i].Tag() ) return i;
198 cerr << "ReadCards::GetValue() no tag: " << tag << " in file: " << m_FileName << endl;
199 exit(-1);
200 return 0;
201 }
int GetNValues() const
Definition ReadCards.h:59

◆ GetIntVector()

const std::vector< int > ReadCards::GetIntVector ( const std::string & tag) const
inline

Definition at line 107 of file ReadCards.h.

107 {
108 std::vector<double> s = GetVector(GetIndex(tag));
109 std::vector<int> a; a.reserve(s.size());
110 for ( size_t i=0 ; i<s.size() ; i++ ) a.push_back( int(s[i]) );
111 return a;
112 }
static Double_t a
int GetIndex(const std::string &tag) const
Definition ReadCards.h:196

◆ GetNValues()

int ReadCards::GetNValues ( ) const
inline

Definition at line 59 of file ReadCards.h.

59{ return m_Values.size(); }

◆ GetString() [1/2]

std::string ReadCards::GetString ( const std::string & tag) const
inline

Definition at line 93 of file ReadCards.h.

93 {
94 return GetString(GetIndex(tag));
95 }

◆ GetString() [2/2]

std::string ReadCards::GetString ( const unsigned i) const
inline

Definition at line 97 of file ReadCards.h.

97 {
98 if ( i<m_Values.size() ) return m_Values[i].Val()[0];
99 return "";
100 }

◆ GetStringVector()

std::vector< std::string > ReadCards::GetStringVector ( const std::string & tag) const
inline

Definition at line 115 of file ReadCards.h.

115 {
116 return m_Values[GetIndex(tag)].Val();
117 }

◆ GetValue() [1/2]

double ReadCards::GetValue ( const string & tag) const
inline

Definition at line 84 of file ReadCards.h.

84 {
85 return handle(GetString(tag));
86 }
double handle(const std::string &s, const std::string &="") const
Definition ReadCards.h:246

◆ GetValue() [2/2]

double ReadCards::GetValue ( int i) const
inline

Definition at line 88 of file ReadCards.h.

88 {
89 return (handle(GetString(i)));
90 }

◆ GetValueString()

string ReadCards::GetValueString ( unsigned i) const
inline

Definition at line 78 of file ReadCards.h.

78 {
79 if ( i<m_Values.size() ) return m_Values[i].Tag();
80 else return string("");
81 }

◆ GetVector() [1/2]

const std::vector< double > ReadCards::GetVector ( const std::string & tag) const
inline

Definition at line 102 of file ReadCards.h.

102 {
103 return GetVector(GetIndex(tag));
104 }

◆ GetVector() [2/2]

const std::vector< double > ReadCards::GetVector ( unsigned i) const
inline

Definition at line 68 of file ReadCards.h.

68 {
69 std::vector<double> dValues;
70 if ( i<m_Values.size() ) {
71 for ( unsigned j=0 ; j<m_Values[i].Val().size() ; j++ ) {
72 dValues.push_back(handle(m_Values[i].Val()[j]));
73 }
74 }
75 return dValues;
76 }

◆ handle()

double ReadCards::handle ( const std::string & s,
const std::string & = "" ) const
inlineprivate

Definition at line 246 of file ReadCards.h.

246 {
247 double d;
248 char temps[1024] = "";
249 int r=0;
250 if ( (r = std::sscanf(s.c_str(), "%lf%1023s", &d, temps))==0 || r!=1 || string(temps)!="" ) {
251 cerr << "ReadCards() error converting string to number : " << s << endl;
252 exit(0);
253 }
254 // cout << "r=" << r << " d=" << d <<" temps=" << temps << endl;
255 return d;
256 }
int r
Definition globals.cxx:22

◆ isTagDefined()

bool ReadCards::isTagDefined ( const string & tag) const
inline

Definition at line 61 of file ReadCards.h.

61 {
62 for ( int i=0 ; i<GetNValues() ; i++ ) {
63 if ( tag==m_Values[i].Tag() ) return true;
64 }
65 return false;
66 }

◆ parse()

void ReadCards::parse ( )
private

parse the remaining cleaned input string

aha !!! cannot split on "=" in case they might be in a string !!.

Definition at line 198 of file ReadCards.cxx.

199{
200
201 // std::string shafted;
202
204
205 while ( m_String.size() ) {
206
207 // cout << "m_String.size() " << m_String.size() << endl;
208
209 // if ( m_String.size()<3 ) cout << "m_String >" << m_String << "<" << endl;
210
211 // break at semi colons that are not within "" pairs
212
213 size_t pos = m_String.find(';');
214
215 while ( pos != std::string::npos ) {
216
217 std::string duff = m_String.substr(0,pos);
218
219 // size_t n = std::count(duff.begin(), duff.end(), "\"");
220 size_t n = count( duff, "\"" );
221
222 if ( n%2==0 ) {
223 /* Make the replacement. */
224 m_String.replace( pos, 1, "|");
225 }
226 else {
227 m_String.replace( pos, 1, "####");
228 }
229
230 // std::cout << "duff: " << duff << " : " << n << " " << std::endl;
231
232
233 pos = m_String.find(';');
234
235 }
236
237 if ( m_String.find('|')==std::string::npos ) {
238 error("syntax error, missing semicolon at end of input " + m_String );
239 }
240
241 string input = choptoken(m_String,"|"); // shafted = input;
242 string line = input;
243
244 // copy the unparsed line
245 line = chop(line,"|");
246
248
249 int quotecount = 0;
250 bool found = true;
251
252 for ( size_t iq=0 ; iq<line.size() ; iq++ ) {
253 found = true;
254 if ( line[iq]=='\"' ) quotecount++;
255 else if ( line[iq]=='"' ) quotecount++;
256 if ( line[iq]=='=' ) break;
257 found = false;
258 }
259
260 if ( found && quotecount>0 ) error("syntax error in tag name : " + input + " quotes" );
261
262 string sline = chop(line, "="); // split at =
263
264 // parse the line
265
266 // nice way to do it ...
267 // string tagname = parseleft(sline); // parse the token name
268 // vector<string> values = parseright(line); // parse the vector of values
269
270
271 // and the nasty way, but we do get access to the whole line for the
272 // error reporting
273
274 // parse the tag name
275
276 // cout << "input >" << input << "<" << endl;
277 // cout << "line (val)>" << line << "<" << endl;
278 // cout << "sline (tag)>" << sline << "<" << endl;
279
280 chopends(sline);
281 string tagname = chopfirst(sline);
282 if ( sline.size() ) error("syntax error in tag name : " + input );
283
284 // cout << "tagname >" << tagname << "<" << endl;
285
286
287 // now parse the right hand side string vector
288
289 // cout << "line >" << line << "<" << endl;
290
291 chopends(line);
292
293 // cout << "line (chopped) >" << line << "<" << endl;
294
295 vector<std::string> values;
296
297 // string bra = chopfirst(s,"{");
298 // string ket = choplast(s,"}");
299
300 quotecount = 0;
301
302 for ( size_t iq=0 ; iq<line.size() ; iq++ ) {
303 found = true;
304 if ( line[iq]=='\"' ) quotecount++;
305 else if ( line[iq]=='"' ) quotecount++;
306 if ( line[iq]=='{' && ( quotecount==0 || quotecount%2==0 ) ) break;
307 found = false;
308 }
309 if ( found && quotecount>0 ) error("syntax error in tag name : " + input + " quotes" );
310
311 string bra = "";
312 string ket = "";
313
314
315 if ( found ) {
316 bra = choptoken(line,"{");
317 ket = chomptoken(line,"}");
318
319 if ( bra.size()>1 ) error("syntax error before brace : " + input);
320 if ( ket.size()>1 ) error("syntax error after brace : " + input);
321 if ( bra.size()!=ket.size() ) error("mismatched braces :" + input);
322 }
323
324 //Note: nargs is unused unless the debug code below is uncommented
325 //int nargs = 0;
326
327 bool empty = true;
328
329 while ( line.size() ) {
330
331 empty = false;
332
333 // get rid of spaces at either end of line
334 chopends(line);
335 //nargs++;
336
337 // cout << nargs << " line >" << line << "< " << endl;
338
339 // check if open quote
340 string qo = choptoken(line, "\"");
341
342 // cout << "qo >" << qo << "<" << endl;
343
344 if ( qo.size()>1 ) error("syntax error before quote : " + input);
345
346 // split the comma seperated list but...
347 // if a quoted string, don't parse until after closing quote
348 string token;
349 if ( qo.size()==1 ) { // ie if a quoted string
350 token = choptoken(line, "\""); // chop to closing quote
351
352 // cout << "token >" << token << "<" << endl;
353
354 if ( token.size()== 0 ) error("sytax error, missing quote : " + input);
355 // cout << "SIZE " << token.size() << " " << token << endl;
356
357 chopends(line); // get rid spaces around remaining line
358
359 // cout << "chopped line >" << line << "<" << endl;
360
361 choplast(token, " "); // get rid of extra spaces after closing quote
362 chomp(token, "\""); // get rid of closing quote
363
364 // cout << "final token >" << token << "<" << endl;
365
366 if ( chop(line, ",").size() ) error("syntax error after quote : " + input);
367 }
368 else {
369 token = chop(line, ",");
370
371 // cout << "token >" << token << "< line >" << line << "<" << endl;
372 }
373
374 // check no spaces in values not enclosed in quotes
375 if ( qo.empty()) {
376 if ( token.find(' ')!=string::npos ) error("space not within quotes : " + input);
377 }
378
379 // missing value
380 if ( qo.empty() && token.empty() ) error("missing token : " + input);
381
382
383 size_t pos = token.find("####");
384 while ( pos !=std::string::npos ) {
385 token.replace( pos, 4, ";" );
386 pos = token.find("####");
387 }
388
389 values.push_back(std::move(token));
390 }
391
392 if ( !empty ) {
393
394 // check the vector had braces
395 if ( bra.empty() && values.size()>1 ) error("missing braces : " + input);
396
397 // missing value
398 if ( values.empty() ) {
399 // std::cout << "shafted :" << shafted << ":" << std::endl;
400 // std::cout << "\nm_String " << m_String << std::endl;
401 error("tag with no value : " + input);
402 }
403
404 // add the tag, value pairing
405
406 AddTag(tagname,values);
407 }
408
410 }
411}
static const Attributes_t empty
bool AddTag(const string &tag, const vector< string > &values)
Definition ReadCards.h:203
void error(const std::string &s)
Definition ReadCards.h:240
std::string choptoken(std::string &s1, const std::string &s2)
Definition hcg.cxx:233
std::string chopends(std::string &s1, const std::string &s2)
Definition hcg.cxx:290
std::string chomp(std::string &s1, const std::string &s2)
Definition hcg.cxx:214
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146
std::string chopfirst(std::string &s1, const std::string &s2)
Definition hcg.cxx:260
std::string choplast(std::string &s1, const std::string &s2)
Definition hcg.cxx:276
std::string chomptoken(std::string &s1, const std::string &s2)
Definition hcg.cxx:247

◆ parseleft()

string ReadCards::parseleft ( string & s)
private

Definition at line 417 of file ReadCards.cxx.

417 {
418 chopends(s);
419 string input = s;
420 string token = chopfirst(s);
421 if ( s.size() ) error("syntax error in tag name : " + input );
422 return token;
423}

◆ parseright()

vector< string > ReadCards::parseright ( std::string & s)
private

Definition at line 427 of file ReadCards.cxx.

427 {
428 chopends(s);
429
430 string input = s;
431 vector<std::string> sv;
432
433 // string bra = chopfirst(s,"{");
434 // string ket = choplast(s,"}");
435 string bra = choptoken(s,"{");
436 string ket = chomptoken(s,"}");
437
438 if ( bra.size()>1 ) error("syntax error before { : "+input);
439 if ( ket.size()>1 ) error("syntax error after } : "+input);
440 if ( bra.size()!=ket.size() ) error("mismatched braces :" + input);
441
442 while ( s.size() ) {
443 // split the comma seperated list
444 string token = chop(s, ",");
445
446 // get rid ofr spaces at either end
447 chopends(token);
448
449 // check open and closing quotes
450 string qo = chopfirst(token, "\"");
451 string qc = choplast(token, "\"");
452 if ( qo.size()>1 || qc.size()>1 ) error("syntax error before \" : " + input);
453
454 // check quotes balance
455 if ( qc.size()!=qo.size() ) error("mismatched \" : " + input);
456
457 // check no spaces in values not enclosed in quotes
458 if ( qo.empty() ) {
459 if ( token.find(' ')!=string::npos ) error("space not wintin \"\" : " + input);
460 }
461
462 if ( token.empty() ) error("missing token : " + input);
463
464 sv.push_back(std::move(token));
465 }
466
467 if ( sv.empty() ) error("tag with no value " + input);
468
469 return sv;
470}
static const int qc[]

◆ print()

void ReadCards::print ( )

Definition at line 484 of file ReadCards.cxx.

484 {
485 // cout << "ReadCards::print() read " << m_Values.size() << " cards from file " << m_FileName << endl;
486 for ( unsigned i=0 ; i<m_Values.size() ; i++ ) {
487 // cout << " ReadCards::print() read " << m_Values[i].Tag() << " =";
488 // cout << " read " << m_Values[i].Tag() << " =";
489
490 printf("read tag %s\t = ", m_Values[i].Tag().c_str() );
491
492 for ( unsigned j=0 ; j<m_Values[i].Val().size() ; j++ ) {
493 // if ( m_Values[i].Val().size()>5 ) if (!(j%5)) cout << endl << " ";
494 // cout << " " << (m_Values[i].Val())[j];
495
496 const std::vector<std::string>& vals = m_Values[i].Val();
497
498 if ( vals[j].size()>10 || ( vals.size()>5 && !(j%5) ) ) printf("\n\t\t\t");
499 printf("%s ", vals[j].c_str() );
500 }
501 cout << endl;
502 }
503}

◆ ReadParam()

void ReadCards::ReadParam ( )
private

Definition at line 474 of file ReadCards.cxx.

475{
476 clean();
477 parse();
478 // print();
479}
void parse()
parse the remaining cleaned input string
void clean()
remove comments and whitespace

◆ Set() [1/6]

void ReadCards::Set ( const std::string & tag,
std::string & value ) const
inline

Definition at line 130 of file ReadCards.h.

130 {
131 if ( isTagDefined(tag) ) value = GetString(GetIndex(tag));
132 }

◆ Set() [2/6]

void ReadCards::Set ( const std::string & tag,
std::vector< std::string > & value ) const
inline

Definition at line 147 of file ReadCards.h.

147 {
148 if ( isTagDefined(tag) ) value = m_Values[GetIndex(tag)].Val();
149 }

◆ Set() [3/6]

void ReadCards::Set ( const string & tag,
double & value ) const
inline

Definition at line 122 of file ReadCards.h.

122 {
123 if ( isTagDefined(tag) ) value = handle(GetString(tag));
124 }

◆ Set() [4/6]

void ReadCards::Set ( const string & tag,
int & value ) const
inline

Definition at line 126 of file ReadCards.h.

◆ Set() [5/6]

void ReadCards::Set ( const string & tag,
std::vector< double > & value ) const
inline

Definition at line 134 of file ReadCards.h.

134 {
135 if ( isTagDefined(tag) ) value = GetVector(GetIndex(tag));
136 }

◆ Set() [6/6]

void ReadCards::Set ( const string & tag,
std::vector< int > & value ) const
inline

Definition at line 138 of file ReadCards.h.

138 {
139 if ( isTagDefined(tag) ) {
140 std::vector<double> v = GetVector(GetIndex(tag));
141 value.clear();
142 value.resize(v.size());
143 for ( unsigned i=v.size() ; i-- ; ) value[i] = v[i];
144 }
145 }

◆ Tags()

std::vector< string > ReadCards::Tags ( const std::string & pattern = "") const
inline

Definition at line 154 of file ReadCards.h.

154 {
155 std::vector<string> tags;
156 if ( pattern=="" ) {
157 for ( unsigned i=0 ; i<m_Values.size() ; i++ ) tags.push_back(m_Values[i].Tag());
158 }
159 else {
160 for ( unsigned i=0 ; i<m_Values.size() ; i++ ) {
161 if ( m_Values[i].Tag().find(pattern)!=std::string::npos ) tags.push_back(m_Values[i].Tag());
162 }
163 }
164 return tags;
165 }
std::vector< std::string > tags
Definition hcg.cxx:105
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:138

Member Data Documentation

◆ m_File

ifstream ReadCards::m_File
private

Definition at line 219 of file ReadCards.h.

◆ m_FileName

std::string ReadCards::m_FileName
private

Definition at line 217 of file ReadCards.h.

◆ m_Path

std::vector< std::string > ReadCards::m_Path
staticprivate

Definition at line 226 of file ReadCards.h.

◆ m_String

std::string ReadCards::m_String
private

Definition at line 221 of file ReadCards.h.

◆ m_Values

std::vector<Value> ReadCards::m_Values
private

Definition at line 223 of file ReadCards.h.

◆ m_ValuesFlag

std::vector<int> ReadCards::m_ValuesFlag
private

Definition at line 224 of file ReadCards.h.


The documentation for this class was generated from the following files: