entry Class Referenceabstract

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

Inheritance diagram for entry:
[legend]
Collaboration diagram for entry:
[legend]

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< entryclone (const dictionary &parentDict) const =0
 Construct on freestore as copy with reference to the. More...
 
virtual autoPtr< entryclone () const
 Construct on freestore as copy. More...
 
virtual ~entry ()=default
 Destructor. More...
 
const keyTypekeyword () const
 Return keyword. More...
 
keyTypekeyword ()
 Return non-const access to keyword. More...
 
virtual const fileNamename () const =0
 Return the dictionary name. More...
 
virtual fileNamename ()=0
 Return the dictionary name. 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
 Return true if this entry is a stream. More...
 
virtual ITstreamstream () const =0
 Return token stream, if entry is a primitive entry. More...
 
virtual bool isDict () const
 Return true if this entry is a dictionary. More...
 
virtual const dictionarydictPtr () const
 Return pointer to dictionary, if entry is a dictionary. More...
 
virtual dictionarydictPtr ()
 Return non-const pointer to dictionary, if entry is a dictionary. More...
 
virtual const dictionarydict () const =0
 Return dictionary, if entry is a dictionary. More...
 
virtual dictionarydict ()=0
 Return non-const access to dictionary, if entry is a dictionary. More...
 
void checkITstream (const ITstream &is) const
 
template<class T >
T get () const
 
template<class T >
void readEntry (T &val) const
 
template<class T , class Predicate >
T getCheck (const Predicate &pred) const
 
template<class T , class Predicate >
void readCheck (T &val, const Predicate &pred) const
 
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< entryNew (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...
 

Friends

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

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 67 of file entry.H.

Member Enumeration Documentation

◆ inputMode

enum 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 76 of file entry.H.

Constructor & Destructor Documentation

◆ entry() [1/2]

entry ( const keyType keyword)

Construct from keyword.

Definition at line 55 of file entry.C.

◆ entry() [2/2]

entry ( const entry e)

Construct as copy.

Definition at line 62 of file entry.C.

◆ ~entry()

virtual ~entry ( )
virtualdefault

Destructor.

Member Function Documentation

◆ 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, and primitiveEntry.

◆ 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 69 of file entry.C.

References dictionary::null.

◆ 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 104 of file entryIO.C.

References dictionary::add(), token::BEGIN_BLOCK, token::BEGIN_LIST, fileName::clean(), 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(), keyType::LITERAL, dictionary::makeScopedDict(), Foam::mode(), fileName::name(), fileName::path(), token::pToken(), 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().

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.

  • The dictionaryEntry starts with a '{' left brace and ends with a '}' right brace.
  • The primitiveEntry ends with a ';' semi-colon.

    Example input

       key1 { ... }   // dictionary input
       key2 ... ;     // primitive input
Returns
The entry read, or nullptr on error.

Definition at line 466 of file entryIO.C.

References token::BEGIN_BLOCK, IOstream::fatalCheck(), FUNCTION_NAME, 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 47 of file entry.C.

References entry::globalInputMode, and entry::MERGE.

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

Here is the caller graph for this function:

◆ keyword() [1/2]

◆ keyword() [2/2]

keyType& keyword ( )
inline

Return non-const access to keyword.

Definition at line 193 of file entry.H.

◆ name() [1/2]

virtual const fileName& name ( ) const
pure virtual

Return the dictionary name.

Implemented in primitiveEntry, and dictionaryEntry.

Referenced by dictionary::add().

Here is the caller graph for this function:

◆ name() [2/2]

virtual fileName& name ( )
pure virtual

Return the dictionary name.

Implemented in primitiveEntry, and dictionaryEntry.

◆ startLineNumber()

virtual label startLineNumber ( ) const
pure virtual

Return line number of first token in dictionary.

Implemented in primitiveEntry, and dictionaryEntry.

Referenced by codedFunctionObject::read(), and dynamicCodeContext::setCodeContext().

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 primitiveEntry, and dictionaryEntry.

◆ isStream()

virtual bool isStream ( ) const
inlinevirtual

Return true if this entry is a stream.

Reimplemented in primitiveEntry.

Definition at line 212 of file entry.H.

◆ stream()

virtual ITstream& stream ( ) const
pure virtual

Return token stream, if entry is a primitive entry.

Implemented in primitiveEntry, and dictionaryEntry.

Referenced by exprResultDelayed::exprResultDelayed(), Foam::exprTools::getList(), expressionEntry::inplaceExpand(), solutionControl::maxTypeResidual(), fvGeometryScheme::New(), Foam::blockMeshTools::read(), entry::readCheck(), fvExprDriver::readDict(), entry::readEntry(), shellSurfaces::shellSurfaces(), and solution::upgradeSolverDict().

Here is the caller graph for this function:

◆ isDict()

virtual bool isDict ( ) const
inlinevirtual

Return true if this entry is a dictionary.

Definition at line 222 of file entry.H.

References entry::dictPtr().

Referenced by dictionary::add(), dictionary::cfindScopedDict(), Foam::entryToString(), GAMGSolver::GAMGSolver(), Foam::getVariableOrDie(), dictionary::makeScopedDict(), functionObjectList::read(), GeometricField< Type, PatchField, GeoMesh >::Boundary::readField(), Foam::debug::switchSet(), and solution::upgradeSolverDict().

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

◆ dictPtr() [1/2]

virtual const dictionary* dictPtr ( ) const
inlinevirtual

Return pointer to dictionary, if entry is a dictionary.

Return nullptr if the entry is not a dictionary.

Reimplemented in dictionaryEntry.

Definition at line 229 of file entry.H.

Referenced by dictionary::cfindScopedDict(), entry::isDict(), and dictionary::makeScopedDict().

Here is the caller graph for this function:

◆ dictPtr() [2/2]

virtual dictionary* dictPtr ( )
inlinevirtual

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

Return nullptr if the entry is not a dictionary.

Reimplemented in dictionaryEntry.

Definition at line 236 of file entry.H.

◆ dict() [1/2]

virtual const dictionary& dict ( ) const
pure virtual

Return dictionary, if entry is a dictionary.

Implemented in primitiveEntry, and dictionaryEntry.

Referenced by dictionary::add(), Foam::entryToString(), GAMGSolver::GAMGSolver(), functionObjectList::read(), sampledSurfaces::read(), GeometricField< Type, PatchField, GeoMesh >::Boundary::readField(), refinementSurfaces::refinementSurfaces(), shellSurfaces::shellSurfaces(), and Foam::debug::switchSet().

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.

Implemented in primitiveEntry, and dictionaryEntry.

◆ 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 96 of file entry.C.

References JobInfo::constructed, Foam::endl(), Foam::exit(), Foam::FatalIOError, IOstream::lineNumber(), Foam::name(), Foam::nl, and ITstream::nRemainingTokens().

Referenced by entry::readCheck(), and entry::readEntry().

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

◆ get()

T get ( ) const
inline

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

Definition at line 258 of file entry.H.

References Foam::T().

Referenced by Foam::getOrAdd(), Enum< filterType >::getOrDefault(), and Enum< filterType >::readEntry().

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

◆ readEntry()

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 270 of file entry.H.

References entry::checkITstream(), and entry::stream().

Referenced by codedFunctionObject::read(), and dynamicCodeContext::setCodeContext().

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

◆ getCheck()

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 283 of file entry.H.

References Foam::T().

Here is the call graph for this function:

◆ readCheck()

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 296 of file entry.H.

References entry::checkITstream(), and entry::stream().

Here is the call graph for this function:

◆ write()

virtual void write ( Ostream os) const
pure virtual

◆ operator=()

void operator= ( const entry e)

Definition at line 180 of file entry.C.

References Foam::constant::electromagnetic::e.

◆ operator==()

bool operator== ( const entry e) const

Definition at line 191 of file entry.C.

References Foam::constant::electromagnetic::e, and StringStreamAllocator< StreamType >::str().

Here is the call graph for this function:

◆ operator!=()

bool operator!= ( const entry e) const

Definition at line 214 of file entry.C.

References Foam::constant::electromagnetic::e, and Foam::operator==().

Here is the call graph for this function:

Friends And Related Function Documentation

◆ operator<<

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

Member Data Documentation

◆ disableFunctionEntries

int disableFunctionEntries
static

Enable or disable use of function entries and variable expansions.

Definition at line 119 of file entry.H.

Referenced by entry::New().

◆ globalInputMode

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

The current global input-mode.

Definition at line 122 of file entry.H.

Referenced by entry::resetInputMode().


The documentation for this class was generated from the following files: