54 const auto len = code.
length();
56 if (lineNum > 0 && len && !file.empty())
58 code =
"#line " +
Foam::name(lineNum) +
" \"" + file +
"\"\n" + code;
60 return (
code.length() - len);
117 sha1_.append(
"<" + key +
">");
127 <<
"Entry '" << key <<
"' not found in dictionary "
159 return readEntry(key, str,
false, withLineNum);
165 dict_ = std::cref<dictionary>(
dict);
propsDict readIfPresent("fields", acceptFields)
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
const entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
Encapsulation of dynamic code dictionaries.
const string & code() const noexcept
The code.
bool readIfPresent(const word &key, string &str, bool withLineNum=true)
Read optional string entry from context dictionary, append content to SHA1 hashing and add line numbe...
static unsigned addLineDirective(string &code, label lineNum, const string &file)
Prefix a #line directive to code.
void setCodeContext(const dictionary &dict)
Set code context from a dictionary.
bool good() const noexcept
Not using dummy code context (dictionary::null).
bool readEntry(const word &key, string &str, bool mandatory=true, bool withLineNum=true)
Read string entry from context dictionary append content to SHA1 hashing and add line number etc.
static void inplaceExpand(string &str, const dictionary &dict)
Cleanup string and expand with dictionary parameters.
const entry * findEntry(const word &key) const
Locate literal dictionary entry, nullptr if not found.
const dictionary & dict() const noexcept
Return the parent dictionary context.
dynamicCodeContext()
Default construct.
A keyword and a list of tokens is an 'entry'.
void readEntry(T &val) const
Assign to T val, FatalIOError if the number of tokens is incorrect.
virtual label startLineNumber() const =0
Return line number of first token in dictionary.
static std::string::size_type length(const char *s)
Length of the character sequence (with nullptr protection).
A class for handling words, derived from Foam::string.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
void inplaceExpand(std::string &s, const HashTable< string > &mapping, const char sigil='$')
Inplace expand occurrences of variables according to the mapping. Does not use environment values.
void inplaceTrim(std::string &s)
Trim leading and trailing whitespace inplace.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a).