38namespace functionEntries
56void Foam::functionEntries::ifeqEntry::readToken(token& t, Istream& is)
61 if (is.read(t).bad() || is.eof() || !t.good())
70Foam::token Foam::functionEntries::ifeqEntry::expandToken
72 const dictionary&
dict,
73 const string& keyword,
77 if (keyword[0] ==
'$')
79 const word varName(keyword.substr(1));
85 return token(ePtr->stream());
90 string expanded(keyword);
94 return token(expanded, t.lineNumber());
97 else if (!t.isString())
100 return token(keyword, t.lineNumber());
107Foam::token Foam::functionEntries::ifeqEntry::expandToken
109 const dictionary&
dict,
115 return expandToken(
dict, t.wordToken(), t);
117 else if (t.isVariable())
119 return expandToken(
dict, t.stringToken(), t);
121 else if (t.isString())
123 return expandToken(
dict, t.stringToken(), t);
130bool Foam::functionEntries::ifeqEntry::equalToken
136 const bool eqType = (t1.type() == t2.type());
144 return (eqType && t1.boolToken() == t2.boolToken());
147 return (eqType && t1.flagToken() == t2.flagToken());
150 return (eqType && t1.pToken() == t2.pToken());
156 return t1.wordToken() == t2.wordToken();
158 else if (t2.isString())
161 return w2.match(t1.wordToken());
170 return w1.match(
w2) ||
w2.match(
w1);
172 else if (t2.isWord())
175 return w1.match(t2.wordToken());
181 if (t2.isStringType())
183 return t1.stringToken() == t2.stringToken();
190 return t1.labelToken() == t2.labelToken();
192 else if (t2.isScalar())
194 return t1.labelToken() == t2.scalarToken();
201 return equal(t1.floatToken(), t2.floatToken());
203 else if (t2.isLabel())
205 return t1.floatToken() == t2.labelToken();
207 else if (t2.isScalar())
209 return t1.scalarToken() == t2.scalarToken();
216 return equal(t1.doubleToken(), t2.doubleToken());
218 else if (t2.isLabel())
220 return t1.doubleToken() == t2.labelToken();
222 else if (t2.isScalar())
224 return t1.scalarToken() == t2.scalarToken();
242void Foam::functionEntries::ifeqEntry::skipUntil
244 DynamicList<filePos>& stack,
245 const dictionary& parentDict,
246 const word& endDirective,
255 if (!t.isDirective())
259 else if (t.wordToken() ==
"#if" || t.wordToken() ==
"#ifeq")
261 stack.append(filePos(is.name(), is.lineNumber()));
262 skipUntil(stack, parentDict,
"#endif", is);
265 else if (t.wordToken() == endDirective)
272 <<
"Did not find matching " << endDirective <<
nl
291 bool pending =
false;
298 execute(stack, parentDict, is);
312 skipUntil(stack, parentDict,
"#endif", is);
355 evaluate(
true, stack, parentDict, is);
374 skipUntil(stack, parentDict,
"#endif", is);
392 if (ifEntry::isTrue(
e.stream()))
409 evaluate(
false, stack, parentDict, is);
414 evaluate(
true, stack, parentDict, is);
428 const label nNested = stack.
size();
434 cond1 = expandToken(parentDict, cond1);
438 cond2 = expandToken(parentDict, cond2);
440 const bool equal = equalToken(cond1, cond2);
449 if (stack.
size() != nNested)
452 <<
"Did not find matching #endif for condition starting"
453 <<
" at line " << stack.
last().second()
470 return execute(stack, parentDict, is);
Macros for easy insertion into member function selection tables.
#define addNamedToMemberFunctionSelectionTable(baseType, thisType, funcName, argNames, lookupName)
Add to hash-table of functions with 'lookupName' as the key.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
T remove()
Remove and return the last element. Fatal on an empty list.
void append(const T &val)
Copy append an element to the end of this list.
void evaluate()
Evaluate boundary conditions.
label lineNumber() const noexcept
Const access to the current stream line number.
virtual const fileName & name() const
Return the name of the stream.
bool eof() const noexcept
True if end of input seen.
Generic input stream using a standard (STL) stream.
Input from string buffer, using a ISstream. Always UNCOMPRESSED.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
void putBack(const token &tok)
Put back a token. Only a single put back is permitted.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
void size(const label n)
Older name for setAddressableSize.
T & last()
Return the last element of the list.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Conditional parsing of dictionary entries.
A functionEntry causes entries to be added/manipulated on the specified dictionary given an input str...
virtual bool execute()
Calculate the output fields.
A keyword and a list of tokens comprise a primitiveEntry. A primitiveEntry can be read,...
A token holds an item read from Istream.
@ LABEL
label (integer) type
@ ERROR
Token error encountered.
@ DOUBLE
double (double-precision) type
@ FLAG
stream flag (1-byte bitmask)
@ UNDEFINED
An undefined token-type.
@ COMPOUND
Compound type such as List<label> etc.
@ FLOAT
float (single-precision) type
@ STRING
Foam::string (usually double-quoted)
@ PUNCTUATION
single character punctuation
@ END_STATEMENT
End entry [isseparator].
bool isDirective() const noexcept
Token is DIRECTIVE (word variant)
const word & wordToken() const
Return const reference to the word contents.
@ DETECT
Detect if the string contains meta-characters.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
void inplaceExpand(std::string &s, const HashTable< string > &mapping, const char sigil='$')
bool equal(const T &s1, const T &s2)
Compare two values for equality.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)