A keyword and a list of tokens is an 'entry'. More...
Public Types | |
enum | inputMode { MERGE, OVERWRITE, PROTECT, WARN, ERROR, GLOBAL } |
The input mode options. More... | |
Public Member Functions | |
entry (const keyType &keyword) | |
Construct from keyword. More... | |
entry (const entry &e) | |
Construct as copy. More... | |
virtual autoPtr< entry > | clone (const dictionary &parentDict) const =0 |
Construct on freestore as copy with reference to the. More... | |
virtual autoPtr< entry > | clone () const |
Construct on freestore as copy. More... | |
virtual | ~entry ()=default |
Destructor. More... | |
const keyType & | keyword () const noexcept |
Return keyword. More... | |
keyType & | keyword () noexcept |
Return non-const access to keyword. More... | |
virtual const fileName & | name () const =0 |
Return the entry name. More... | |
virtual fileName & | name ()=0 |
Return the entry name for modification. More... | |
virtual fileName | relativeName () const =0 |
Return the entry name relative to the current case. More... | |
virtual label | startLineNumber () const =0 |
Return line number of first token in dictionary. More... | |
virtual label | endLineNumber () const =0 |
Return line number of last token in dictionary. More... | |
virtual bool | isStream () const noexcept |
True if this entry is a stream. More... | |
virtual ITstream * | streamPtr () const noexcept |
Return pointer to token stream, if it is a primitive entry, otherwise return nullptr. More... | |
virtual ITstream & | stream () const =0 |
Return token stream, if entry is a primitive entry. More... | |
virtual bool | isDict () const noexcept |
True if this entry is a dictionary. More... | |
virtual const dictionary * | dictPtr () const noexcept |
Return pointer to dictionary, if entry is a dictionary, otherwise return nullptr. More... | |
virtual dictionary * | dictPtr () noexcept |
Return non-const pointer to dictionary, if entry is a dictionary, otherwise return nullptr. More... | |
virtual const dictionary & | dict () const =0 |
Return dictionary, if entry is a dictionary, otherwise Fatal. More... | |
virtual dictionary & | dict ()=0 |
Return non-const access to dictionary, if entry is a dictionary, otherwise Fatal. More... | |
void | checkITstream (const ITstream &is) const |
Check after reading if the input token stream has unconsumed tokens remaining or if there were no tokens in the first place. More... | |
template<class T > | |
T | get () const |
Get a T from the stream, FatalIOError if the number of tokens is incorrect. More... | |
template<class T > | |
void | readEntry (T &val) const |
Assign to T val, FatalIOError if the number of tokens is incorrect. More... | |
template<class T , class Predicate > | |
T | getCheck (const Predicate &pred) const |
Get a T from the stream, FatalIOError if the number of tokens is incorrect. More... | |
template<class T , class Predicate > | |
void | readCheck (T &val, const Predicate &pred) const |
Assign to T val, FatalIOError if the number of tokens is incorrect. More... | |
virtual void | write (Ostream &os) const =0 |
Write. More... | |
void | operator= (const entry &e) |
bool | operator== (const entry &e) const |
bool | operator!= (const entry &e) const |
Static Public Member Functions | |
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. More... | |
static autoPtr< entry > | New (Istream &is) |
Construct an entry from Istream. More... | |
static void | resetInputMode () |
Reset the globalInputMode to merge. More... | |
Static Public Attributes | |
static int | disableFunctionEntries |
Enable or disable use of function entries and variable expansions. More... | |
static inputMode | globalInputMode = inputMode::MERGE |
The current global input-mode. More... | |
Static Protected Member Functions | |
static void | reportReadWarning (const IOstream &, const std::string &) |
Report a read warning (on std::cerr) More... | |
Friends | |
Ostream & | operator<< (Ostream &os, const entry &e) |
A keyword and a list of tokens is an 'entry'.
An entry can be read, written and printed, and the types and values of its tokens analysed. An entry is a high-level building block for data description. It is a front-end for the token parser. A list of entries can be used as a set of keyword syntax elements, for example.
|
strong |
The input mode options.
Enumerator | |
---|---|
MERGE | Merge sub-dictionaries when possible. |
OVERWRITE | Keep last entry. Silently remove previous ones. |
PROTECT | Keep initial entry. Silently ignore subsequent ones. |
WARN | Keep initial entry. Warn about subsequent ones. |
ERROR | FatalError for duplicate entries. |
GLOBAL | Use global value from globalInputMode variable. |
|
virtualdefault |
Destructor.
|
staticprotected |
Report a read warning (on std::cerr)
Definition at line 41 of file entry.C.
References Foam::endl(), IOstream::lineNumber(), and IOstream::relativeName().
|
pure virtual |
Construct on freestore as copy with reference to the.
dictionary the copy belongs to
Implemented in primitiveEntry, formattingEntry, dictionaryEntry, and dictionaryListEntry.
|
virtual |
Construct on freestore as copy.
Note: the parent directory is set to dictionary::null
Definition at line 76 of file entry.C.
References dictionary::null.
|
static |
Construct from an Istream and insert into the dictionary.
parentDict | dictionary to insert into |
is | the input stream |
inpMode | the input mode. The default is to use the currently active globalInputMode |
endChar | the expected end character (eg, a closing brace). The endChar is 0 if no expectations are asserted. |
Definition at line 98 of file entryIO.C.
References dictionary::add(), token::BEGIN_BLOCK, token::BEGIN_LIST, fileName::clean(), string::contains(), dictionary::csearchScoped(), entry::disableFunctionEntries, token::DOLLAR, token::END_BLOCK, token::END_LIST, IOstream::eof(), functionEntry::execute(), Foam::exit(), IOstream::fatalCheck(), Foam::FatalIOError, FatalIOErrorInFunction, FUNCTION_NAME, token::HASH, token::info(), Foam::stringOps::inplaceExpand(), token::isLabel(), token::isPunctuation(), Foam::glTF::key(), keyType::LITERAL, dictionary::makeScopedDict(), Foam::mode(), fileName::name(), fileName::path(), Istream::putBack(), keyType::REGEX, keyType::REGEX_RECURSIVE, dictionary::search(), dictionary::searchScoped(), dictionary::substituteScopedKeyword(), and word::validate().
Referenced by ifeqEntry::evaluate(), dictionary::read(), and functionObjectList::readFunctionObject().
|
static |
Construct an entry from Istream.
The expected input comprises a keyword followed by a dictionaryEntry or a primitiveEntry.
Example input
* key1 { ... } // dictionary input * key2 ... ; // primitive input *
Definition at line 456 of file entryIO.C.
References token::BEGIN_BLOCK, IOstream::fatalCheck(), FUNCTION_NAME, dictionary::null, Istream::putBack(), and autoPtr< T >::reset().
|
static |
Reset the globalInputMode to merge.
Definition at line 54 of file entry.C.
References entry::globalInputMode, and entry::MERGE.
Referenced by dictionary::dictionary(), and Foam::operator>>().
|
inlinenoexcept |
Return keyword.
Definition at line 231 of file entry.H.
Referenced by dictionary::add(), cellModel::cellModel(), solutionControl::maxTypeResidual(), PatchFunction1< Foam::vector >::New(), Function1< Foam::vector >::New(), phase::iNew::operator()(), phaseModel::iNew::operator()(), sizeGroup::iNew::operator()(), Foam::operator>>(), Foam::functionObjects::operator>>(), genericPatchFieldBase::processEntry(), GeometricBoundaryField< Foam::vector, Foam::fvPatchField, Foam::volMesh >::readField(), refinementSurfaces::refinementSurfaces(), dictionary::set(), shellSurfaces::shellSurfaces(), dictionaryEntry::stream(), Foam::blockMeshTools::write(), dictionaryListEntry::write(), dictionaryEntry::write(), and genericPatchFieldBase::writeGeneric().
|
inlinenoexcept |
|
pure virtual |
Return the entry name.
Implemented in primitiveEntry, and dictionaryEntry.
Referenced by dictionary::add().
|
pure virtual |
Return the entry name for modification.
Implemented in primitiveEntry, and dictionaryEntry.
|
pure virtual |
Return the entry name relative to the current case.
Implemented in primitiveEntry, and dictionaryEntry.
|
pure virtual |
Return line number of first token in dictionary.
Implemented in primitiveEntry, and dictionaryEntry.
Referenced by dynamicCodeContext::readEntry().
|
pure virtual |
Return line number of last token in dictionary.
Implemented in primitiveEntry, and dictionaryEntry.
|
inlinevirtualnoexcept |
True if this entry is a stream.
Definition at line 267 of file entry.H.
References entry::streamPtr().
Referenced by Constant< Type >::Constant(), exprResultDelayed::exprResultDelayed(), Polynomial< Type >::Polynomial(), genericPatchFieldBase::processEntry(), and Table< Type >::Table().
|
inlinevirtualnoexcept |
Return pointer to token stream, if it is a primitive entry, otherwise return nullptr.
Reimplemented in primitiveEntry.
Definition at line 273 of file entry.H.
Referenced by entry::isStream().
|
pure virtual |
Return token stream, if entry is a primitive entry.
Implemented in primitiveEntry, and dictionaryEntry.
Referenced by Constant< Type >::Constant(), Foam::entryToString(), exprResultDelayed::exprResultDelayed(), dictionary::getCheckOrAdd(), dictionary::getCheckOrDefault(), Foam::exprTools::getList(), dictionary::getOrAdd(), dictionary::getOrDefault(), dictionary::getOrDefaultCompat(), expressionEntry::inplaceExpand(), meshRefinement::lookup(), solutionControl::maxTypeResidual(), fvGeometryScheme::New(), Polynomial< Type >::Polynomial(), genericPatchFieldBase::processEntry(), Foam::blockMeshTools::read(), entry::readCheck(), dictionary::readCheck(), dictionary::readCompat(), fvExprDriver::readDict(), entry::readEntry(), dictionary::readEntry(), Foam::readScaling(), Table< Type >::Table(), and Foam::writeEntryIfPresent().
|
inlinevirtualnoexcept |
True if this entry is a dictionary.
Definition at line 284 of file entry.H.
References entry::dictPtr().
Referenced by dictionary::add(), dictionary::cfindScopedDict(), Foam::entryToString(), GAMGSolver::GAMGSolver(), Foam::getVariableOrDie(), dictionary::makeScopedDict(), functionObjectList::read(), and Foam::writeEntryIfPresent().
|
inlinevirtualnoexcept |
Return pointer to dictionary, if entry is a dictionary, otherwise return nullptr.
Reimplemented in dictionaryEntry.
Definition at line 290 of file entry.H.
Referenced by dictionary::cfindScopedDict(), entry::isDict(), dictionary::makeScopedDict(), and GeometricBoundaryField< Foam::vector, Foam::fvPatchField, Foam::volMesh >::readField().
|
inlinevirtualnoexcept |
Return non-const pointer to dictionary, if entry is a dictionary, otherwise return nullptr.
Reimplemented in dictionaryEntry.
|
pure virtual |
Return dictionary, if entry is a dictionary, otherwise Fatal.
Implemented in primitiveEntry, and dictionaryEntry.
Referenced by dictionary::add(), Foam::entryToString(), GAMGSolver::GAMGSolver(), functionObjectList::read(), sampledSurfaces::read(), refinementSurfaces::refinementSurfaces(), shellSurfaces::shellSurfaces(), and Foam::writeEntryIfPresent().
|
pure virtual |
Return non-const access to dictionary, if entry is a dictionary, otherwise Fatal.
Implemented in primitiveEntry, and dictionaryEntry.
void checkITstream | ( | const ITstream & | is | ) | const |
Check after reading if the input token stream has unconsumed tokens remaining or if there were no tokens in the first place.
Emits FatalIOError
Definition at line 103 of file entry.C.
References JobInfo::constructed, Foam::endl(), Foam::exit(), Foam::FatalIOError, IOstream::lineNumber(), Foam::nl, ITstream::nRemainingTokens(), UList< T >::size(), and UList< T >::writeList().
Referenced by entry::readCheck(), entry::readEntry(), and Foam::readScaling().
|
inline |
Get a T from the stream, FatalIOError if the number of tokens is incorrect.
Definition at line 326 of file entry.H.
References Foam::T().
Referenced by Foam::getOrAdd(), Enum< preconditioners >::getOrDefault(), and Enum< preconditioners >::readEntry().
|
inline |
Assign to T val, FatalIOError if the number of tokens is incorrect.
val | the value to read into |
Definition at line 341 of file entry.H.
References entry::checkITstream(), and entry::stream().
Referenced by dynamicCodeContext::readEntry().
|
inline |
|
inline |
Assign to T val, FatalIOError if the number of tokens is incorrect.
val | the value to read into |
pred | the value check predicate |
Definition at line 373 of file entry.H.
References entry::checkITstream(), and entry::stream().
|
pure virtual |
Write.
Implemented in primitiveEntry, dictionaryEntry, functionEntry, formattingEntry, and dictionaryListEntry.
void operator= | ( | const entry & | e | ) |
Definition at line 179 of file entry.C.
References Foam::constant::electromagnetic::e.
bool operator== | ( | const entry & | e | ) | const |
Definition at line 190 of file entry.C.
References Foam::constant::electromagnetic::e, Foam::MatrixTools::equal(), and OCharStream::view().
bool operator!= | ( | const entry & | e | ) | const |
Definition at line 222 of file entry.C.
References Foam::constant::electromagnetic::e, and Foam::operator==().
|
static |
Enable or disable use of function entries and variable expansions.
Definition at line 139 of file entry.H.
Referenced by entry::New().
|
static |
The current global input-mode.
Definition at line 144 of file entry.H.
Referenced by entry::resetInputMode().