#include <cfl_symboltable.h>

Public Member Functions

 SymbolTable (void)
 
 SymbolTable (const SymbolTable &rSrc)
 
const std::string & Name (void) const
 
void Name (const std::string &rName)
 
Idx Size (void) const
 
void Clear (void)
 
Idx MaxIndex (void) const
 
void MaxIndex (Idx index)
 
Idx LastIndex (void) const
 
std::string Symbol (Idx index) const
 
Idx Index (const std::string &rName) const
 
bool Exists (Idx index) const
 
bool Exists (const std::string &rName) const
 
std::string UniqueSymbol (const std::string &rName) const
 
Idx InsEntry (Idx index, const std::string &rName)
 
Idx InsEntry (const std::string &rName)
 
void SetEntry (Idx index, const std::string &rName)
 
void SetDefaultSymbol (Idx index)
 
void ClrEntry (Idx index)
 
void ClrEntry (const std::string &rName)
 
void RestrictDomain (const IndexSet &rDomain)
 
Typeoperator= (const Type &rSrc)
 
- Public Member Functions inherited from faudes::Type
 Type (void)
 
 Type (const Type &rType)
 
virtual ~Type (void)
 
virtual TypeNew (void) const
 
virtual TypeCopy (void) const
 
virtual const TypeCast (const Type *pOther) const
 
virtual TypeAssign (const Type &rSrc)
 
Typeoperator= (const Type &rSrc)
 
virtual bool Equal (const Type &rOther) const
 
bool operator== (const Type &rOther) const
 
bool operator!= (const Type &rOther) const
 
virtual const std::string & TypeName (void) const
 
void Write (const Type *pContext=0) const
 
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
 
void Write (const std::string &pFileName, std::ios::openmode openmode) const
 
void Write (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 
virtual void XWrite (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0) const
 
void XWrite (const Type *pContext=0) const
 
void XWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 
std::string ToString (const std::string &rLabel="", const Type *pContext=0) const
 
std::string ToText (const std::string &rLabel="", const Type *pContext=0) const
 
void DWrite (const Type *pContext=0) const
 
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
 
void DWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 
void SWrite (TokenWriter &rTw) const
 
void SWrite (void) const
 
std::string ToSText (void) const
 
void Read (const std::string &rFileName, const std::string &rLabel="", const Type *pContext=0)
 
void FromString (const std::string &rString, const std::string &rLabel="", const Type *pContext=0)
 
void Read (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 

Static Public Member Functions

static bool ValidSymbol (const std::string &rName)
 
static SymbolTableGlobalEventSymbolTablep (void)
 

Protected Member Functions

void DoAssign (const SymbolTable &rSrc)
 
- Protected Member Functions inherited from faudes::Type
void DoAssign (const Type &rSrc)
 
bool DoEqual (const Type &rOther) const
 
virtual void DoXWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 
virtual void DoDWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 
virtual void DoSWrite (TokenWriter &rTw) const
 
virtual const TypeDefinitionTypeDefinitionp (void) const
 
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)
 
void DoWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 

Private Attributes

std::string mMyName
 
std::map< std::string, IdxmIndexMap
 
std::map< Idx, std::string > mNameMap
 
Idx mMaxIndex
 
Idx mNextIndex
 

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.

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.

◆ operator=()

Type & faudes::Type::operator=

Assign configurationdata from other object. Derived classes should implement the operator form for the assignment for each source type which allows for a non-trivial assignment. This includes the particular case were the source and destination types match exactly. In the latter case the DoAssign method should be invoked. In contrast to the Assign function, the operator form must not be reimplemented for missmatched source types: the operator form only accepts sensible source types. This allows for compiletime typeckecking. However, the downside is that when the type is not known at compiletime, configuration is not properly assigned.

Re-implementation can be done via the convenience macros FAUDES_TYPE_DECLARATION and FAUDES_TYPE_IMPLEMENTATION.

Parameters
rSrcSource to copy from
Returns
Reference to this object.

Definition at line 340 of file cfl_types.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 266 of file cfl_symboltable.h.

◆ mMaxIndex

Idx faudes::SymbolTable::mMaxIndex
private

Upper limit (incl)

Definition at line 272 of file cfl_symboltable.h.

◆ mMyName

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

Name of the SymbolTable

Definition at line 263 of file cfl_symboltable.h.

◆ mNameMap

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

Name lookup map

Definition at line 269 of file cfl_symboltable.h.

◆ mNextIndex

Idx faudes::SymbolTable::mNextIndex
private

Largest used index + 1

Definition at line 275 of file cfl_symboltable.h.


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

libFAUDES 2.33c --- 2025.05.15 --- c++ api documentaion by doxygen