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;
97 builtin_.insert(cleanKey(
key), value.c_str());
103 return builtin_.contains(
key);
113 builtin_.set(cleanKey(
key), value.c_str());
119 if (builtin_.found(
key))
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;
156 Foam::substitutionModel::substitutionModel
158 const dictionary&
dict,
static bool replaceBuiltin(const word &key, string &str)
Replace key in string.
static std::string::size_type length(const char *s)
Length of the character sequence (with nullptr protection)
constexpr char nl
The newline '\n' character (0x0a)
label k
Boltzmann constant.
static void setBuiltinStr(const word &key, const string &value)
Set a builtin to the hash table.
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
static void addBuiltinStr(const word &key, const string &value)
Add a builtin to the hash table - does not overwrite.
dimensionedScalar pos(const dimensionedScalar &ds)
A class for handling words, derived from Foam::string.
string trim(const std::string &s)
Return string trimmed of leading and trailing whitespace.
static const word KEY_BEGIN
Keyword starting characters.
dimensionedScalar pos0(const dimensionedScalar &ds)
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
defineTypeNameAndDebug(combustionModel, 0)
static HashTable< string > builtin_
Built-in substitutions.
string upper(const std::string &s)
Return string copy transformed with std::toupper on each character.
static bool containsBuiltin(const word &key)
Return true if key is builtin.
constexpr auto key(const Type &t) noexcept
Helper function to return the enum value.
static void writeBuiltins(Ostream &os)
Write all builtins to stream.
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. ...
static wordList getKeys(string &buffer)
Return all keys from a string buffer.
static const word KEY_END
Keyword ending characters.
List< Key > toc() const
The table of contents (the keys) in unsorted order.
static word cleanKey(const string &str)
Clean the key text.
static string keyify(const word &w)
Return a key representation from a word.
A class for handling character strings derived from std::string.
forAllConstIters(mixture.phases(), phase)