BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtParser Class Reference

#include <EvtParser.hh>

Public Member Functions

 EvtParser ()
 ~EvtParser ()
int Read (const std::string filename)
int getNToken ()
const std::string & getToken (int i)
int getLineofToken (int i)

Detailed Description

Definition at line 26 of file EvtParser.hh.

Constructor & Destructor Documentation

◆ EvtParser()

EvtParser::EvtParser ( )

Definition at line 35 of file EvtParser.cc.

35 {
36 _ntoken = 0;
37 _lengthoftokenlist = 0;
38 _tokenlist = 0;
39 _linelist = 0;
40}

◆ ~EvtParser()

EvtParser::~EvtParser ( )

Definition at line 42 of file EvtParser.cc.

42 {
43
44 delete[] _tokenlist;
45 delete[] _linelist;
46}

Member Function Documentation

◆ getLineofToken()

int EvtParser::getLineofToken ( int i)

Definition at line 52 of file EvtParser.cc.

52{ return _linelist[i]; }

Referenced by EvtDecayTable::readDecayFile().

◆ getNToken()

int EvtParser::getNToken ( )

Definition at line 48 of file EvtParser.cc.

48{ return _ntoken; }

Referenced by EvtMultiChannelParser::getDecayMode(), EvtMultiChannelParser::parse(), and EvtDecayTable::readDecayFile().

◆ getToken()

const std::string & EvtParser::getToken ( int i)

Definition at line 50 of file EvtParser.cc.

50{ return _tokenlist[i]; }

Referenced by EvtMultiChannelParser::getDecayMode(), EvtMultiChannelParser::parse(), and EvtDecayTable::readDecayFile().

◆ Read()

int EvtParser::Read ( const std::string filename)

Definition at line 54 of file EvtParser.cc.

54 {
55 ifstream fin;
56
57 fin.open( filename.c_str() );
58 if ( !fin )
59 {
60 report( ERROR, "EvtGen" ) << "Could not open file '" << filename.c_str() << "'" << endl;
61 return -1;
62 }
63
64 char buf[MAXBUF];
65 char buf2[MAXBUF];
66 char c;
67
68 int line = 0;
69 int i;
70
71 while ( fin.peek() != EOF )
72 {
73 line++;
74
75 i = 0;
76 while ( ( c = fin.get() ) != '\n' && i < MAXBUF )
77 {
78 buf[i] = c;
79 i++;
80 }
81 if ( i == MAXBUF )
82 { report( ERROR, "EvtGen" ) << "Error in EvtParser: line:" << line << " to long" << endl; }
83 else { buf[i] = '\0'; }
84
85 // search for '#' which indicates comment for rest of line!
86 i = 0;
87 do {
88 if ( buf[i] == '#' ) buf[i] = 0;
89 i++;
90 } while ( buf[i - 1] != 0 );
91
92 // read each token
93 istrstream ist( buf, strlen( buf ) );
94 while ( ist >> buf2 )
95 {
96 i = 0;
97 int semicolon = 0;
98 do {
99 if ( buf2[i] == ';' )
100 {
101 buf2[i] = 0;
102 semicolon = 1;
103 }
104 } while ( buf2[i++] != 0 );
105 if ( buf2[0] != 0 ) { addToken( line, buf2 ); }
106 if ( semicolon ) addToken( line, ";" );
107 }
108 }
109
110 fin.close();
111
112 return 0;
113}
#define MAXBUF
Definition EvtParser.cc:33
ostream & report(Severity severity, const char *facility)
Definition EvtReport.cc:34
@ ERROR
Definition EvtReport.hh:49

Referenced by EvtMultiChannelParser::getDecayMode(), EvtMultiChannelParser::parse(), and EvtDecayTable::readDecayFile().


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