ATLAS Offline Software
LArBadChannelParser2.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef LArBadChannelParser2_H
6 #define LArBadChannelParser2_H
7 
8 #include <vector>
9 #include <string>
10 #include <fstream>
11 #include <sstream>
12 
13 class MsgStream;
14 
16 public:
17 
18  struct ISLine {
19  std::vector<int> intVec;
20  std::vector<std::string> stringVec;
21  };
22 
27  LArBadChannelParser2(const std::string& filename, MsgStream* const messager);
28 
30 
40  std::vector< ISLine> parseISfile( int nint, int minString,
41  int firstWildcard=-1);
42 
46  bool fileStatusGood() const;
47 
48 private:
49 
50  std::ifstream m_fin; //to read the file
51  unsigned int m_linenumber; //line number currently being parsed
52  const std::string m_filename;
53  MsgStream* const m_log;
54 
55  bool parseLine( std::string& readLine, ISLine& parsedLine,
56  int nint, int minString, int firstWildcard);
57 
58  bool interpretLine( const std::vector<std::string>& command, ISLine& parsedLine,
59  int nint, int minString, int firstWildcard);
60 
61  bool stringToInt(int& theInt, const std::string& theStr) const;
62 
63 };
64 
65 inline bool LArBadChannelParser2::stringToInt(int& theInt, const std::string& theStr) const
66 {
67  std::istringstream iss(theStr);
68  //the second condition checks for invalid input of the form "123abc"
69  //return !(iss >> std::dec >> theInt).fail() && (static_cast<int>(theStr.size()) == iss.tellg());
70  iss >> std::dec >> theInt;
71  return !iss.fail() && iss.eof();
72 }
73 
74 #endif
LArBadChannelParser2::interpretLine
bool interpretLine(const std::vector< std::string > &command, ISLine &parsedLine, int nint, int minString, int firstWildcard)
Definition: LArBadChannelParser2.cxx:76
LArBadChannelParser2::stringToInt
bool stringToInt(int &theInt, const std::string &theStr) const
Definition: LArBadChannelParser2.h:65
LArBadChannelParser2::ISLine
Definition: LArBadChannelParser2.h:18
LArBadChannelParser2::m_fin
std::ifstream m_fin
Definition: LArBadChannelParser2.h:50
LArBadChannelParser2::ISLine::intVec
std::vector< int > intVec
Definition: LArBadChannelParser2.h:19
LArBadChannelParser2::fileStatusGood
bool fileStatusGood() const
You can use this function to check whether the file was successfully opened for reading.
Definition: LArBadChannelParser2.cxx:24
LArBadChannelParser2::m_filename
const std::string m_filename
Definition: LArBadChannelParser2.h:52
LArBadChannelParser2::~LArBadChannelParser2
~LArBadChannelParser2()
Definition: LArBadChannelParser2.cxx:19
LArBadChannelParser2::LArBadChannelParser2
LArBadChannelParser2(const std::string &filename, MsgStream *const messager)
A parser object must be initialized with the filename that it is to parse.
Definition: LArBadChannelParser2.cxx:10
LArBadChannelParser2::m_log
MsgStream *const m_log
Definition: LArBadChannelParser2.h:53
LArBadChannelParser2::m_linenumber
unsigned int m_linenumber
Definition: LArBadChannelParser2.h:51
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
LArBadChannelParser2::parseISfile
std::vector< ISLine > parseISfile(int nint, int minString, int firstWildcard=-1)
parse the file using the format "nint consecutive integers and then at least minString strings" and r...
Definition: LArBadChannelParser2.cxx:30
LArBadChannelParser2::parseLine
bool parseLine(std::string &readLine, ISLine &parsedLine, int nint, int minString, int firstWildcard)
Definition: LArBadChannelParser2.cxx:53
LArBadChannelParser2
Definition: LArBadChannelParser2.h:15
get_generator_info.command
string command
Definition: get_generator_info.py:38
LArBadChannelParser2::ISLine::stringVec
std::vector< std::string > stringVec
Definition: LArBadChannelParser2.h:20