Detailed Description

A SymbolTable associates sybolic names with indices.

Symbolic names are restricted to printable ascii, no quoatation ("), no hash (#) and and no blanks. Indices are of type faudes Idx aka (long unsigned) integer and must be positive. Both, indices and symbolic names must be unique within each SymbolTable. Consistency checks on input data are preformed, regardless of the FAUDES_CHECKED compiletime option.

Generators refer to a global symboltable for event names and hold a local symboltable for state names.

Definition at line 61 of file cfl_symboltable.h.

#include <cfl_symboltable.h>

Public Member Functions

 SymbolTable (void)
 Creates a new SymbolTable. More...
 
 SymbolTable (const SymbolTable &rSrc)
 Copy constructor. More...
 
const std::string & Name (void) const
 Return name of SymbolTable. More...
 
void Name (const std::string &rName)
 Set name of SymbolTable. More...
 
Idx Size (void) const
 Size of symboltabel. More...
 
void Clear (void)
 Clear all entries. More...
 
Idx MaxIndex (void) const
 Get maximum index which this SymbolTable accepts. More...
 
void MaxIndex (Idx index)
 Set maximum index which this SymbolTable accepts. More...
 
Idx LastIndex (void) const
 Get the largest index in use. More...
 
std::string Symbol (Idx index) const
 Symbolic name lookup. More...
 
Idx Index (const std::string &rName) const
 Index lookup. More...
 
bool Exists (Idx index) const
 Test existence of index. More...
 
bool Exists (const std::string &rName) const
 Test existence of symbol. More...
 
std::string UniqueSymbol (const std::string &rName) const
 Create unique symbolic name by adding an underscore and extra digits. More...
 
Idx InsEntry (Idx index, const std::string &rName)
 Add new entry (aka symbolic name and index) to symboltable,. More...
 
Idx InsEntry (const std::string &rName)
 Merge a symbolic name with symboltable. More...
 
void SetEntry (Idx index, const std::string &rName)
 Set symbolic name for existing entry. More...
 
void SetDefaultSymbol (Idx index)
 Set default names ("1", "2", "3", ...) for index. More...
 
void ClrEntry (Idx index)
 Delete entry by index. More...
 
void ClrEntry (const std::string &rName)
 Delete entry by symbol. More...
 
void RestrictDomain (const IndexSet &rDomain)
 Restrict to specified indicees. More...
 
- Public Member Functions inherited from faudes::Type
 Type (void)
 Constructor. More...
 
 Type (const Type &rType)
 Copy constructor. More...
 
virtual ~Type (void)
 Destructor. More...
 
virtual TypeNew (void) const
 Construct on heap. More...
 
virtual TypeCopy (void) const
 Construct on heap. More...
 
virtual const TypeCast (const Type *pOther) const
 Cast other object to this type. More...
 
virtual TypeAssign (const Type &rSrc)
 Assign configuration data from other object. More...
 
virtual Typeoperator= (const Type &rSrc)
 Assign configurationdata from other object. More...
 
virtual bool Equal (const Type &rOther) const
 Test equality of configuration data. More...
 
virtual bool operator== (const Type &rOther) const
 Test equality of configuration data. More...
 
virtual bool operator!= (const Type &rOther) const
 Test equality of configuration data. More...
 
virtual const std::string & TypeName (void) const
 Get objects's type name. More...
 
void Write (const Type *pContext=0) const
 Write configuration data to console. More...
 
void Write (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0, std::ios::openmode openmode=std::ios::out|std::ios::trunc) const
 Write configuration data to a file. More...
 
void Write (const std::string &pFileName, std::ios::openmode openmode) const
 Write configuration data to a file. More...
 
void Write (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to TokenWriter. More...
 
virtual void XWrite (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to an XML file. More...
 
void XWrite (const Type *pContext=0) const
 Write configuration data in XML format to concole Note: this write function uses the virtual function DoXWrite(), to be reimplemented by derived classes. More...
 
void XWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data in XML format to TokenWriter. More...
 
std::string ToString (const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to a string. More...
 
std::string ToText (const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to a formated string. More...
 
void DWrite (const Type *pContext=0) const
 Write configuration data to console, debugging format. More...
 
void DWrite (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0, std::ios::openmode openmode=std::ios::out|std::ios::trunc) const
 Write configuration data to a file, debugging format. More...
 
void DWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data in debug format to TokenWriter. More...
 
void SWrite (TokenWriter &rTw) const
 Write statistics comment to TokenWriter. More...
 
void SWrite (void) const
 Write statistics comment to console. More...
 
std::string ToSText (void) const
 Write statistics to a string. More...
 
void Read (const std::string &rFileName, const std::string &rLabel="", const Type *pContext=0)
 Read configuration data from file with label specified. More...
 
void FromString (const std::string &rString, const std::string &rLabel="", const Type *pContext=0)
 Read configuration data from a string. More...
 
void Read (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 Read configuration data from TokenReader with label sepcified. More...
 

Static Public Member Functions

static bool ValidSymbol (const std::string &rName)
 Test validiy of candidate symbol. More...
 
static SymbolTableGlobalEventSymbolTablep (void)
 Get Static Symboltable ref (initialize on first use pattern) More...
 

Protected Member Functions

void DoAssign (const SymbolTable &rSrc)
 assign my members More...
 
- Protected Member Functions inherited from faudes::Type
void DoAssign (const Type &rSrc)
 Assign configuration data from other object. More...
 
bool DoEqual (const Type &rOther) const
 Test equality of configuration data. More...
 
virtual void DoXWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data of this object to TokenWriter in XML format. More...
 
virtual void DoDWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data in debugging format to TokenWriter. More...
 
virtual void DoSWrite (TokenWriter &rTw) const
 Write statistical data as a comment to TokenWriter. More...
 
virtual const TypeDefinitionTypeDefinitionp (void) const
 Get objects's type definition. More...
 
virtual Token XBeginTag (const std::string &rLabel="", const std::string &rFallbackLabel="") const
 

Private Member Functions

void DoRead (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 Symboltable token io. More...
 
void DoWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Symboltable token io. More...
 

Private Attributes

std::string mMyName
 Name of the SymbolTable. More...
 
std::map< std::string, IdxmIndexMap
 Index lookup map. More...
 
std::map< Idx, std::string > mNameMap
 Name lookup map. More...
 
Idx mMaxIndex
 Upper limit (incl) More...
 
Idx mNextIndex
 Largest used index + 1. More...
 

Constructor & Destructor Documentation

◆ SymbolTable() [1/2]

faudes::SymbolTable::SymbolTable ( void  )

Creates a new SymbolTable.

Definition at line 31 of file cfl_symboltable.cpp.

◆ SymbolTable() [2/2]

faudes::SymbolTable::SymbolTable ( const SymbolTable rSrc)

Copy constructor.

Definition at line 38 of file cfl_symboltable.cpp.

Member Function Documentation

◆ Clear()

void faudes::SymbolTable::Clear ( void  )
virtual

Clear all entries.

Reimplemented from faudes::Type.

Definition at line 63 of file cfl_symboltable.cpp.

◆ ClrEntry() [1/2]

void faudes::SymbolTable::ClrEntry ( const std::string &  rName)

Delete entry by symbol.

Parameters
rNameSymbolic name to delete

Definition at line 220 of file cfl_symboltable.cpp.

◆ ClrEntry() [2/2]

void faudes::SymbolTable::ClrEntry ( Idx  index)

Delete entry by index.

Parameters
indexIndex to delete

Definition at line 212 of file cfl_symboltable.cpp.

◆ DoAssign()

void faudes::SymbolTable::DoAssign ( const SymbolTable rSrc)
protected

assign my members

Definition at line 43 of file cfl_symboltable.cpp.

◆ DoRead()

void faudes::SymbolTable::DoRead ( TokenReader rTr,
const std::string &  rLabel = "",
const Type pContext = 0 
)
privatevirtual

Symboltable token io.

Reimplemented from faudes::Type.

Definition at line 313 of file cfl_symboltable.cpp.

◆ DoWrite()

void faudes::SymbolTable::DoWrite ( TokenWriter rTw,
const std::string &  rLabel = "",
const Type pContext = 0 
) const
privatevirtual

Symboltable token io.

Reimplemented from faudes::Type.

Definition at line 284 of file cfl_symboltable.cpp.

◆ Exists() [1/2]

bool faudes::SymbolTable::Exists ( const std::string &  rName) const

Test existence of symbol.

Parameters
rNameSymbolic name to test
Returns
True, if name exists

Definition at line 269 of file cfl_symboltable.cpp.

◆ Exists() [2/2]

bool faudes::SymbolTable::Exists ( Idx  index) const

Test existence of index.

Parameters
indexIndex to test
Returns
True, if index exists

Definition at line 263 of file cfl_symboltable.cpp.

◆ GlobalEventSymbolTablep()

SymbolTable * faudes::SymbolTable::GlobalEventSymbolTablep ( void  )
static

Get Static Symboltable ref (initialize on first use pattern)

Definition at line 277 of file cfl_symboltable.cpp.

◆ Index()

Idx faudes::SymbolTable::Index ( const std::string &  rName) const

Index lookup.

Parameters
rNameSymbolic name to lookup
Returns
Index of symbolic name, or 0 for non-existent name

Definition at line 243 of file cfl_symboltable.cpp.

◆ InsEntry() [1/2]

Idx faudes::SymbolTable::InsEntry ( const std::string &  rName)

Merge a symbolic name with symboltable.

If the symbol does not exist, find a new index and add the new entry. If the symbol does exist, lookup its index.

Parameters
rNameSymbolic name to merge
Returns
Index of rName
Exceptions
Exception
  • invalid name (id 43)

Definition at line 170 of file cfl_symboltable.cpp.

◆ InsEntry() [2/2]

Idx faudes::SymbolTable::InsEntry ( Idx  index,
const std::string &  rName 
)

Add new entry (aka symbolic name and index) to symboltable,.

Parameters
indexNew index
rNameNew symbolic name
Returns
New index
Exceptions
Exception
  • name already associated with another index (id 41)
  • index already associated with another name (id 42)
  • invalid name (id 43)

Definition at line 138 of file cfl_symboltable.cpp.

◆ LastIndex()

Idx faudes::SymbolTable::LastIndex ( void  ) const

Get the largest index in use.

Definition at line 92 of file cfl_symboltable.cpp.

◆ MaxIndex() [1/2]

void faudes::SymbolTable::MaxIndex ( Idx  index)

Set maximum index which this SymbolTable accepts.

Parameters
indexNew maximum index
Exceptions
Exception
  • symboltable overflow (id 40)

Definition at line 81 of file cfl_symboltable.cpp.

◆ MaxIndex() [2/2]

Idx faudes::SymbolTable::MaxIndex ( void  ) const

Get maximum index which this SymbolTable accepts.

Definition at line 76 of file cfl_symboltable.cpp.

◆ Name() [1/2]

void faudes::SymbolTable::Name ( const std::string &  rName)
virtual

Set name of SymbolTable.

Reimplemented from faudes::Type.

Definition at line 58 of file cfl_symboltable.cpp.

◆ Name() [2/2]

const std::string & faudes::SymbolTable::Name ( void  ) const
virtual

Return name of SymbolTable.

Reimplemented from faudes::Type.

Definition at line 53 of file cfl_symboltable.cpp.

◆ RestrictDomain()

void faudes::SymbolTable::RestrictDomain ( const IndexSet rDomain)

Restrict to specified indicees.

Parameters
rDomainIndicees to keep.

Definition at line 228 of file cfl_symboltable.cpp.

◆ SetDefaultSymbol()

void faudes::SymbolTable::SetDefaultSymbol ( Idx  index)

Set default names ("1", "2", "3", ...) for index.

Parameters
indexIndex for which to set the default name

Definition at line 203 of file cfl_symboltable.cpp.

◆ SetEntry()

void faudes::SymbolTable::SetEntry ( Idx  index,
const std::string &  rName 
)

Set symbolic name for existing entry.

If the name is the emptystring, an existing entry is cleared. All other invalid names throw an exception.

Parameters
indexIndex to specify entry
rNameNew esymbolic name for index
Exceptions
Exception
  • name already associated with another index (id 41)
  • invalid name (id 43)

Definition at line 178 of file cfl_symboltable.cpp.

◆ Size()

Idx faudes::SymbolTable::Size ( void  ) const

Size of symboltabel.

Definition at line 71 of file cfl_symboltable.cpp.

◆ Symbol()

std::string faudes::SymbolTable::Symbol ( Idx  index) const

Symbolic name lookup.

Parameters
indexIndex to lookup
Returns
Symbolic name of index, or empty string "" for non-existent index

Definition at line 252 of file cfl_symboltable.cpp.

◆ UniqueSymbol()

std::string faudes::SymbolTable::UniqueSymbol ( const std::string &  rName) const

Create unique symbolic name by adding an underscore and extra digits.

The current implementation tries to be smart and overwrites any previously added digits. It is also slow.

Parameters
rNameCandidate symbolic name
Returns
Unique symbolic name

Definition at line 114 of file cfl_symboltable.cpp.

◆ ValidSymbol()

bool faudes::SymbolTable::ValidSymbol ( const std::string &  rName)
static

Test validiy of candidate symbol.

The current implementation insists in printable ascii, no quotes ("), no hash (#) and no blanks.

Parameters
rNameSymbolic name to test
Returns
True, if name is a valid symbol

Definition at line 97 of file cfl_symboltable.cpp.

Member Data Documentation

◆ mIndexMap

std::map<std::string,Idx> faudes::SymbolTable::mIndexMap
private

Index lookup map.

Definition at line 264 of file cfl_symboltable.h.

◆ mMaxIndex

Idx faudes::SymbolTable::mMaxIndex
private

Upper limit (incl)

Definition at line 270 of file cfl_symboltable.h.

◆ mMyName

std::string faudes::SymbolTable::mMyName
private

Name of the SymbolTable.

Definition at line 261 of file cfl_symboltable.h.

◆ mNameMap

std::map<Idx,std::string> faudes::SymbolTable::mNameMap
private

Name lookup map.

Definition at line 267 of file cfl_symboltable.h.

◆ mNextIndex

Idx faudes::SymbolTable::mNextIndex
private

Largest used index + 1.

Definition at line 273 of file cfl_symboltable.h.


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

libFAUDES 2.32b --- 2024.03.01 --- c++ api documentaion by doxygen