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);
358 dynamic_cast<ISstream&
>(is).getLine(line);
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);
const variable & variableToken() const
const functionName & functionNameToken() const
string expand(const string &, const HashTable< string, word, string::hash > &mapping, const char sigil='$')
Expand occurrences of variables according to the mapping.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void evaluate(GeometricField< Type, PatchField, GeoMesh > &result, const Function1< Type > &func, const GeometricField< Type, PatchField, GeoMesh > &x)
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A 2-tuple for storing two objects of different types.
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 token holds items read from Istream.
static bool New(dictionary &parentDict, Istream &)
Construct from Istream and insert into dictionary.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none/any.
label lineNumber() const
Return current stream line number.
addToMemberFunctionSelectionTable(functionEntry, calcEntry, execute, dictionaryIstream)
A keyword and a list of tokens is a 'primitiveEntry'. An primitiveEntry can be read, written and printed, and the types and values of its tokens analysed.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
A functionName is a word starting with '#'.
static const functionName endifName
virtual const fileName & name() const
Return the name of the stream.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
static const functionName ifName
static const functionName ifeqName
ITstream & stream() const
Return token stream if this entry is a primitive entry.
bool eof() const
Return true if end of input seen.
static const functionName elifName
T remove()
Remove and return the top element.
bool equal(const T &s1, const T &s2)
string & inplaceExpand(string &, const HashTable< string, word, string::hash > &mapping, const char sigil='$')
Inplace expand occurrences of variables according to the mapping.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Input from memory buffer stream.
Macros for easy insertion into member function selection tables.
bool isFunctionName() const
const doubleScalar e
Elementary charge.
static const functionName elseName
T & last()
Return the last element of the list.
defineTypeNameAndDebug(calcEntry, 0)