7#include "GaudiKernel/MsgStream.h"
15 std::cerr <<
"WARNING \t LArBadChannelParser was given a NULL MsgStream pointer!" << std::endl;
29std::vector< LArBadChannelParser2::ISLine>
33 std::vector< LArBadChannelParser2::ISLine>
result;
35 while (
m_fin.good()) {
37 std::getline(
m_fin, readLine);
42 if (
parseLine( readLine, parsedLine, nint, minString, firstWildcard)) {
43 result.push_back(std::move(parsedLine));
47 (*m_log) << MSG::WARNING <<
"LArBadChannelParser REJECTED line " << readLine <<
endmsg;
54 int nint,
int minString,
int firstWildcard)
56 std::string::size_type commentPosition = readLine.find(
'#');
57 if(commentPosition != std::string::npos)
58 readLine.erase(commentPosition);
61 std::vector<std::string> command;
63 std::istringstream stringIn(readLine);
66 command.push_back(readWord);
69 if(!command.empty()) {
70 bool success =
interpretLine( command, parsedLine, nint, minString, firstWildcard);
78 int nint,
int minString,
int firstWildcard)
80 if((
int)command.size() < nint+minString) {
81 (*m_log) << MSG::WARNING <<
"LArBadChannelParser REJECTED line " <<
m_linenumber \
82 <<
":\t not enough parameters given" <<
endmsg;
86 for(
int i=0; i<nint; i++) {
88 if (firstWildcard >=0 && i>=firstWildcard && command[i] ==
"*") {
89 parsedLine.
intVec.push_back(-1);
91 else if(
stringToInt(nextInt, command[i]) && nextInt >= 0) {
92 parsedLine.
intVec.push_back( nextInt);
95 (*m_log) << MSG::WARNING <<
"LArBadChannelParser REJECTED line " <<
m_linenumber \
96 <<
":\t word " << i + 1 <<
" must be a non-negative integer: " << command[i] <<
endmsg;
102 parsedLine.
stringVec.insert( parsedLine.
stringVec.end(), command.begin()+nint, command.end());
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.
unsigned int m_linenumber
bool fileStatusGood() const
You can use this function to check whether the file was successfully opened for reading.
std::vector< int > intVec
std::vector< std::string > stringVec