39bool 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();
74bool 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
310 bool mergeEntry =
false;
315 const keyType key = finder.ref().keyword();
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))
bool fatalCheck(const char *operation) const
Check IOstream status for given operation.
bool eof() const noexcept
True if end of input seen.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
void putBack(const token &tok)
Put back a token. Only a single put back is permitted.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
void reset(autoPtr< T > &&other) noexcept
Delete managed object and set to new given pointer.
A keyword and a list of tokens is a 'dictionaryEntry'.
Read/write List of dictionaries.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
const_searcher csearchScoped(const word &keyword, enum keyType::option matchOpt) const
Search using scoping.
dictionary * makeScopedDict(const fileName &dictPath)
Locate existing or create sub-dictionary using slash-scoping.
const_searcher search(const word &keyword, enum keyType::option matchOpt=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.
const_searcher searchScoped(const word &keyword, enum keyType::option matchOpt) const
Search using dot or slash scoping.
A keyword and a list of tokens is an 'entry'.
inputMode
The input mode options.
const keyType & keyword() const noexcept
Return keyword.
static int disableFunctionEntries
Enable or disable use of function entries and variable expansions.
bool clean()
Cleanup filename (inplace)
word name() const
Return basename (part beyond last /), including its extension.
fileName path() const
Return directory path name (part before last /)
A functionEntry causes entries to be added/manipulated on the specified dictionary given an input str...
virtual bool execute()
Calculate the output fields.
virtual void validate()
Validate the turbulence fields after construction.
A class for handling keywords in dictionaries.
@ REGEX
Regular expression.
A keyword and a list of tokens comprise a primitiveEntry. A primitiveEntry can be read,...
virtual bool write(const bool valid=true) const
Write using setting from DB.
A token holds an item read from Istream.
bool isPunctuation() const noexcept
Token is PUNCTUATION.
@ BEGIN_BLOCK
Begin block [isseparator].
@ END_BLOCK
End block [isseparator].
@ HASH
Hash - directive or start verbatim string.
@ END_STATEMENT
End entry [isseparator].
@ BEGIN_LIST
Begin list [isseparator].
@ DOLLAR
Dollar - start variable or expression.
@ END_LIST
End list [isseparator].
bool isLabel() const noexcept
Token is LABEL.
InfoProxy< token > info() const
Return info proxy for printing token information to a stream.
A class for handling words, derived from Foam::string.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
OBJstream os(runTime.globalPath()/outputName)
void inplaceExpand(std::string &s, const HashTable< string > &mapping, const char sigil='$')
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)
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)