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);
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
const fileName & name() const noexcept
The dictionary name.
entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find for an entry (non-const access) with the given keyword.
Encapsulation of dynamic code dictionaries.
bool readIfPresent(const word &key, string &str, bool withLineNum=true)
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 readEntry(const word &key, string &str, bool mandatory=true, bool withLineNum=true)
static void inplaceExpand(string &str, const dictionary &dict)
Cleanup string and expand with dictionary parameters.
bool valid() const noexcept
Considered valid if not using dictionary::null as the context.
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
virtual label startLineNumber() const =0
Return line number of first token in dictionary.
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='$')
void inplaceTrim(std::string &s)
Trim leading and trailing whitespace inplace.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
propsDict readIfPresent("fields", acceptFields)