ATLAS Offline Software
Loading...
Searching...
No Matches
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
13class MsgStream;
14
16public:
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
48private:
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
65inline 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
bool parseLine(std::string &readLine, ISLine &parsedLine, int nint, int minString, int firstWildcard)
bool stringToInt(int &theInt, const std::string &theStr) const
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...
bool interpretLine(const std::vector< std::string > &command, ISLine &parsedLine, int nint, int minString, int firstWildcard)
const std::string m_filename
LArBadChannelParser2(const std::string &filename, MsgStream *const messager)
A parser object must be initialized with the filename that it is to parse.
bool fileStatusGood() const
You can use this function to check whether the file was successfully opened for reading.
std::vector< std::string > stringVec