expressionEntry Class Reference

Convert dictionary entry to a stringified expression. More...

Inheritance diagram for expressionEntry:
[legend]

Public Member Functions

 TypeNameNoDebug ("expressionEntry")
 Runtime type information. More...
 
 declareRunTimeSelectionTable (autoPtr, expressionEntry, empty,(),())
 
 expressionEntry ()=default
 Construct null. More...
 
virtual ~expressionEntry ()=default
 Destructor. More...
 
virtual string toExpr (const entry &e) const
 To string. Normally with comma separators. More...
 
template<class Type >
Foam::string toExprStr (const Type &data)
 
template<class Type >
Foam::string toExprStr (ITstream &is)
 

Static Public Member Functions

static autoPtr< expressionEntryNew (const word &name)
 Return an entry to expression converter. More...
 
static string evaluate (const entry &e)
 Generic concatenate tokens to space-separated string. More...
 
static void inplaceExpand (std::string &s, const dictionary &dict)
 Inplace expand expression with dictionary variables/entries. More...
 
static expressions::exprString expand (const std::string &str, const dictionary &dict)
 Expand expression with dictionary entries. More...
 

Static Protected Member Functions

template<class Type >
static string toExprStr (const Type &data)
 
template<class Type >
static string toExprStr (ITstream &is)
 

Detailed Description

Convert dictionary entry to a stringified expression.

The general OpenFOAM dictionary expansions will result in space-separated values. For example,

    origin (0.21 0 0.01);

    condition  "mag(pos() - $centre) < 0.5";

this will expand to the following:

    condition  "mag(pos() - (0.21 0 0.01)) < 0.5";

For these type of expressions, we'd would like better control. Using instead the special expansions, we can add an effective type cast.

    condition  "mag(pos() - $[(vector)centre]) < 0.5";

which will expand to the following:

    condition  "mag(pos() - vector(0.21,0,0.01)) < 0.5";
Source files

Definition at line 85 of file expressionEntry.H.

Constructor & Destructor Documentation

◆ expressionEntry()

expressionEntry ( )
default

Construct null.

◆ ~expressionEntry()

virtual ~expressionEntry ( )
virtualdefault

Destructor.

Member Function Documentation

◆ toExprStr() [1/4]

static string toExprStr ( const Type &  data)
staticprotected

Stringified version of data with comma-separated components. Uses prefix corresponding to the pTraits of Type.

◆ toExprStr() [2/4]

static string toExprStr ( ITstream is)
staticprotected

Comma-separated stringified version of primitiveEntry of Type. Prefix corresponding to the pTraits of Type

◆ TypeNameNoDebug()

TypeNameNoDebug ( "expressionEntry"  )

Runtime type information.

◆ declareRunTimeSelectionTable()

declareRunTimeSelectionTable ( autoPtr  ,
expressionEntry  ,
empty  ,
()  ,
()   
)

◆ New()

Foam::autoPtr< Foam::exprTools::expressionEntry > New ( const word name)
static

Return an entry to expression converter.

Definition at line 117 of file expressionEntry.C.

References Foam::exit(), Foam::FatalError, FatalErrorInLookup, and Foam::name().

Here is the call graph for this function:

◆ evaluate()

Foam::string evaluate ( const entry e)
inlinestatic

Generic concatenate tokens to space-separated string.

Definition at line 34 of file expressionEntryI.H.

References e.

Referenced by expressionEntry::toExpr().

Here is the caller graph for this function:

◆ inplaceExpand()

void inplaceExpand ( std::string &  s,
const dictionary dict 
)
static

Inplace expand expression with dictionary variables/entries.

Expansion behaviour
  • alternatives = True
  • environment = True
  • allow empty = True
  • subDict = False

Definition at line 140 of file expressionEntry.C.

References dict, Foam::exit(), Foam::FatalError, FatalErrorInFunction, Foam::getVariableOrDie(), Foam::stringOps::inplaceExpand(), Foam::stringOps::inplaceTrim(), Time::New(), Foam::nl, s(), UList< T >::size(), entry::stream(), and ITstream::toString().

Referenced by exprString::inplaceExpand().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ expand()

Foam::expressions::exprString expand ( const std::string &  str,
const dictionary dict 
)
static

Expand expression with dictionary entries.

Definition at line 280 of file expressionEntry.C.

References dict, and s().

Here is the call graph for this function:

◆ toExpr()

virtual string toExpr ( const entry e) const
inlinevirtual

To string. Normally with comma separators.

Reimplemented in boolEntry, dimensionedScalarEntry, dimensionedVectorEntry, dimensionedTensorEntry, dimensionedSymmTensorEntry, dimensionedSphericalTensorEntry, stringEntry, vectorEntry, tensorEntry, symmTensorEntry, and sphericalTensorEntry.

Definition at line 161 of file expressionEntry.H.

References e, and expressionEntry::evaluate().

Here is the call graph for this function:

◆ toExprStr() [3/4]

Foam::string toExprStr ( const Type &  data)
inline

Definition at line 42 of file expressionEntryI.H.

References Foam::component(), and StringStreamAllocator< StreamType >::str().

Here is the call graph for this function:

◆ toExprStr() [4/4]

Foam::string toExprStr ( ITstream is)
inline

Definition at line 60 of file expressionEntryI.H.

References Foam::Zero.


The documentation for this class was generated from the following files: