BOSS 7.0.6
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 36 of file EvtParser.cc.

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

◆ ~EvtParser()

EvtParser::~EvtParser ( )

Definition at line 43 of file EvtParser.cc.

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

Member Function Documentation

◆ getLineofToken()

int EvtParser::getLineofToken ( int  i)

Definition at line 63 of file EvtParser.cc.

63 {
64
65 return _linelist[i];
66
67}

Referenced by EvtDecayTable::readDecayFile().

◆ getNToken()

int EvtParser::getNToken ( )

Definition at line 51 of file EvtParser.cc.

51 {
52
53 return _ntoken;
54
55}

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

◆ getToken()

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

Definition at line 57 of file EvtParser.cc.

57 {
58
59 return _tokenlist[i];
60
61}

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

◆ Read()

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

Definition at line 69 of file EvtParser.cc.

69 {
70 ifstream fin;
71
72 fin.open(filename.c_str());
73 if (!fin) {
74 report(ERROR,"EvtGen") << "Could not open file '"<<filename.c_str()<<"'"<<endl;
75 return -1;
76 }
77
78 char buf[MAXBUF];
79 char buf2[MAXBUF];
80 char c;
81
82 int line=0;
83 int i;
84
85 while(fin.peek() != EOF){
86 line++;
87
88 i=0;
89 while((c=fin.get()) != '\n' && i<MAXBUF) {
90 buf[i]=c;
91 i++;
92 }
93 if(i==MAXBUF) {
94 report(ERROR,"EvtGen") << "Error in EvtParser: line:"
95 <<line<<" to long"<<endl;
96 }
97 else {
98 buf[i] = '\0';
99 }
100
101 //search for '#' which indicates comment for rest of line!
102 i=0;
103 do{
104 if (buf[i]=='#') buf[i]=0;
105 i++;
106 }while(buf[i-1]!=0);
107
108 //read each token
109 istrstream ist(buf,strlen(buf));
110 while(ist>>buf2){
111 i=0;
112 int semicolon=0;
113 do{
114 if (buf2[i]==';') {
115 buf2[i]=0;
116 semicolon=1;
117 }
118 }while(buf2[i++]!=0);
119 if (buf2[0]!=0){
120 addToken(line,buf2);
121 }
122 if (semicolon) addToken(line,";");
123 }
124 }
125
126 fin.close();
127
128 return 0;
129
130}
#define MAXBUF
Definition: EvtParser.cc:34
ostream & report(Severity severity, const char *facility)
Definition: EvtReport.cc:36
@ ERROR
Definition: EvtReport.hh:49
std::ifstream ifstream
Definition: bpkt_streams.h:44

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


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