55 const auto len = code.length();
57 if (lineNum > 0 && len && !file.empty())
59 code =
"#line " +
Foam::name(lineNum) +
" \"" + file +
"\"\n" + code;
61 return (code.length() - len);
72 const dictionary&
dict 75 return addLineDirective(code, lineNum,
dict.
name());
118 sha1_.append(
"<" +
key +
">");
128 <<
"Entry '" <<
key <<
"' not found in dictionary " 160 return readEntry(
key, str,
false, withLineNum);
166 dict_ = std::cref<dictionary>(
dict);
void readEntry(T &val) const
Assign to T val, FatalIOError if the number of tokens is incorrect.
dynamicCodeContext()
Default construct.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void setCodeContext(const dictionary &dict)
Set code context from a dictionary.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
constexpr char nl
The newline '\n' character (0x0a)
virtual label startLineNumber() const =0
Return line number of first token in dictionary.
void inplaceTrim(std::string &s)
Trim leading and trailing whitespace inplace.
const fileName & name() const noexcept
The dictionary name.
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.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
A class for handling words, derived from Foam::string.
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
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...
static unsigned addLineDirective(string &code, label lineNum, const string &file)
Prefix a #line directive to code.
Encapsulation of dynamic code dictionaries.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
bool valid() const noexcept
Considered valid if not using dictionary::null as the context.
meshDefDict readIfPresent("polyMeshPatches", polyPatchNames)
const entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
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.
A keyword and a list of tokens is an 'entry'.
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...
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...