Go to the documentation of this file.
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);
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);
170 readIfPresent(
"codeOptions", codeOptions_,
false);
173 readIfPresent(
"codeLibs", codeLibs_,
false);
175 readIfPresent(
"codeInclude", codeInclude_);
176 readIfPresent(
"localCode", localCode_);
177 readIfPresent(
"code", code_);
A keyword and a list of tokens is an 'entry'.
A class for handling words, derived from Foam::string.
bool readEntry(const word &key, string &str, bool mandatory=true, bool withLineNum=true)
void inplaceTrim(std::string &s)
Trim leading and trailing whitespace inplace.
bool valid() const noexcept
Considered valid if not using dictionary::null as the context.
Encapsulation of dynamic code dictionaries.
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
bool readIfPresent(const word &key, string &str, bool withLineNum=true)
const dictionary & dict() const noexcept
Return the parent dictionary context.
dynamicCodeContext()
Default construct.
const fileName & name() const noexcept
The dictionary name.
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='$')
const entry * findEntry(const word &key) const
Locate literal dictionary entry, nullptr if not found.
virtual label startLineNumber() const =0
Return line number of first token in dictionary.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
void setCodeContext(const dictionary &dict)
Set code context from a dictionary.
errorManipArg< error, int > exit(error &err, const int errNo=1)
static void inplaceExpand(string &str, const dictionary &dict)
Cleanup string and expand with dictionary parameters.
static unsigned addLineDirective(string &code, label lineNum, const string &file)
Prefix a #line directive to code.
entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find for an entry (non-const access) with the given keyword.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
void readEntry(T &val) const
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.