#include <LArBadChannelParser2.h>
|
| LArBadChannelParser2 (const std::string &filename, MsgStream *const messager) |
| A parser object must be initialized with the filename that it is to parse. More...
|
|
| ~LArBadChannelParser2 () |
|
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 return the result as a vector of all successfully parsed lines. More...
|
|
bool | fileStatusGood () const |
| You can use this function to check whether the file was successfully opened for reading. More...
|
|
Definition at line 15 of file LArBadChannelParser2.h.
◆ LArBadChannelParser2()
LArBadChannelParser2::LArBadChannelParser2 |
( |
const std::string & |
filename, |
|
|
MsgStream *const |
messager |
|
) |
| |
A parser object must be initialized with the filename that it is to parse.
It must also be given a MsgStream pointer for logging messages.
Definition at line 10 of file LArBadChannelParser2.cxx.
15 std::cerr <<
"WARNING \t LArBadChannelParser was given a NULL MsgStream pointer!" << std::endl;
◆ ~LArBadChannelParser2()
LArBadChannelParser2::~LArBadChannelParser2 |
( |
| ) |
|
◆ fileStatusGood()
bool LArBadChannelParser2::fileStatusGood |
( |
| ) |
const |
You can use this function to check whether the file was successfully opened for reading.
Definition at line 24 of file LArBadChannelParser2.cxx.
◆ interpretLine()
bool LArBadChannelParser2::interpretLine |
( |
const std::vector< std::string > & |
command, |
|
|
ISLine & |
parsedLine, |
|
|
int |
nint, |
|
|
int |
minString, |
|
|
int |
firstWildcard |
|
) |
| |
|
private |
Definition at line 76 of file LArBadChannelParser2.cxx.
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);
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());
◆ parseISfile()
parse the file using the format "nint consecutive integers and then at least minString strings" and return the result as a vector of all successfully parsed lines.
The int part of a line may contain wildcards, starting from position firstWildcard; firstWildcard=-1 means "no wildcards". The wildcard character in the input file is "*", it is replaced by -1 in the parsed output. Lines that failed to parse are skipped, with diagnostic messages sent to the message stream.
Definition at line 30 of file LArBadChannelParser2.cxx.
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(parsedLine);
47 (*m_log) << MSG::WARNING <<
"LArBadChannelParser REJECTED line " << readLine <<
endmsg;
◆ parseLine()
bool LArBadChannelParser2::parseLine |
( |
std::string & |
readLine, |
|
|
ISLine & |
parsedLine, |
|
|
int |
nint, |
|
|
int |
minString, |
|
|
int |
firstWildcard |
|
) |
| |
|
private |
Definition at line 53 of file LArBadChannelParser2.cxx.
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);
◆ stringToInt()
bool LArBadChannelParser2::stringToInt |
( |
int & |
theInt, |
|
|
const std::string & |
theStr |
|
) |
| const |
|
inlineprivate |
Definition at line 65 of file LArBadChannelParser2.h.
67 std::istringstream iss(theStr);
70 iss >> std::dec >> theInt;
71 return !iss.fail() && iss.eof();
◆ m_filename
const std::string LArBadChannelParser2::m_filename |
|
private |
◆ m_fin
std::ifstream LArBadChannelParser2::m_fin |
|
private |
◆ m_linenumber
unsigned int LArBadChannelParser2::m_linenumber |
|
private |
◆ m_log
MsgStream* const LArBadChannelParser2::m_log |
|
private |
The documentation for this class was generated from the following files: