Loading...
Searching...
No Matches
substitutionModel Class Referenceabstract

Base class for substitution models. More...

#include <substitutionModel.H>

Inheritance diagram for substitutionModel:
Collaboration diagram for substitutionModel:

Public Member Functions

 TypeName ("substitutionModel")
 Runtime type information.
 declareRunTimeSelectionTable (autoPtr, substitutionModel, dictionary,(const dictionary &dict, const Time &time),(dict, time))
 substitutionModel (const dictionary &dict, const Time &time)
 Constructor.
virtual ~substitutionModel ()=default
 Destructor.
virtual bool update ()
 Update model local data.
virtual bool valid (const word &keyName) const =0
 Return true of model applies to this keyName.
virtual bool apply (const word &key, string &buffer) const =0
 Apply substitutions to this string buffer.
virtual wordList keys () const =0
 Return a word list of the keys.

Static Public Member Functions

static string keyify (const word &w)
 Return a key representation from a word.
static word cleanKey (const string &str)
 Clean the key text.
static wordList getKeys (string &buffer)
 Return all keys from a string buffer.
static void addBuiltinStr (const word &key, const string &value)
 Add a builtin to the hash table - does not overwrite.
template<class Type>
static void addBuiltin (const word &key, const Type &value)
 Add a builtin to the hash table - does not overwrite.
static bool containsBuiltin (const word &key)
 Return true if key is builtin.
static void setBuiltinStr (const word &key, const string &value)
 Set a builtin to the hash table.
template<class Type>
static void setBuiltin (const word &key, const Type &value)
 Set a builtin to the hash table.
static bool replaceBuiltin (const word &key, string &str)
 Replace key in string.
static bool replaceBuiltin (string &str)
 Replace all occurrences of key in string.
static void writeBuiltins (Ostream &os)
 Write all builtins to stream.
static autoPtr< substitutionModel > New (const dictionary &dict, const Time &time)
 Return a reference to the selected substitution model.

Static Public Attributes

static const word KEY_BEGIN = "{{"
 Keyword starting characters.
static const word KEY_END = "}}"
 Keyword ending characters.
static HashTable< stringbuiltin_
 Built-in substitutions.

Protected Attributes

const dictionary dict_
 Construction dictionary.
const Timetime_
 Reference to the time database.

Detailed Description

Base class for substitution models.

Provides a static hash table for builtin keyword-value pairs and functions to manipulate/interact.

Source files

Definition at line 52 of file substitutionModel.H.

Constructor & Destructor Documentation

◆ substitutionModel()

substitutionModel ( const dictionary & dict,
const Time & time )

Constructor.

Definition at line 149 of file substitutionModel.C.

References dict, dict_, and time_.

◆ ~substitutionModel()

virtual ~substitutionModel ( )
virtualdefault

Destructor.

Member Function Documentation

◆ keyify()

Foam::string keyify ( const word & w)
static

Return a key representation from a word.

Definition at line 38 of file substitutionModel.C.

References KEY_BEGIN, and KEY_END.

Referenced by environmentVariable::apply(), fileRegEx::apply(), functionObjectValue::apply(), userValue::apply(), getKeys(), dictionaryValue::processDict(), replaceBuiltin(), replaceBuiltin(), and writeBuiltins().

Here is the caller graph for this function:

◆ cleanKey()

Foam::word cleanKey ( const string & str)
static

Clean the key text.

Definition at line 44 of file substitutionModel.C.

References Foam::stringOps::trim(), and Foam::stringOps::upper().

Referenced by addBuiltinStr(), dictionaryValue::dictionaryValue(), environmentVariable::environmentVariable(), fileRegEx::fileRegEx(), functionObjectValue::functionObjectValue(), getKeys(), setBuiltinStr(), and userValue::userValue().

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

◆ getKeys()

Foam::wordList getKeys ( string & buffer)
static

Return all keys from a string buffer.

Also cleans the key strings in the buffer

Definition at line 50 of file substitutionModel.C.

References cleanKey(), k, KEY_BEGIN, KEY_END, keyify(), keys(), string::length(), Foam::pos(), and Foam::pos0().

Referenced by foamReport::parseTemplate().

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

◆ addBuiltinStr()

void addBuiltinStr ( const word & key,
const string & value )
static

Add a builtin to the hash table - does not overwrite.

Definition at line 84 of file substitutionModel.C.

References builtin_, and cleanKey().

Referenced by addBuiltin(), and foamReport::setStaticBuiltins().

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

◆ addBuiltin()

template<class Type>
void addBuiltin ( const word & key,
const Type & value )
static

Add a builtin to the hash table - does not overwrite.

Definition at line 22 of file substitutionModelTemplates.C.

References addBuiltinStr(), and OStringStream::str().

Referenced by foamReport::setStaticBuiltins().

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

◆ containsBuiltin()

bool containsBuiltin ( const word & key)
static

Return true if key is builtin.

Definition at line 94 of file substitutionModel.C.

References builtin_.

◆ setBuiltinStr()

void setBuiltinStr ( const word & key,
const string & value )
static

Set a builtin to the hash table.

Definition at line 100 of file substitutionModel.C.

References builtin_, and cleanKey().

Referenced by setBuiltin(), and foamReport::setDynamicBuiltins().

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

◆ setBuiltin()

template<class Type>
void setBuiltin ( const word & key,
const Type & value )
static

Set a builtin to the hash table.

Definition at line 31 of file substitutionModelTemplates.C.

References setBuiltinStr(), and OStringStream::str().

Referenced by foamReport::setDynamicBuiltins().

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

◆ replaceBuiltin() [1/2]

bool replaceBuiltin ( const word & key,
string & str )
static

Replace key in string.

Definition at line 110 of file substitutionModel.C.

References builtin_, keyify(), and string::replaceAll().

Referenced by foamReport::apply(), dictionaryValue::apply(), and fileRegEx::apply().

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

◆ replaceBuiltin() [2/2]

bool replaceBuiltin ( string & str)
static

Replace all occurrences of key in string.

Definition at line 122 of file substitutionModel.C.

References builtin_, forAllConstIters, KEY_BEGIN, keyify(), and string::replaceAll().

Here is the call graph for this function:

◆ writeBuiltins()

void writeBuiltins ( Ostream & os)
static

Write all builtins to stream.

Definition at line 138 of file substitutionModel.C.

References builtin_, keyify(), Foam::nl, and os().

Referenced by foamReport::write().

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

◆ TypeName()

TypeName ( "substitutionModel" )

Runtime type information.

◆ declareRunTimeSelectionTable()

declareRunTimeSelectionTable ( autoPtr ,
substitutionModel ,
dictionary ,
(const dictionary &dict, const Time &time) ,
(dict, time)  )

References dict.

◆ New()

Foam::autoPtr< Foam::substitutionModel > New ( const dictionary & dict,
const Time & time )
static

Return a reference to the selected substitution model.

Definition at line 26 of file substitutionModelNew.C.

References dict, Foam::endl(), Foam::exit(), Foam::FatalIOError, FatalIOErrorInLookup, and Foam::Info.

Referenced by foamReport::read().

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

◆ update()

virtual bool update ( )
inlinevirtual

Update model local data.

Reimplemented in functionObjectValue.

Definition at line 221 of file substitutionModel.H.

◆ valid()

virtual bool valid ( const word & keyName) const
pure virtual

Return true of model applies to this keyName.

Implemented in dictionaryValue, environmentVariable, fileRegEx, functionObjectValue, and userValue.

◆ apply()

virtual bool apply ( const word & key,
string & buffer ) const
pure virtual

Apply substitutions to this string buffer.

Implemented in dictionaryValue, environmentVariable, fileRegEx, functionObjectValue, and userValue.

◆ keys()

virtual wordList keys ( ) const
pure virtual

Return a word list of the keys.

Implemented in dictionaryValue, environmentVariable, fileRegEx, functionObjectValue, and userValue.

Referenced by getKeys().

Here is the caller graph for this function:

Member Data Documentation

◆ KEY_BEGIN

const Foam::word KEY_BEGIN = "{{"
static

Keyword starting characters.

Definition at line 61 of file substitutionModel.H.

Referenced by getKeys(), keyify(), and replaceBuiltin().

◆ KEY_END

const Foam::word KEY_END = "}}"
static

Keyword ending characters.

Definition at line 66 of file substitutionModel.H.

Referenced by getKeys(), and keyify().

◆ builtin_

Foam::HashTable< Foam::string > builtin_
static

Built-in substitutions.

Definition at line 71 of file substitutionModel.H.

Referenced by addBuiltinStr(), containsBuiltin(), replaceBuiltin(), replaceBuiltin(), setBuiltinStr(), and writeBuiltins().

◆ dict_

const dictionary dict_
protected

Construction dictionary.

Definition at line 158 of file substitutionModel.H.

Referenced by substitutionModel().

◆ time_

const Time& time_
protected

Reference to the time database.

Definition at line 163 of file substitutionModel.H.

Referenced by dictionaryValue::apply(), substitutionModel(), and functionObjectValue::update().


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