36 namespace functionEntries
58 void Foam::functionEntries::ifeqEntry::readToken(token& t, Istream& is)
77 Foam::token Foam::functionEntries::ifeqEntry::expand
79 const dictionary&
dict,
87 word varName = var(1, var.size() - 1);
90 const entry* ePtr =
dict.lookupScopedEntryPtr
99 return token(ePtr->stream());
104 string expanded(var);
108 return token(expanded, t.lineNumber());
118 bool Foam::functionEntries::ifeqEntry::equalToken
124 const bool eqType = (t1.type() == t2.type());
132 return (eqType && t1.pToken() == t2.pToken());
138 if (t2.isAnyString())
140 return t1.anyStringToken() == t2.anyStringToken();
149 <<
"Attempt to compare an un-expanded variable"
150 << InfoProxy<token>(t1)
157 return t1.integer32Token() == t2.integer32Token();
159 else if (t2.isLabel())
161 return t1.labelToken() == t2.labelToken();
163 else if (t2.isScalar())
165 return t1.labelToken() == t2.scalarToken();
175 return t1.integer64Token() == t2.integer64Token();
177 else if (t2.isLabel())
179 return t1.labelToken() == t2.labelToken();
181 else if (t2.isScalar())
183 return t1.labelToken() == t2.scalarToken();
194 t1.unsignedInteger32Token() == t2.unsignedInteger32Token();
196 else if (t2.isLabel())
198 return t1.labelToken() == t2.labelToken();
200 else if (t2.isScalar())
202 return t1.labelToken() == t2.scalarToken();
213 t1.unsignedInteger64Token() == t2.unsignedInteger64Token();
215 else if (t2.isLabel())
217 return t1.labelToken() == t2.labelToken();
219 else if (t2.isScalar())
221 return t1.labelToken() == t2.scalarToken();
231 return equal(t1.floatScalarToken(), t2.floatScalarToken());
233 else if (t2.isScalar())
235 return t1.scalarToken() == t2.scalarToken();
245 return equal(t1.doubleScalarToken(), t2.doubleScalarToken());
247 else if (t2.isScalar())
249 return t1.scalarToken() == t2.scalarToken();
261 t1.longDoubleScalarToken(),
262 t2.longDoubleScalarToken()
265 else if (t2.isScalar())
267 return t1.scalarToken() == t2.scalarToken();
285 void Foam::functionEntries::ifeqEntry::skipUntil
287 DynamicList<filePos>& stack,
288 const dictionary& parentDict,
289 const functionName& endWord,
297 if (t.isFunctionName())
301 t.functionNameToken() == ifName
302 || t.functionNameToken() == ifeqName
305 stack.append(filePos(is.name(), is.lineNumber()));
306 skipUntil(stack, parentDict, endifName, is);
309 else if (t.functionNameToken() == endWord)
321 bool Foam::functionEntries::ifeqEntry::evaluate
324 DynamicList<filePos>& stack,
325 dictionary& parentDict,
334 if (t.isFunctionName() && t.functionNameToken() == ifeqName)
337 execute(stack, parentDict, is);
339 else if (t.isFunctionName() && t.functionNameToken() == ifName)
342 ifEntry::execute(stack, parentDict, is);
347 && t.isFunctionName()
349 t.functionNameToken() == elseName
350 || t.functionNameToken() == elifName
355 skipUntil(stack, parentDict, endifName, is);
359 else if (t.isFunctionName() && t.functionNameToken() == endifName)
378 bool Foam::functionEntries::ifeqEntry::execute
388 evaluate(
true, stack, parentDict, is);
407 skipUntil(stack, parentDict, endifName, is);
443 evaluate(
false, stack, parentDict, is);
448 evaluate(
true, stack, parentDict, is);
455 bool Foam::functionEntries::ifeqEntry::execute
468 cond1 =
expand(parentDict, cond1);
472 cond2 =
expand(parentDict, cond2);
474 const bool equal = equalToken(cond1, cond2);
481 bool ok = ifeqEntry::execute(
equal, stack, parentDict, is);
483 if (stack.
size() != nNested)
486 <<
"Did not find matching #endif for condition starting"
487 <<
" at line " << stack.
last().second()
497 bool Foam::functionEntries::ifeqEntry::execute
504 return execute(stack, parentDict, is);
Macros for easy insertion into member function selection tables.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
T remove()
Remove and return the top element.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
label lineNumber() const
Return current stream line number.
virtual const fileName & name() const
Return the name of the stream.
bool eof() const
Return true if end of input seen.
Input from memory buffer stream.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
void size(const label)
Override size to be inconsistent with allocated storage.
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
A 2-tuple for storing two objects of different types.
T & last()
Return the last element of the list.
A list of keyword definitions, which are a keyword followed by any number of values (e....
static bool New(dictionary &parentDict, Istream &)
Construct from Istream and insert into dictionary.
Conditional parsing of dictionary entries.
static const functionName ifeqName
static const functionName ifName
static const functionName endifName
static const functionName elseName
static const functionName elifName
A functionEntry causes entries to be added/manipulated on the specified dictionary given an input str...
A functionName is a word starting with '#'.
A keyword and a list of tokens is a 'primitiveEntry'. An primitiveEntry can be read,...
A token holds items read from Istream.
const variable & variableToken() const
const functionName & functionNameToken() const
bool isFunctionName() const
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
defineTypeNameAndDebug(includeFvConstraintEntry, 0)
addToMemberFunctionSelectionTable(functionEntry, includeFvConstraintEntry, execute, dictionaryIstream)
string & inplaceExpandEntry(string &s, const dictionary &dict, const bool allowEnvVars, const bool allowEmpty, const char sigil='$')
Inplace expand occurrences of variables according to the dictionary.
errorManipArg< error, int > exit(error &err, const int errNo=1)
bool equal(const T &s1, const T &s2)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void evaluate(GeometricField< Type, PatchField, GeoMesh > &result, const Function1< Type > &func, const GeometricField< Type, PatchField, GeoMesh > &x)
string expand(const string &s, string::size_type &index, const dictionary &dict, const bool allowEnvVars, const bool allowEmpty)