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 "
98 debugScanner_(
dict.lookupOrDefault(
"debugScanner",
false)),
99 debugParser_(
dict.lookupOrDefault(
"debugParser",
false)),
102 dict.lookupOrDefault(
"allowShadowing",
false)
106 dict.lookupOrDefault(
"prevIterIsOldTime",
false)
108 cacheReadFields_(cacheReadFields),
109 searchInMemory_(searchInMemory || cacheReadFields),
110 searchFiles_(searchFiles)
143 dict.lookupOrDefault(
"cacheReadFields",
false),
144 dict.lookupOrDefault(
"searchInMemory",
true),
145 dict.lookupOrDefault(
"searchFiles",
false),
160 dict.readIfPresent(
"debugBaseDriver",
debug);
163 variableStrings_ = readVariableStrings(
dict);
193 addVariables(variableStrings_,
false);
204 result_.testIfSingleValue();
207 <<
"Evaluating: " << expr <<
" -> " << varName <<
endl
249 const auto varExpressions =
250 stringOps::split<expressions::exprString>(expr,
';');
252 for (
const auto& subMatch : varExpressions)
265 const auto eqPos = varExpr.find(
'=');
267 if (eqPos == std::string::npos)
270 <<
"No '=' found in expression " << varExpr <<
nl <<
nl
284 varExpr.resize(eqPos);
288 const auto lbrace = varExpr.find(
'{');
290 if (lbrace != std::string::npos)
292 const auto rbrace = varExpr.find(
'}');
294 if (rbrace == std::string::npos || rbrace < lbrace)
298 <<
"No closing '}' found in " << varExpr <<
nl
301 else if (lbrace+1 == rbrace)
305 <<
"Empty '{}' location in " << varExpr <<
nl
315 varExpr.substr(lbrace+1, rbrace-lbrace-1)
321 evaluateVariableRemote(remoteExpr, varName, rhsExpr);
327 evaluateVariable(varName, rhsExpr);
344 for (
const auto& expr : list)
346 addVariables(expr,
false);
357 debugScanner_ = scannerDebug;
358 debugParser_ = parserDebug;
374 bool cacheReadFields,
379 searchInMemory_ = searchInMemory_ || cacheReadFields_;
383 <<
" registry:" << searchInMemory_
384 <<
" disk:" << searchFiles_
385 <<
" 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.
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.
#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.
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.
#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.
string trim(const std::string &str)
Return string trimmed of leading and trailing whitespace.