Loading...
Searching...
No Matches
entry Class Referenceabstract

A keyword and a list of tokens is an 'entry'. More...

#include <entry.H>

Inheritance diagram for entry:
Collaboration diagram for entry:

Public Types

enum class  inputMode {
  MERGE , OVERWRITE , PROTECT , WARN ,
  ERROR , GLOBAL
}
 The input mode options. More...

Public Member Functions

 entry (const keyType &keyword)
 Construct from keyword.
 entry (const entry &e)
 Construct as copy.
virtual autoPtr< entryclone (const dictionary &parentDict) const =0
 Construct on freestore as copy with reference to the.
virtual autoPtr< entryclone () const
 Construct on freestore as copy.
virtual ~entry ()=default
 Destructor.
const keyTypekeyword () const noexcept
 Return keyword.
keyTypekeyword () noexcept
 Return non-const access to keyword.
virtual const fileNamename () const =0
 Return the entry name.
virtual fileNamename ()=0
 Return the entry name for modification.
virtual fileName relativeName () const =0
 Return the entry name relative to the current case.
virtual label startLineNumber () const =0
 Return line number of first token in dictionary.
virtual label endLineNumber () const =0
 Return line number of last token in dictionary.
virtual bool isStream () const noexcept
 True if this entry is a stream.
virtual ITstreamstreamPtr () const noexcept
 Return pointer to token stream, if it is a primitive entry, otherwise return nullptr.
virtual ITstreamstream () const =0
 Return token stream, if entry is a primitive entry.
virtual bool isDict () const noexcept
 True if this entry is a dictionary.
virtual const dictionarydictPtr () const noexcept
 Return pointer to dictionary, if entry is a dictionary, otherwise return nullptr.
virtual dictionarydictPtr () noexcept
 Return non-const pointer to dictionary, if entry is a dictionary, otherwise return nullptr.
virtual const dictionarydict () const =0
 Return dictionary, if entry is a dictionary, otherwise Fatal.
virtual dictionarydict ()=0
 Return non-const access to dictionary, if entry is a dictionary, otherwise Fatal.
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.
template<class T>
T get () const
 Get a T from the stream, FatalIOError if the number of tokens is incorrect.
template<class T>
void readEntry (T &val) const
 Assign to T val, FatalIOError if the number of tokens is incorrect.
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.
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.
virtual void write (Ostream &os) const =0
 Write.
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.
static autoPtr< entryNew (Istream &is)
 Construct an entry from Istream.
static void resetInputMode ()
 Reset the globalInputMode to merge.

Static Public Attributes

static int disableFunctionEntries
 Enable or disable use of function entries and variable expansions.
static inputMode globalInputMode = inputMode::MERGE
 The current global input-mode.

Static Protected Member Functions

static void reportReadWarning (const IOstream &, const std::string &)
 Report a read warning (on std::cerr).

Friends

Ostreamoperator<< (Ostream &os, const entry &e)

Additional Inherited Members

Detailed Description

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.

Source files

Definition at line 63 of file entry.H.

Member Enumeration Documentation

◆ inputMode

enum class inputMode
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.

Definition at line 74 of file entry.H.

Constructor & Destructor Documentation

◆ entry() [1/2]

◆ entry() [2/2]

entry ( const entry & e)

Construct as copy.

Definition at line 69 of file entry.C.

References e, entry(), and DLListBase::link::link().

Here is the call graph for this function:

◆ ~entry()

virtual ~entry ( )
virtualdefault

Destructor.

Member Function Documentation

◆ reportReadWarning()

void reportReadWarning ( const IOstream & is,
const std::string & msg )
staticprotected

Report a read warning (on std::cerr).

Definition at line 40 of file entry.C.

References IOstream::lineNumber(), and IOstream::relativeName().

Referenced by formattingEntry::primitiveEntry().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clone() [1/2]

virtual autoPtr< entry > clone ( const dictionary & parentDict) const
pure virtual

Construct on freestore as copy with reference to the.

dictionary the copy belongs to

Implemented in dictionaryEntry, dictionaryListEntry, formattingEntry, and primitiveEntry.

References GLOBAL.

Referenced by clone().

Here is the caller graph for this function:

◆ clone() [2/2]

Foam::autoPtr< Foam::entry > clone ( ) const
virtual

Construct on freestore as copy.

Note: the parent directory is set to dictionary::null

Definition at line 76 of file entry.C.

References clone(), and dictionary::null.

Here is the call graph for this function:

◆ New() [1/2]

bool New ( dictionary & parentDict,
Istream & is,
const inputMode inpMode = inputMode::GLOBAL,
const int endChar = 0 )
static

Construct from an Istream and insert into the dictionary.

Parameters
parentDictdictionary to insert into
isthe input stream
inpModethe input mode. The default is to use the currently active globalInputMode
endCharthe expected end character (eg, a closing brace). The endChar is 0 if no expectations are asserted.

Definition at line 97 of file entryIO.C.

References dictionary::add(), token::BEGIN_BLOCK, token::BEGIN_LIST, fileName::clean(), dictionary::csearchScoped(), disableFunctionEntries, token::DOLLAR, token::END_BLOCK, token::END_LIST, IOstream::eof(), ERROR, functionEntry::execute(), Foam::exit(), IOstream::fatalCheck(), Foam::FatalIOError, FatalIOErrorInFunction, FUNCTION_NAME, GLOBAL, globalInputMode, token::HASH, token::info(), Foam::stringOps::inplaceExpand(), token::isLabel(), token::isPunctuation(), keyword(), keyType::LITERAL, dictionary::makeScopedDict(), MERGE, Foam::mode(), fileName::name(), OVERWRITE, fileName::path(), PROTECT, Istream::putBack(), keyType::REGEX, keyType::REGEX_RECURSIVE, dictionary::search(), dictionary::searchScoped(), dictionary::substituteScopedKeyword(), string::validate(), and word::validate().

Referenced by dictionaryListEntry::dictionaryListEntry(), ifeqEntry::evaluate(), inputModeDefault::execute(), inputModeError::execute(), inputModeMerge::execute(), inputModeOverwrite::execute(), inputModeWarn::execute(), dictionary::read(), and functionObjectList::readFunctionObject().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ New() [2/2]

Foam::autoPtr< Foam::entry > New ( Istream & is)
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
* 
Returns
The entry read, or nullptr on error.

Definition at line 456 of file entryIO.C.

References token::BEGIN_BLOCK, IOstream::fatalCheck(), FUNCTION_NAME, keyword(), dictionary::null, Istream::putBack(), and autoPtr< T >::reset().

Here is the call graph for this function:

◆ resetInputMode()

void resetInputMode ( )
static

Reset the globalInputMode to merge.

Definition at line 54 of file entry.C.

References globalInputMode, and MERGE.

Referenced by dictionary::dictionary(), inputMode::execute(), and Foam::operator>>().

Here is the caller graph for this function:

◆ keyword() [1/2]

◆ keyword() [2/2]

keyType & keyword ( )
inlinenoexcept

Return non-const access to keyword.

Definition at line 236 of file entry.H.

References Foam::noexcept.

◆ name() [1/2]

virtual const fileName & name ( ) const
pure virtual

Return the entry name.

Implemented in dictionaryEntry, and primitiveEntry.

Referenced by dictionary::add().

Here is the caller graph for this function:

◆ name() [2/2]

virtual fileName & name ( )
pure virtual

Return the entry name for modification.

Implemented in dictionaryEntry, and primitiveEntry.

◆ relativeName()

virtual fileName relativeName ( ) const
pure virtual

Return the entry name relative to the current case.

Implemented in dictionaryEntry, and primitiveEntry.

Referenced by checkITstream().

Here is the caller graph for this function:

◆ startLineNumber()

virtual label startLineNumber ( ) const
pure virtual

Return line number of first token in dictionary.

Implemented in dictionaryEntry, and primitiveEntry.

Referenced by dynamicCodeContext::readEntry().

Here is the caller graph for this function:

◆ endLineNumber()

virtual label endLineNumber ( ) const
pure virtual

Return line number of last token in dictionary.

Implemented in dictionaryEntry, and primitiveEntry.

◆ isStream()

virtual bool isStream ( ) const
inlinevirtualnoexcept

True if this entry is a stream.

Definition at line 267 of file entry.H.

References Foam::noexcept, and streamPtr().

Referenced by Constant< Type >::Constant(), exprResultDelayed::exprResultDelayed(), Polynomial< Type >::Polynomial(), genericPatchFieldBase::processEntry(), and Table< Type >::Table().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ streamPtr()

virtual ITstream * streamPtr ( ) const
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.

References Foam::noexcept.

Referenced by isStream().

Here is the caller graph for this function:

◆ stream()

◆ isDict()

virtual bool isDict ( ) const
inlinevirtualnoexcept

True if this entry is a dictionary.

Definition at line 284 of file entry.H.

References dictPtr(), and Foam::noexcept.

Referenced by dictionary::add(), dictionary::cfindScopedDict(), GAMGSolver::GAMGSolver(), Foam::getVariableOrDie(), dictionary::makeScopedDict(), dictionaryValue::processDict(), functionObjectList::read(), and Foam::writeEntryIfPresent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dictPtr() [1/2]

virtual const dictionary * dictPtr ( ) const
inlinevirtualnoexcept

Return pointer to dictionary, if entry is a dictionary, otherwise return nullptr.

Reimplemented in dictionaryEntry.

Definition at line 290 of file entry.H.

References Foam::noexcept.

Referenced by dictionary::cfindScopedDict(), GeometricBoundaryField< scalar, Foam::fvPatchField, Foam::volMesh >::evaluate(), isDict(), and dictionary::makeScopedDict().

Here is the caller graph for this function:

◆ dictPtr() [2/2]

virtual dictionary * dictPtr ( )
inlinevirtualnoexcept

Return non-const pointer to dictionary, if entry is a dictionary, otherwise return nullptr.

Reimplemented in dictionaryEntry.

Definition at line 296 of file entry.H.

References Foam::noexcept.

◆ dict() [1/2]

virtual const dictionary & dict ( ) const
pure virtual

Return dictionary, if entry is a dictionary, otherwise Fatal.

Implemented in dictionaryEntry, and primitiveEntry.

Referenced by dictionary::add(), GAMGSolver::GAMGSolver(), dictionaryValue::processDict(), functionObjectList::read(), sampledSurfaces::read(), refinementSurfaces::refinementSurfaces(), and Foam::writeEntryIfPresent().

Here is the caller graph for this function:

◆ dict() [2/2]

virtual dictionary & dict ( )
pure virtual

Return non-const access to dictionary, if entry is a dictionary, otherwise Fatal.

Implemented in dictionaryEntry, and primitiveEntry.

◆ checkITstream()

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::exit(), Foam::FatalIOError, keyword(), IOstream::lineNumber(), Foam::nl, ITstream::nRemainingTokens(), relativeName(), UList< T >::size(), and UList< T >::writeList().

Referenced by readCheck(), readEntry(), and Foam::readScaling().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get()

template<class T>
T get ( ) const
inline

Get a T from the stream, FatalIOError if the number of tokens is incorrect.

Definition at line 326 of file entry.H.

References readEntry(), and Foam::T().

Referenced by Enum< injectionMethod >::get(), Foam::getOrAdd(), and Enum< injectionMethod >::getOrDefault().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readEntry()

template<class T>
void readEntry ( T & val) const
inline

Assign to T val, FatalIOError if the number of tokens is incorrect.

Parameters
valthe value to read into

Definition at line 341 of file entry.H.

References checkITstream(), stream(), and Foam::T().

Referenced by get(), and dynamicCodeContext::readEntry().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCheck()

template<class T, class Predicate>
T getCheck ( const Predicate & pred) const
inline

Get a T from the stream, FatalIOError if the number of tokens is incorrect.

Parameters
predthe value check predicate

Definition at line 357 of file entry.H.

References readCheck(), and Foam::T().

Here is the call graph for this function:

◆ readCheck()

template<class T, class Predicate>
void readCheck ( T & val,
const Predicate & pred ) const
inline

Assign to T val, FatalIOError if the number of tokens is incorrect.

Parameters
valthe value to read into
predthe value check predicate

Definition at line 373 of file entry.H.

References checkITstream(), stream(), and Foam::T().

Referenced by getCheck().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write()

virtual void write ( Ostream & os) const
pure virtual

Write.

Implemented in dictionaryEntry, dictionaryListEntry, formattingEntry, functionEntry, and primitiveEntry.

References e, entry(), and os().

Here is the call graph for this function:

◆ operator=()

void operator= ( const entry & e)

Definition at line 179 of file entry.C.

References e, and entry().

Here is the call graph for this function:

◆ operator==()

bool operator== ( const entry & e) const

Definition at line 190 of file entry.C.

References e, entry(), and OCharStream::view().

Here is the call graph for this function:

◆ operator!=()

bool operator!= ( const entry & e) const

Definition at line 222 of file entry.C.

References e, entry(), and Foam::operator==().

Here is the call graph for this function:

◆ operator<<

Ostream & operator<< ( Ostream & os,
const entry & e )
friend

References e, entry(), and os().

Member Data Documentation

◆ disableFunctionEntries

int disableFunctionEntries
static

Enable or disable use of function entries and variable expansions.

Definition at line 139 of file entry.H.

Referenced by New().

◆ globalInputMode

Foam::entry::inputMode globalInputMode = inputMode::MERGE
static

The current global input-mode.

Definition at line 144 of file entry.H.

Referenced by inputMode::execute(), New(), and resetInputMode().


The documentation for this class was generated from the following files:
  • src/OpenFOAM/db/dictionary/entry/entry.H
  • src/OpenFOAM/db/dictionary/entry/entry.C
  • src/OpenFOAM/db/dictionary/entry/entryIO.C