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 142 new dictionaryListEntry(parentDict, is),
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 254 new dictionaryEntry(newKeyword, parentDict, is),
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.contains(
'/')
310 bool mergeEntry =
false;
315 const keyType
key = finder.ref().keyword();
317 if (
mode == inputMode::PROTECT || keyword ==
"FoamFile")
328 dictionaryEntry dummy(
"dummy", finder.context(), is);
332 primitiveEntry dummy(
"dummy", finder.context(), is);
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
368 new dictionaryEntry(
key, finder.context(), is),
374 return finder.context().add
376 new primitiveEntry(
key, finder.context(), is),
385 string fullPath(keyword);
390 dictionary* subDictPtr =
402 if (keyName.find_first_of(
"\"'") == 0)
407 string::validate<keyType>(keyName),
419 return subDictPtr->add
421 new dictionaryEntry(
key, *subDictPtr, is),
427 return subDictPtr->add
429 new primitiveEntry(
key, *subDictPtr, is),
444 return parentDict.
add 446 new dictionaryEntry(keyword, parentDict, is),
452 return parentDict.
add 454 new primitiveEntry(keyword, parentDict, is),
471 if (getKeyword(keyword, is))
475 is.putBack(nextToken);
484 ptr.reset(
new primitiveEntry(keyword, is));
Begin block [isseparator].
static word validate(const std::string &s, const bool prefix=false)
Construct validated word (no invalid characters).
static bool execute(const word &functionName, dictionary &parentDict, Istream &is)
Execute the functionEntry in a sub-dict context.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
bool clean()
Cleanup filename (inplace)
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
constexpr char nl
The newline '\n' character (0x0a)
bool substituteScopedKeyword(const word &keyword, bool mergeEntry=false)
Substitute the given scoped keyword (which is prefixed by '$')
Ostream & endl(Ostream &os)
Add newline and flush stream.
Begin list [isseparator].
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
inputMode
The input mode options.
Dollar - start variable or expression.
const_searcher search(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search dictionary for given keyword.
void putBack(const token &tok)
Put back a token. Only a single put back is permitted.
static int disableFunctionEntries
Enable or disable use of function entries and variable expansions.
const dimensionedScalar e
Elementary charge.
const keyType & keyword() const noexcept
Return keyword.
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.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
void inplaceExpand(std::string &s, const HashTable< string > &mapping, const char sigil='$')
Inplace expand occurrences of variables according to the mapping. Does not use environment values...
OBJstream os(runTime.globalPath()/outputName)
const_searcher csearchScoped(const word &keyword, enum keyType::option matchOpt) const
Search using scoping.
const_searcher searchScoped(const word &keyword, enum keyType::option matchOpt) const
Search using dot or slash scoping.
dictionary * makeScopedDict(const fileName &dictPath)
Locate existing or create sub-dictionary using slash-scoping.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
bool fatalCheck(const char *operation) const
Check IOstream status for given operation.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
fileName path() const
Return directory path name (part before last /)
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
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.
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
bool eof() const noexcept
True if end of input seen.
Hash - directive or start verbatim string.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...