59 const label lBegin = KEY_BEGIN.length();
60 const label lEnd = KEY_END.length();
66 string cleanedBuffer =
"";
67 while (((
pos = buffer.find(KEY_BEGIN,
pos)) != string::npos))
71 size_t posEnd = buffer.find(KEY_END,
pos);
73 if (posEnd != string::npos)
75 const word k(cleanKey(buffer.substr(
pos+lBegin, posEnd-
pos-lEnd)));
77 cleanedBuffer += keyify(
k);
85 buffer = cleanedBuffer;
119 if (builtin_.found(key))
121 str.
replaceAll(keyify(key), builtin_[key].c_str());
131 const string str0 = str;
134 if (str.find(KEY_BEGIN) == string::npos)
return false;
138 str.replaceAll(
keyify(iter.key()), iter.val().c_str());
147 for (
const auto& iter : builtin_.csorted())
149 os <<
keyify(iter.key()).c_str() <<
" : " << iter.val() <<
nl;
156Foam::substitutionModel::substitutionModel
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
A HashTable similar to std::unordered_map.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A class for handling character strings derived from std::string.
static std::string::size_type length(const char *s)
Length of the character sequence (with nullptr protection).
string & replaceAll(const std::string &s1, const std::string &s2, size_type pos=0)
Replace all occurrences of sub-string s1 with s2, beginning at pos in the string.
Base class for substitution models.
const Time & time_
Reference to the time database.
static wordList getKeys(string &buffer)
Return all keys from a string buffer.
static bool containsBuiltin(const word &key)
Return true if key is builtin.
static const word KEY_END
Keyword ending characters.
static const word KEY_BEGIN
Keyword starting characters.
static void writeBuiltins(Ostream &os)
Write all builtins to stream.
virtual wordList keys() const =0
Return a word list of the keys.
const dictionary dict_
Construction dictionary.
static word cleanKey(const string &str)
Clean the key text.
static void setBuiltinStr(const word &key, const string &value)
Set a builtin to the hash table.
static string keyify(const word &w)
Return a key representation from a word.
static HashTable< string > builtin_
Built-in substitutions.
static bool replaceBuiltin(const word &key, string &str)
Replace key in string.
static void addBuiltinStr(const word &key, const string &value)
Add a builtin to the hash table - does not overwrite.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
OBJstream os(runTime.globalPath()/outputName)
string trim(const std::string &s)
Return string trimmed of leading and trailing whitespace.
string upper(const std::string &s)
Return string copy transformed with std::toupper on each character.
dimensionedScalar pos(const dimensionedScalar &ds)
List< word > wordList
List of word.
HashSet< word, Hash< word > > wordHashSet
A HashSet of words, uses string hasher.
dimensionedScalar pos0(const dimensionedScalar &ds)
constexpr char nl
The newline '\n' character (0x0a).
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.