5 #include "G4ExceptionSeverity.hh" 20 ifstream in(filename.c_str());
21 if(!in.is_open())
fail(
"unable to open file");
27 istringstream in(data);
35 if(in.bad())
fail(
"error reading input stream");
58 {getSingle(name, buffer);}
60 {getSingle(name, buffer);}
62 {getSingle(name, buffer);}
64 {getSingle(name, buffer);}
67 {getVector(name, buffer, length);}
69 {getVector(name, buffer, length);}
71 {getVector(name, buffer, length);}
73 {getVector(name, buffer, length);}
79 G4cout <<
"printing LBNEKeyedInput..." << G4endl;
80 G4cout <<
"--------------------------" << G4endl << G4endl;
82 G4cout << it->first <<
": " << it->second << G4endl << G4endl;
84 G4cout <<
"--------------------------" << G4endl << G4endl;
93 if(isLineComment(line))
return;
95 istringstream in(line);
100 readIndexSpec(in, key);
107 if(!in.fail()) value << term <<
' ';
110 varMap[
key] = value.str();
117 for(
size_t i = 0;
i < line.size();
i++) {
118 if(line[
i] ==
'C')
continue;
119 if(isalnum(line[
i]))
return false;
131 streampos
start = in.tellg();
134 if(in.get() !=
'=' || in.fail()) {
135 if(contains(name))
fail(
"duplicate variable", name);
139 else if(index != countTerms(
varMap[name]) + 1) {
140 fail(
"illegal array indexing", name);
147 istringstream in(value);
164 exc <<
"LBNEKeyedInput error:\n";
165 if(key !=
"") exc <<
" variable: " << key <<
'\n';
166 exc <<
" message: " << message <<
'\n';
167 if(expected >= 0) exc <<
" expected: " << expected <<
'\n';
168 G4Exception(exc.str().c_str(),
" " , FatalException,
" " );
175 getVector(name, myVector, 1);
176 buffer = myVector[0];
188 if(buffer.size() != 0)
fail(
"non-empty buffer", name);
189 istringstream in(
varMap[name]);
191 if(in.eof())
fail(
"missing or empty variable", name);
194 parse(in, term, name);
195 buffer.push_back(term);
198 if(length >= 0 && (
size_t)length != buffer.size()) {
199 fail(
"unexpected array length", name, length);
212 checkGotTerm(in,
"expected integer(s)", name);
217 checkGotTerm(in,
"expected floating point number(s)", name);
223 if(term ==
"TRUE" || term ==
"1") buffer =
true;
224 else if(term ==
"FALSE" || term ==
"0") buffer =
false;
225 else in.setstate(ios::failbit);
226 checkGotTerm(in,
"expected boolean(s)", name);
231 size_t size = buffer.size();
232 if(size >= 2 && buffer[0u] ==
'\'' && buffer[size-1u] ==
'\'') {
233 buffer.erase(size-1,1);
237 in.setstate(ios::failbit);
240 "expected string(s) in single quotes, no spaces within string", name);
248 if(in.peek() !=
' ' || in.fail())
fail(message, name);
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
const GenericPointer< typename T::ValueType > T2 value
static QMap< QCString, MemberDef * > varMap