evtgen is hosted by Hepforge, IPPP Durham
EvtGen  2.0.0
Monte Carlo generator of particle decays, in particular the weak decays of heavy flavour particles such as B mesons.
EvtParserXml.hh
Go to the documentation of this file.
1 
2 /***********************************************************************
3 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors *
4 * *
5 * This file is part of EvtGen. *
6 * *
7 * EvtGen is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * EvtGen is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with EvtGen. If not, see <https://www.gnu.org/licenses/>. *
19 ***********************************************************************/
20 
21 #ifndef EVTPARSERXML_HH
22 #define EVTPARSERXML_HH
23 
24 #include <fstream>
25 #include <string>
26 #include <vector>
27 
28 class EvtParserXml final {
29  public:
30  bool open( std::string filename );
31  bool close();
32 
33  bool readNextTag();
34 
35  std::string getTagTitle() { return _tagTitle; }
36  std::string getParentTagTitle();
37  int getLineNumber() { return _lineNo; }
38  bool isTagInline() { return _inLineTag; }
39 
40  std::string readAttribute( std::string attribute,
41  std::string defaultValue = "" );
42  bool readAttributeBool( std::string attribute, bool defaultValue = false );
43  int readAttributeInt( std::string attribute, int defaultValue = -1 );
44  double readAttributeDouble( std::string attribute, double defaultValue = -1. );
45 
46  private:
47  std::ifstream _fin;
48  std::string _line;
49  int _lineNo = 0;
50 
51  std::string _tag;
52  std::string _tagTitle;
53  bool _inLineTag;
54  std::vector<std::string> _tagTree;
55 
56  bool processTagTree();
57 
58  bool expandEnvVars( std::string& str );
59  bool isAlphaNum( char c );
60 };
61 
62 #endif
int getLineNumber()
Definition: EvtParserXml.hh:37
bool processTagTree()
double readAttributeDouble(std::string attribute, double defaultValue=-1.)
std::ifstream _fin
Definition: EvtParserXml.hh:47
std::string _line
Definition: EvtParserXml.hh:48
bool open(std::string filename)
std::string getTagTitle()
Definition: EvtParserXml.hh:35
bool readAttributeBool(std::string attribute, bool defaultValue=false)
std::string _tagTitle
Definition: EvtParserXml.hh:52
bool readNextTag()
std::string getParentTagTitle()
std::string _tag
Definition: EvtParserXml.hh:51
int readAttributeInt(std::string attribute, int defaultValue=-1)
std::vector< std::string > _tagTree
Definition: EvtParserXml.hh:54
bool isAlphaNum(char c)
bool expandEnvVars(std::string &str)
bool isTagInline()
Definition: EvtParserXml.hh:38
std::string readAttribute(std::string attribute, std::string defaultValue="")