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.relativeName() <<
nl
96 <<
" found " << keyToken <<
nl
115 inpMode == inputMode::GLOBAL
121 if (
mode == inputMode::GLOBAL)
124 <<
"Cannot use 'GLOBAL' as an inputMode"
134 const bool valid = getKeyword(keyword, keyToken, is);
140 return parentDict.
add
157 <<
"Unexpected '}' while reading dictionary entry"
167 <<
"Unexpected EOF while reading dictionary entry"
177 <<
"Found " << keyToken
178 <<
" but expected " << char(endChar)
184 <<
"Found " << keyToken
185 <<
" but expected EOF, or perhaps a '}' char"
197 if (disableFunctionEntries)
199 return parentDict.
add
211 const word functionName(keyword.substr(1),
false);
228 string expanded = keyword.substr(2, keyword.size()-3);
236 keyword.std::string::replace(1, keyword.size()-1, expanded);
241 const word varName = keyword.substr(1);
250 const keyType newKeyword(finder.ptr()->stream());
252 return parentDict.
add
260 <<
"Attempt to use undefined variable " << varName
268 const bool mergeEntry =
270 mode == inputMode::MERGE
271 ||
mode == inputMode::OVERWRITE
289 <<
"Unexpected token encountered for "
290 << keyword <<
" - " << nextToken.
info()
297 !disableFunctionEntries
298 && (keyword.find(
'/') != string::npos)
310 bool mergeEntry =
false;
317 if (
mode == inputMode::PROTECT || keyword ==
"FoamFile")
339 if (
mode == inputMode::ERROR)
342 <<
"duplicate entry: " <<
key
348 if (
mode == inputMode::MERGE)
352 else if (
mode == inputMode::OVERWRITE)
357 finder.dict().clear();
366 return finder.context().add
374 return finder.context().add
385 string fullPath(keyword);
402 if (keyName.find_first_of(
"\"'") == 0)
407 string::validate<keyType>(keyName),
419 return subDictPtr->
add
427 return subDictPtr->
add
444 return parentDict.
add
452 return parentDict.
add
471 if (getKeyword(keyword, is))
A keyword and a list of tokens is an 'entry'.
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.
fileName path() const
Return directory path name (part before last /)
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
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).
const keyType & keyword() const noexcept
Return keyword.
Ostream & endl(Ostream &os)
Add newline and flush stream.
A token holds an item read from Istream.
inputMode
The input mode options.
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.
void inplaceExpand(std::string &s, const HashTable< string > &mapping, const char sigil='$')
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.
bool eof() const noexcept
True if end of input seen.
bool isPunctuation() const noexcept
Token is PUNCTUATION.
Dollar - start variable or expression.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
OBJstream os(runTime.globalPath()/outputName)
Hash - directive or start 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)
void reset(autoPtr< T > &&other) noexcept
Delete managed object and set to new given pointer.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
void putBack(const token &tok)
Put back a token. Only a single put back is permitted.
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.