OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

dictionary Class Reference

A list of keyword definitions, which are a keyword followed by any number of values (e.g. words and numbers). The keywords can represent patterns which are matched using Posix regular expressions. The general order for searching is as follows:
  • exact match
  • pattern match (in reverse order)
  • optional recursion into the enclosing (parent) dictionaries.
More...

Inheritance diagram for dictionary:
Collaboration diagram for dictionary:

List of all members.


Public Member Functions

bool read (Istream &)
 Read dictionary from Istream.
bool substituteKeyword (const word &keyword)
 Substitute the given keyword prepended by '$' with the.
 ClassName ("dictionary")
 dictionary ()
 Construct top-level dictionary null.
 dictionary (const dictionary &parentDict, Istream &)
 Construct from the parent dictionary and Istream, reading entries.
 dictionary (Istream &)
 Construct top-level dictionary from Istream, reading entries.
 dictionary (const dictionary &parentDict, const dictionary &)
 Construct as copy given the parent dictionary.
 dictionary (const dictionary &)
 Construct top-level dictionary as copy.
 dictionary (const dictionary *)
 Construct top-level dictionary as copy from pointer to dictionary.
 dictionary (const dictionary &parentDict, const Xfer< dictionary > &)
 Construct by transferring parameter contents given parent dictionary.
 dictionary (const Xfer< dictionary > &)
 Construct top-level dictionary by transferring parameter contents.
autoPtr< dictionary > clone () const
 Construct and return clone.
 ~dictionary ()
const fileName & name () const
 Return the dictionary name.
fileName & name ()
 Return the dictionary name.
const dictionary & parent () const
 Return the parent dictionary.
label startLineNumber () const
 Return line number of first token in dictionary.
label endLineNumber () const
 Return line number of last token in dictionary.
SHA1Digest digest () const
 Return the SHA1 digest of the dictionary contents.
bool found (const word &, bool recursive=false) const
 Search dictionary for given keyword.
const entry * lookupEntryPtr (const word &, bool recursive, bool patternMatch) const
 Find and return an entry data stream pointer if present.
entry * lookupEntryPtr (const word &, bool recursive, bool patternMatch)
 Find and return an entry data stream pointer for manipulation.
const entry & lookupEntry (const word &, bool recursive, bool patternMatch) const
 Find and return an entry data stream if present otherwise error.
ITstream & lookup (const word &, bool recursive=false, bool patternMatch=true) const
 Find and return an entry data stream.
template<class T >
T lookupOrDefault (const word &, const T &, bool recursive=false, bool patternMatch=true) const
 Find and return a T,.
template<class T >
T lookupOrAddDefault (const word &, const T &, bool recursive=false, bool patternMatch=true)
 Find and return a T, if not found return the given.
template<class T >
bool readIfPresent (const word &, T &, bool recursive=false, bool patternMatch=true) const
 Find an entry if present, and assign to T.
bool isDict (const word &) const
 Check if entry is a sub-dictionary.
const dictionary * subDictPtr (const word &) const
 Find and return a sub-dictionary pointer if present.
const dictionary & subDict (const word &) const
 Find and return a sub-dictionary.
dictionary & subDict (const word &)
 Find and return a sub-dictionary for manipulation.
wordList toc () const
 Return the table of contents.
List< keyType > keys (bool patterns=false) const
 Return the list of available keys or patterns.
bool add (entry *, bool mergeEntry=false)
 Add a new entry.
void add (const entry &, bool mergeEntry=false)
 Add an entry.
void add (const keyType &, const word &, bool overwrite=false)
 Add a word entry.
void add (const keyType &, const string &, bool overwrite=false)
 Add a string entry.
void add (const keyType &, const label, bool overwrite=false)
 Add a label entry.
void add (const keyType &, const scalar, bool overwrite=false)
 Add a scalar entry.
void add (const keyType &, const dictionary &, bool mergeEntry=false)
 Add a dictionary entry.
template<class T >
void add (const keyType &, const T &, bool overwrite=false)
 Add a T entry.
void set (entry *)
 Assign a new entry, overwrite any existing entry.
void set (const entry &)
 Assign a new entry, overwrite any existing entry.
void set (const keyType &, const dictionary &)
 Assign a dictionary entry, overwrite any existing entry.
template<class T >
void set (const keyType &, const T &)
 Assign a T entry, overwrite any existing entry.
bool remove (const word &)
 Remove an entry specified by keyword.
bool changeKeyword (const keyType &oldKeyword, const keyType &newKeyword, bool forceOverwrite=false)
 Change the keyword for an entry,.
bool merge (const dictionary &)
 Merge entries from the given dictionary.
void clear ()
 Clear the dictionary.
void transfer (dictionary &)
 Transfer the contents of the argument and annull the argument.
Xfer< dictionary > xfer ()
 Transfer contents to the Xfer container.
void write (Ostream &, bool subDict=true) const
ITstream & operator[] (const word &) const
 Find and return entry.
void operator= (const dictionary &)
void operator+= (const dictionary &)
 Include entries from the given dictionary.
void operator|= (const dictionary &)
 Conditionally include entries from the given dictionary.
void operator<<= (const dictionary &)
 Unconditionally include entries from the given dictionary.

Static Public Member Functions

static autoPtr< dictionary > New (Istream &)
 Construct top-level dictionary on freestore from Istream.

Static Public Attributes

static const dictionary null
 Null dictionary.

Friends

class entry
 Declare friendship with the entry class for IO.
Istream & operator>> (Istream &, dictionary &)
 Read dictionary from Istream.
Ostream & operator<< (Ostream &, const dictionary &)
 Write dictionary to Ostream.

Detailed Description

A list of keyword definitions, which are a keyword followed by any number of values (e.g. words and numbers). The keywords can represent patterns which are matched using Posix regular expressions. The general order for searching is as follows:
  • exact match
  • pattern match (in reverse order)
  • optional recursion into the enclosing (parent) dictionaries.

The dictionary class is the base class for IOdictionary. It also serves as a bootstrap dictionary for the objectRegistry data dictionaries since, unlike the IOdictionary class, it does not use an objectRegistry itself to work.

Todo:
A merge() member function with a non-const dictionary parameter. This would avoid unnecessary cloning in the add(entry*,bool) method
Source files

Definition at line 76 of file dictionary.H.


Constructor & Destructor Documentation

dictionary (  ) 

Construct top-level dictionary null.

Definition at line 97 of file dictionary.C.

Referenced by dictionary::~dictionary().

Here is the caller graph for this function:

dictionary ( const dictionary &  parentDict,
Istream &  is 
)

Construct from the parent dictionary and Istream, reading entries.

until lastEntry or EOF

Definition at line 88 of file dictionaryIO.C.

dictionary ( Istream &  is  ) 

Construct top-level dictionary from Istream, reading entries.

until EOF

Definition at line 100 of file dictionaryIO.C.

References dictionary::read().

Here is the call graph for this function:

dictionary ( const dictionary &  parentDict,
const dictionary &  dict 
)

Construct as copy given the parent dictionary.

Definition at line 104 of file dictionary.C.

dictionary ( const dictionary &  dict  ) 

Construct top-level dictionary as copy.

Definition at line 130 of file dictionary.C.

dictionary ( const dictionary *  dictPtr  ) 

Construct top-level dictionary as copy from pointer to dictionary.

A null pointer is treated like an empty dictionary.

Definition at line 155 of file dictionary.C.

dictionary ( const dictionary &  parentDict,
const Xfer< dictionary > &  dict 
)

Construct by transferring parameter contents given parent dictionary.

Definition at line 169 of file dictionary.C.

dictionary ( const Xfer< dictionary > &  dict  ) 

Construct top-level dictionary by transferring parameter contents.

Definition at line 181 of file dictionary.C.

References dictionary::transfer().

Here is the call graph for this function:

~dictionary (  ) 

Definition at line 199 of file dictionary.C.

References dictionary::dictionary().

Here is the call graph for this function:


Member Function Documentation

bool read ( Istream &  is  ) 

Read dictionary from Istream.

Definition at line 25 of file dictionaryIO.C.

References IOstream::bad(), token::BEGIN_BLOCK, IOstream::eof(), Foam::exit(), Foam::FatalIOError, FatalIOErrorIn, IOstream::good(), Foam::Info, dictionary::name(), dictionary::New(), and Istream::putBack().

Referenced by dictionary::dictionary(), and includeIfPresentEntry::execute().

Here is the call graph for this function:

Here is the caller graph for this function:

bool substituteKeyword ( const word &  keyword  ) 

Substitute the given keyword prepended by '$' with the.

corresponding sub-dictionary entries

Definition at line 61 of file dictionaryIO.C.

ClassName ( "dictionary"   ) 

Foam::autoPtr< Foam::dictionary > clone (  )  const

Construct and return clone.

Definition at line 191 of file dictionary.C.

References dictionary::transfer().

Referenced by dictionary::operator+=(), and dictionary::operator<<=().

Here is the call graph for this function:

Here is the caller graph for this function:

Foam::autoPtr< Foam::dictionary > New ( Istream &  is  )  [static]

Construct top-level dictionary on freestore from Istream.

Definition at line 112 of file dictionaryIO.C.

References inputModeEntry::clear().

Referenced by dictionary::read().

Here is the call graph for this function:

Here is the caller graph for this function:

const fileName& name (  )  const [inline]

Return the dictionary name.

Reimplemented in timeActivatedExplicitSource, fvMesh, dictionaryEntry, IOOutputFilter< OutputFilter >, and IOdictionary.

Definition at line 198 of file dictionary.H.

Referenced by dictionary::read().

Here is the caller graph for this function:

fileName& name (  )  [inline]

Return the dictionary name.

Reimplemented in dictionaryEntry.

Definition at line 204 of file dictionary.H.

const dictionary& parent (  )  const [inline]

Return the parent dictionary.

Definition at line 210 of file dictionary.H.

Foam::label startLineNumber (  )  const

Return line number of first token in dictionary.

Reimplemented in dictionaryEntry.

Definition at line 207 of file dictionary.C.

Foam::label endLineNumber (  )  const

Return line number of last token in dictionary.

Reimplemented in dictionaryEntry.

Definition at line 220 of file dictionary.C.

Foam::SHA1Digest digest (  )  const

Return the SHA1 digest of the dictionary contents.

Definition at line 233 of file dictionary.C.

bool found ( const word &  keyword,
bool  recursive = false 
) const

const Foam::entry * lookupEntryPtr ( const word &  keyword,
bool  recursive,
bool  patternMatch 
) const

Find and return an entry data stream pointer if present.

otherwise return NULL. If recursive, search parent dictionaries. If patternMatch, use regular expressions

Definition at line 282 of file dictionary.C.

Referenced by dictionary::lookupOrDefault().

Here is the caller graph for this function:

Foam::entry * lookupEntryPtr ( const word &  keyword,
bool  recursive,
bool  patternMatch 
)

Find and return an entry data stream pointer for manipulation.

if present otherwise return NULL. If recursive, search parent dictionaries. If patternMatch, use regular expressions.

Definition at line 321 of file dictionary.C.

const Foam::entry & lookupEntry ( const word &  keyword,
bool  recursive,
bool  patternMatch 
) const

Find and return an entry data stream if present otherwise error.

If recursive, search parent dictionaries. If patternMatch, use regular expressions.

Definition at line 365 of file dictionary.C.

Referenced by dictionary::isDict().

Here is the caller graph for this function:

Foam::ITstream & lookup ( const word &  keyword,
bool  recursive = false,
bool  patternMatch = true 
) const

Find and return an entry data stream.

If recursive, search parent dictionaries. If patternMatch, use regular expressions.

Definition at line 389 of file dictionary.C.

Referenced by activeBaffleVelocityFvPatchVectorField::activeBaffleVelocityFvPatchVectorField(), autoHexMeshDriver::autoHexMeshDriver(), cubeRootVolDelta::correct(), IDDESDelta::correct(), dictionaryEntry::dict(), Foam::dimensionedConstant(), staticPressure::execute(), FreeStream< CloudType >::FreeStream(), ignition::ignition(), liquidMixture::liquidMixture(), fieldMinMax::makeFile(), multivariateSelectionScheme< Type >::multivariateSelectionScheme(), viscosityModel::New(), hReactionThermo::New(), hhuCombustionThermo::New(), hCombustionThermo::New(), scatterModel::New(), absorptionEmissionModel::New(), radiationModel::New(), pdf::New(), laminarFlameSpeed::New(), rhoChemistryModel::New(), psiChemistryModel::New(), basicRhoThermo::New(), basicPsiThermo::New(), barotropicCompressibilityModel::New(), pointZone::New(), faceZone::New(), cellZone::New(), tetherPotential::New(), pairPotential::New(), energyScalingFunction::New(), HeatTransferModel< CloudType >::New(), SurfaceReactionModel< CloudType >::New(), DevolatilisationModel< CloudType >::New(), PhaseChangeModel< CloudType >::New(), CompositionModel< CloudType >::New(), PostProcessingModel< CloudType >::New(), PatchInteractionModel< CloudType >::New(), InjectionModel< CloudType >::New(), DragModel< CloudType >::New(), DispersionModel< CloudType >::New(), DataEntry< Type >::New(), IntegrationScheme< Type >::New(), WallInteractionModel< CloudType >::New(), InflowBoundaryModel< CloudType >::New(), BinaryCollisionModel< CloudType >::New(), wallModel::New(), injectorModel::New(), heatTransferModel::New(), evaporationModel::New(), dragModel::New(), dispersionModel::New(), collisionModel::New(), breakupModel::New(), atomizationModel::New(), SRFModel::New(), engineMesh::New(), polyMeshModifier::New(), solidBodyMotionFunction::New(), dynamicFvMesh::New(), dlLibraryTable::open(), laplaceFilter::operator()(), anisotropicFilter::operator()(), dictionary::operator=(), phaseProperties::phaseProperties(), pointSourceProperties::pointSourceProperties(), Foam::preservePatchTypes(), Time::readDict(), DimensionedField< Type, GeoMesh >::readField(), IOobject::readHeader(), refinementSurfaces::refinementSurfaces(), searchableSurfaces::searchableSurfaces(), Foam::setRefCell(), tolerances::solverRelativeTolerance(), tolerances::solverRelativeTolerances(), fvMotionSolverEngineMesh::~fvMotionSolverEngineMesh(), laminarFlameSpeed::~laminarFlameSpeed(), and layeredEngineMesh::~layeredEngineMesh().

T lookupOrDefault ( const word &  keyword,
const T &  deflt,
bool  recursive = false,
bool  patternMatch = true 
) const [inline]

Find and return a T,.

if not found return the given default value If recursive, search parent dictionaries. If patternMatch, use regular expressions.

Definition at line 25 of file dictionaryTemplates.C.

References dictionary::lookupEntryPtr(), and entry::stream().

Referenced by dimensioned< Type >::lookupOrAddToDict(), fieldMinMax::makeFile(), GAMGPreconditioner::precondition(), solver::read(), and smoothSolver::solve().

Here is the call graph for this function:

Here is the caller graph for this function:

T lookupOrAddDefault ( const word &  keyword,
const T &  deflt,
bool  recursive = false,
bool  patternMatch = true 
) [inline]

Find and return a T, if not found return the given.

default value, and add to dictionary. If recursive, search parent dictionaries. If patternMatch, use regular expressions.

Definition at line 47 of file dictionaryTemplates.C.

Referenced by Foam::debug::infoSwitch(), Foam::debug::optimisationSwitch(), and Switch::readIfPresent().

Here is the caller graph for this function:

bool readIfPresent ( const word &  k,
T &  val,
bool  recursive = false,
bool  patternMatch = true 
) const [inline]

Find an entry if present, and assign to T.

Returns true if the entry was found. If recursive, search parent dictionaries. If patternMatch, use regular expressions.

Definition at line 70 of file dictionaryTemplates.C.

References dictionary::add().

Referenced by staticPressure::execute(), chemistryReader< ThermoType >::New(), coordinateSystem::New(), dimensioned< Type >::operator[](), patchIdentifier::patchIdentifier(), Foam::preservePatchTypes(), Time::readDict(), boundaryRegion::readDict(), IOobject::readHeader(), searchableSurfaces::searchableSurfaces(), surfZoneIdentifier::surfZoneIdentifier(), and sampledSurface::~sampledSurface().

Here is the call graph for this function:

Here is the caller graph for this function:

bool isDict ( const word &  keyword  )  const

Check if entry is a sub-dictionary.

Definition at line 399 of file dictionary.C.

References dictionary::lookupEntry(), and entry::stream().

Referenced by searchableSurfaces::searchableSurfaces().

Here is the call graph for this function:

Here is the caller graph for this function:

const Foam::dictionary * subDictPtr ( const word &  keyword  )  const

Find and return a sub-dictionary pointer if present.

otherwise return NULL.

Definition at line 415 of file dictionary.C.

Referenced by liquidMixture::liquidMixture().

Here is the caller graph for this function:

const Foam::dictionary & subDict ( const word &  keyword  )  const

Find and return a sub-dictionary.

Definition at line 430 of file dictionary.C.

Referenced by smoothDelta::correct(), cubeRootVolDelta::correct(), IDDESDelta::correct(), laplaceFilter::operator()(), anisotropicFilter::operator()(), Foam::preservePatchTypes(), and searchableSurfaces::searchableSurfaces().

Here is the caller graph for this function:

Foam::dictionary & subDict ( const word &  keyword  ) 

Find and return a sub-dictionary for manipulation.

Definition at line 448 of file dictionary.C.

Foam::wordList toc (  )  const

Return the table of contents.

Definition at line 466 of file dictionary.C.

Referenced by FreeStream< CloudType >::FreeStream().

Here is the caller graph for this function:

Foam::List< Foam::keyType > keys ( bool  patterns = false  )  const

Return the list of available keys or patterns.

Definition at line 480 of file dictionary.C.

bool add ( entry *  entryPtr,
bool  mergeEntry = false 
)

Add a new entry.

With the merge option, dictionaries are interwoven and primitive entries are overwritten

Definition at line 498 of file dictionary.C.

Referenced by dictionary::add(), autoHexMeshDriver::autoHexMeshDriver(), Foam::dimensionedConstant(), dictionary::operator+=(), dictionary::operator<<=(), Foam::preservePatchTypes(), dictionary::readIfPresent(), and dictionary::set().

Here is the caller graph for this function:

void add ( const entry &  e,
bool  mergeEntry = false 
)

Add an entry.

With the merge option, dictionaries are interwoven and primitive entries are overwritten

Definition at line 579 of file dictionary.C.

void add ( const keyType &  k,
const word &  w,
bool  overwrite = false 
)

Add a word entry.

optionally overwrite an existing entry

Definition at line 585 of file dictionary.C.

void add ( const keyType &  k,
const string &  s,
bool  overwrite = false 
)

Add a string entry.

optionally overwrite an existing entry

Definition at line 592 of file dictionary.C.

References dictionary::add().

Here is the call graph for this function:

void add ( const keyType &  k,
const label  l,
bool  overwrite = false 
)

Add a label entry.

optionally overwrite an existing entry

Definition at line 602 of file dictionary.C.

References dictionary::add().

Here is the call graph for this function:

void add ( const keyType &  k,
const scalar  s,
bool  overwrite = false 
)

Add a scalar entry.

optionally overwrite an existing entry

Definition at line 608 of file dictionary.C.

void add ( const keyType &  k,
const dictionary &  d,
bool  mergeEntry = false 
)

Add a dictionary entry.

optionally merge with an existing sub-dictionary

Definition at line 615 of file dictionary.C.

References dictionary::add().

Here is the call graph for this function:

void add ( const keyType &  k,
const T &  t,
bool  overwrite = false 
) [inline]

Add a T entry.

optionally overwrite an existing entry

Definition at line 92 of file dictionaryTemplates.C.

void set ( entry *  entryPtr  ) 

Assign a new entry, overwrite any existing entry.

Definition at line 625 of file dictionary.C.

References dictionary::add().

Here is the call graph for this function:

void set ( const entry &  e  ) 

Assign a new entry, overwrite any existing entry.

Definition at line 638 of file dictionary.C.

References dictionary::clear(), and entry::dict().

Here is the call graph for this function:

void set ( const keyType &  k,
const dictionary &  d 
)

Assign a dictionary entry, overwrite any existing entry.

Definition at line 644 of file dictionary.C.

void set ( const keyType &  k,
const T &  t 
) [inline]

Assign a T entry, overwrite any existing entry.

Definition at line 99 of file dictionaryTemplates.C.

References dictionary::add().

Here is the call graph for this function:

bool remove ( const word &  Keyword  ) 

Remove an entry specified by keyword.

Definition at line 650 of file dictionary.C.

Referenced by autoHexMeshDriver::autoHexMeshDriver().

Here is the caller graph for this function:

bool changeKeyword ( const keyType &  oldKeyword,
const keyType &  newKeyword,
bool  forceOverwrite = false 
)

Change the keyword for an entry,.

optionally forcing overwrite of an existing entry

Definition at line 683 of file dictionary.C.

bool merge ( const dictionary &  dict  ) 

Merge entries from the given dictionary.

Also merge sub-dictionaries as required.

Definition at line 774 of file dictionary.C.

void clear (  ) 

Clear the dictionary.

Reimplemented from ILList< DLListBase, entry >.

Definition at line 819 of file dictionary.C.

Referenced by dictionary::set(), and dictionary::transfer().

Here is the caller graph for this function:

void transfer ( dictionary &  dict  ) 

Transfer the contents of the argument and annull the argument.

Definition at line 828 of file dictionary.C.

References LList< LListBase, T >::clear(), HashTable< T, Key, Hash >::clear(), and dictionary::clear().

Referenced by dictionary::clone(), and dictionary::dictionary().

Here is the call graph for this function:

Here is the caller graph for this function:

Foam::Xfer< Foam::dictionary > xfer (  ) 

Transfer contents to the Xfer container.

Definition at line 841 of file dictionary.C.

void write ( Ostream &  os,
bool  subDict = true 
) const

Definition at line 134 of file dictionaryIO.C.

Foam::ITstream & operator[] ( const word &  keyword  )  const

Find and return entry.

Definition at line 849 of file dictionary.C.

References Foam::xferMove().

Here is the call graph for this function:

void operator= ( const dictionary &  rhs  ) 

Definition at line 855 of file dictionary.C.

References dictionary::lookup().

Here is the call graph for this function:

void operator+= ( const dictionary &  rhs  ) 

Include entries from the given dictionary.

Warn, but do not overwrite existing entries.

Definition at line 878 of file dictionary.C.

References dictionary::add(), and dictionary::clone().

Here is the call graph for this function:

void operator|= ( const dictionary &  rhs  ) 

Conditionally include entries from the given dictionary.

Do not overwrite existing entries.

Definition at line 895 of file dictionary.C.

void operator<<= ( const dictionary &  rhs  ) 

Unconditionally include entries from the given dictionary.

Overwrite existing entries.

Definition at line 915 of file dictionary.C.

References dictionary::add(), dictionary::clone(), and dictionary::found().

Here is the call graph for this function:


Friends And Related Function Documentation

friend class entry [friend]

Declare friendship with the entry class for IO.

Definition at line 133 of file dictionary.H.

Istream& operator>> ( Istream &  ,
dictionary &   
) [friend]

Read dictionary from Istream.

Ostream& operator<< ( Ostream &  ,
const dictionary &   
) [friend]

Write dictionary to Ostream.


Member Data Documentation


The documentation for this class was generated from the following files:
Copyright © 2000-2009 OpenCFD Ltd