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.labelToken() == t2.labelToken();
159 else if (t2.isScalar())
161 return t1.labelToken() == t2.scalarToken();
171 return equal(t1.floatScalarToken(), t2.floatScalarToken());
173 else if (t2.isScalar())
175 return t1.scalarToken() == t2.scalarToken();
185 return equal(t1.doubleScalarToken(), t2.doubleScalarToken());
187 else if (t2.isScalar())
189 return t1.scalarToken() == t2.scalarToken();
201 t1.longDoubleScalarToken(),
202 t2.longDoubleScalarToken()
205 else if (t2.isScalar())
207 return t1.scalarToken() == t2.scalarToken();
225 void Foam::functionEntries::ifeqEntry::skipUntil
227 DynamicList<filePos>& stack,
228 const dictionary& parentDict,
229 const functionName& endWord,
237 if (t.isFunctionName())
241 t.functionNameToken() == ifName
242 || t.functionNameToken() == ifeqName
245 stack.append(filePos(is.name(), is.lineNumber()));
246 skipUntil(stack, parentDict, endifName, is);
249 else if (t.functionNameToken() == endWord)
261 bool Foam::functionEntries::ifeqEntry::evaluate
264 DynamicList<filePos>& stack,
265 dictionary& parentDict,
274 if (t.isFunctionName() && t.functionNameToken() == ifeqName)
277 execute(stack, parentDict, is);
279 else if (t.isFunctionName() && t.functionNameToken() == ifName)
282 ifEntry::execute(stack, parentDict, is);
287 && t.isFunctionName()
289 t.functionNameToken() == elseName
290 || t.functionNameToken() == elifName
295 skipUntil(stack, parentDict, endifName, is);
299 else if (t.isFunctionName() && t.functionNameToken() == endifName)
318 bool Foam::functionEntries::ifeqEntry::execute
328 evaluate(
true, stack, parentDict, is);
347 skipUntil(stack, parentDict, endifName, is);
383 evaluate(
false, stack, parentDict, is);
388 evaluate(
true, stack, parentDict, is);
395 bool Foam::functionEntries::ifeqEntry::execute
408 cond1 =
expand(parentDict, cond1);
412 cond2 =
expand(parentDict, cond2);
414 const bool equal = equalToken(cond1, cond2);
421 bool ok = ifeqEntry::execute(
equal, stack, parentDict, is);
423 if (stack.
size() != nNested)
426 <<
"Did not find matching #endif for condition starting"
427 <<
" at line " << stack.
last().second()
437 bool Foam::functionEntries::ifeqEntry::execute
444 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 expand(const string &, const HashTable< string, word, string::hash > &mapping, const char sigil='$')
Expand occurrences of variables according to the mapping.
string & inplaceExpand(string &, const HashTable< string, word, string::hash > &mapping, const char sigil='$')
Inplace expand occurrences of variables according to the mapping.
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)