Go to the documentation of this file.
39 bool Foam::entry::getKeyword(keyType& keyword, token& keyToken, Istream& is)
46 is.read(keyToken).bad()
57 if (keyToken.isWord())
63 if (keyToken.isString())
66 keyword = keyToken.stringToken();
74 bool Foam::entry::getKeyword(keyType& keyword, Istream& is)
77 const bool valid = getKeyword(keyword, keyToken, is);
92 <<
"--> FOAM Warning :" <<
nl
94 <<
" in file " << __FILE__ <<
" at line " << __LINE__ <<
nl
95 <<
" Reading " << is.name() <<
nl
96 <<
" found " << keyToken <<
nl
114 inpMode == inputMode::GLOBAL
120 if (
mode == inputMode::GLOBAL)
123 <<
"Cannot use 'GLOBAL' as an inputMode"
133 const bool valid = getKeyword(keyword, keyToken, is);
143 return parentDict.
add
160 <<
"Unexpected '}' while reading dictionary entry"
170 <<
"Unexpected EOF while reading dictionary entry"
180 <<
"Found " << keyToken
181 <<
" but expected " << char(endChar)
187 <<
"Found " << keyToken
188 <<
" but expected EOF, or perhaps a '}' char"
200 if (disableFunctionEntries)
202 return parentDict.
add
214 const word functionName(keyword.substr(1),
false);
231 string expanded = keyword.substr(2, keyword.size()-3);
239 keyword.std::string::replace(1, keyword.size()-1, expanded);
244 const word varName = keyword.substr(1);
253 const keyType newKeyword(finder.ptr()->stream());
255 return parentDict.
add
263 <<
"Attempt to use undefined variable " << varName
271 const bool mergeEntry =
273 mode == inputMode::MERGE
274 ||
mode == inputMode::OVERWRITE
292 <<
"Unexpected token encountered for "
293 << keyword <<
" - " << nextToken.
info()
300 !disableFunctionEntries
301 && (keyword.find(
'/') != string::npos)
313 bool mergeEntry =
false;
318 const keyType key = finder.ref().keyword();
320 if (
mode == inputMode::PROTECT || keyword ==
"FoamFile")
342 if (
mode == inputMode::ERROR)
345 <<
"duplicate entry: " << key
351 if (
mode == inputMode::MERGE)
355 else if (
mode == inputMode::OVERWRITE)
360 finder.dict().clear();
369 return finder.context().add
377 return finder.context().add
388 string fullPath(keyword);
405 if (keyName.find_first_of(
"\"'") == 0)
410 string::validate<keyType>(keyName),
422 return subDictPtr->
add
430 return subDictPtr->
add
447 return parentDict.
add
455 return parentDict.
add
474 if (getKeyword(keyword, is))
A keyword and a list of tokens is an 'entry'.
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
A keyword and a list of tokens is a 'dictionaryEntry'.
static bool New(dictionary &parentDict, Istream &is, const inputMode inpMode=inputMode::GLOBAL, const int endChar=0)
Construct from an Istream and insert into the dictionary.
A keyword and a list of tokens comprise a primitiveEntry. A primitiveEntry can be read,...
bool isLabel() const noexcept
Token is LABEL.
A class for handling words, derived from Foam::string.
const keyType & keyword() const
Return keyword.
bool eof() const
Return true if end of input seen.
fileName path() const
Return directory path name (part before last /)
bool fatalCheck(const char *operation) const
Check IOstream status for given operation.
const_searcher searchScoped(const word &keyword, enum keyType::option) const
Search using dot or slash scoping.
static word validate(const std::string &s, const bool prefix=false)
Construct validated word (no invalid characters).
Ostream & endl(Ostream &os)
Add newline and flush stream.
A token holds an item read from Istream.
inputMode
The input mode options.
punctuationToken pToken() const
Return punctuation character.
word name() const
Return basename (part beyond last /), including its extension.
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
A class for handling keywords in dictionaries.
InfoProxy< token > info() const
Return info proxy for printing token information to a stream.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
const_searcher csearchScoped(const word &keyword, enum keyType::option) const
Search using scoping.
dictionary * makeScopedDict(const fileName &dictPath)
Locate existing or create sub-dictionary using slash-scoping.
void inplaceExpand(std::string &s, const HashTable< string, word, string::hash > &mapping, const char sigil='$')
bool isPunctuation() const noexcept
Token is PUNCTUATION.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Hash - directive or verbatim string.
static int disableFunctionEntries
Enable or disable use of function entries and variable expansions.
Begin block [isseparator].
A functionEntry causes entries to be added/manipulated on the specified dictionary given an input str...
errorManipArg< error, int > exit(error &err, const int errNo=1)
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
void putBack(const token &tok)
Put back token.
const dimensionedScalar e
Elementary charge.
const_searcher search(const word &keyword, enum keyType::option=keyType::REGEX) const
Search dictionary for given keyword.
bool substituteScopedKeyword(const word &keyword, bool mergeEntry=false)
Substitute the given scoped keyword (which is prefixed by '$')
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
bool clean()
Cleanup filename inplace.
Read/write List of dictionaries.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Begin list [isseparator].
static bool execute(const word &functionName, dictionary &parentDict, Istream &is)
Execute the functionEntry in a sub-dict context.