Go to the documentation of this file.
52 static string getEntryString
54 const dictionary&
dict,
63 <<
"Entry " << key <<
" not found in "
67 else if (eptr->isDict())
70 <<
"Entry " << key <<
" found in "
99 debugScanner_(
dict.getOrDefault(
"debugScanner",
false)),
100 debugParser_(
dict.getOrDefault(
"debugParser",
false)),
103 dict.getOrDefault(
"allowShadowing",
false)
107 dict.getOrDefault(
"prevIterIsOldTime",
false)
109 cacheReadFields_(cacheReadFields),
110 searchInMemory_(searchInMemory || cacheReadFields),
111 searchFiles_(searchFiles)
145 dict.getOrDefault(
"cacheReadFields",
false),
146 dict.getOrDefault(
"searchInMemory",
true),
147 dict.getOrDefault(
"searchFiles",
false),
162 dict.readIfPresent(
"debugBaseDriver",
debug);
165 variableStrings_ = readVariableStrings(
dict);
195 addVariables(variableStrings_,
false);
218 result_.testIfSingleValue();
221 <<
"Evaluating: " << expr <<
" -> " << varName <<
endl
263 const auto varExpressions =
264 stringOps::split<expressions::exprString>(expr,
';');
266 for (
const auto& subMatch : varExpressions)
279 const auto eqPos = varExpr.find(
'=');
281 if (eqPos == std::string::npos)
284 <<
"No '=' found in expression " << varExpr <<
nl <<
nl
298 varExpr.resize(eqPos);
302 const auto lbrace = varExpr.find(
'{');
304 if (lbrace != std::string::npos)
306 const auto rbrace = varExpr.find(
'}');
308 if (rbrace == std::string::npos || rbrace < lbrace)
312 <<
"No closing '}' found in " << varExpr <<
nl
315 else if (lbrace+1 == rbrace)
319 <<
"Empty '{}' location in " << varExpr <<
nl
329 varExpr.substr(lbrace+1, rbrace-lbrace-1)
335 evaluateVariableRemote(remoteExpr, varName, rhsExpr);
341 evaluateVariable(varName, rhsExpr);
358 for (
const auto& expr : list)
360 addVariables(expr,
false);
371 debugScanner_ = scannerDebug;
372 debugParser_ = parserDebug;
388 bool cacheReadFields,
393 searchInMemory_ = searchInMemory_ || cacheReadFields_;
397 <<
" registry:" << searchInMemory_
398 <<
" disk:" << searchFiles_
399 <<
" cache-read:" << cacheReadFields_ <<
nl;
virtual void updateSpecialVariables(bool force=false)
Examine current variable values and update stored variables.
int debug
Static debugging option.
static string evaluate(const entry &e)
Generic concatenate tokens to space-separated string.
bool prevIterIsOldTime_
Use value of previous iteration when oldTime is requested.
bool debugParser_
Request debugging for parser.
void addVariables(const expressions::exprString &expr, bool clear=true)
Add/set string expressions for variables.
bool searchInMemory_
Search in registry before looking on disk.
A class for handling words, derived from Foam::string.
void inplaceTrim(std::string &s)
Trim leading and trailing whitespace inplace.
virtual bool readDict(const dictionary &dict)
Read variables, tables etc.
void setSearchBehaviour(bool cacheReadFields, bool searchInMemory, bool searchFiles)
Set search behaviour.
bool searchFiles_
Search on disk (eg, for a standalone application)
void evaluateVariable(const word &varName, const expressions::exprString &expr)
static exprString toExpr(const std::string &str)
Copy convert string to exprString.
string trim(const std::string &s)
Return string trimmed of leading and trailing whitespace.
static word validate(const std::string &s, const bool prefix=false)
Construct validated word (no invalid characters).
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool debugScanner_
Request debugging for scanner.
const dictionary & dict_
The dictionary with all input data/specification.
void setDebugging(bool scannerDebug, bool parserDebug)
Set the scanner/parser debug.
bool allowShadowing_
Allow variable names to mask field names.
virtual void setArgument(const scalar val)
Set special-purpose scalar reference argument.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
const fileName & name() const
The dictionary name.
virtual exprResult getRemoteResult(const exprDriver &other) const
Get the result from another driver.
A polymorphic field/result from evaluating an expression.
messageStream Info
Information stream (uses stdout - output is on the master only)
HashTable< exprResult > variables_
The variables table.
Base driver for parsing (field) values.
scalar arg1Value_
Special-purpose scalar reference argument.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
virtual void clearVariables()
Clear temporary variables and resets from expression strings.
exprDriver(bool cacheReadFields=false, bool searchInMemory=true, bool searchFiles=false, const dictionary &dict=dictionary::null)
Null constructor, and null construct with search preferences.
bool cacheReadFields_
Keep fields read from disc in memory.
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< expressions::exprString > variableStrings_
Variable definitions, as read from a dictionary.
exprResult getUniform(const label size, const bool noWarn, const bool parRun=Pstream::parRun()) const
Construct a uniform field from the current results.
scalar argValue() const
Set special-purpose scalar reference argument.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define DebugInfo
Report an information message using Foam::Info.
void clear()
Clear (zero) the result.
virtual const exprResult & result() const
Const access to expression result.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find for an entry (non-const access) with the given keyword.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
virtual void evaluateVariableRemote(string remote, const word &varName, const expressions::exprString &expr)
void clearResult()
Clear the result.
defineTypeNameAndDebug(fvExprDriver, 0)
virtual bool update()
Update things.
exprResult result_
The result.