faudes::SymbolTable Class Reference

A SymbolTable associates sybolic names with indices. More...

#include <cfl_symboltable.h>

List of all members.

Public Member Functions

 SymbolTable (void)
 Creates a new SymbolTable.
 SymbolTable (const SymbolTable &rSrc)
 Copy constructor.
const std::string & Name (void) const
 Return name of SymbolTable.
void Name (const std::string &rName)
 Set name of SymbolTable.
Idx Size (void) const
 Size of symboltabel.
void Clear (void)
 Clear all entries.
Idx MaxIndex (void) const
 Get maximum index which this SymbolTable accepts.
void MaxIndex (Idx index)
 Set maximum index which this SymbolTable accepts.
Idx LastIndex (void) const
 Get the largest index in use.
std::string Symbol (Idx index) const
 Symbolic name lookup.
Idx Index (const std::string &rName) const
 Index lookup.
bool Exists (Idx index) const
 Test existence of index.
bool Exists (const std::string &rName) const
 Test existence of symbol.
std::string UniqueSymbol (const std::string &rName) const
 Create unique symbolic name by adding an underscore and extra digits.
Idx InsEntry (Idx index, const std::string &rName)
 Add new entry (aka symbolic name and index) to symboltable,.
Idx InsEntry (const std::string &rName)
 Merge a symbolic name with symboltable.
void SetEntry (Idx index, const std::string &rName)
 Set symbolic name for existing entry.
void SetDefaultSymbol (Idx index)
 Set default names ("1", "2", "3", .
void ClrEntry (Idx index)
 Delete entry by index.
void ClrEntry (const std::string &rName)
 Delete entry by symbol.
void RestrictDomain (const IndexSet &rDomain)
 Restrict to specified indicees.

Static Public Member Functions

static bool ValidSymbol (const std::string &rName)
 Test validiy of candidate symbol.
static SymbolTableGlobalEventSymbolTablep (void)
 Get Static Symboltable ref.

Protected Member Functions

virtual void DoAssign (const SymbolTable &rSrc)
 assign my members

Private Member Functions

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

Private Attributes

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

Static Private Attributes

static SymbolTable msEventSymbolTable
 static event symbol table (should go to faudes::Generator, or faudes)

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

faudes::SymbolTable::SymbolTable ( void   ) 

Creates a new SymbolTable.

Definition at line 33 of file cfl_symboltable.cpp.

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

Copy constructor.

Definition at line 40 of file cfl_symboltable.cpp.


Member Function Documentation

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

Clear all entries.

Reimplemented from faudes::Type.

Definition at line 65 of file cfl_symboltable.cpp.

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

Delete entry by symbol.

Parameters:
rName Symbolic name to delete

Definition at line 222 of file cfl_symboltable.cpp.

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

Delete entry by index.

Parameters:
index Index to delete

Definition at line 214 of file cfl_symboltable.cpp.

void faudes::SymbolTable::DoAssign ( const SymbolTable rSrc  )  [protected, virtual]

assign my members

Definition at line 45 of file cfl_symboltable.cpp.

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

Symboltable token io.

Reimplemented from faudes::Type.

Definition at line 313 of file cfl_symboltable.cpp.

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

Symboltable token io.

Reimplemented from faudes::Type.

Definition at line 284 of file cfl_symboltable.cpp.

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

Test existence of symbol.

Parameters:
rName Symbolic name to test
Returns:
True, if name exists

Definition at line 271 of file cfl_symboltable.cpp.

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

Test existence of index.

Parameters:
index Index to test
Returns:
True, if index exists

Definition at line 265 of file cfl_symboltable.cpp.

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

Get Static Symboltable ref.

Definition at line 278 of file cfl_symboltable.cpp.

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

Index lookup.

Parameters:
rName Symbolic name to lookup
Returns:
Index of symbolic name, or 0 for non-existent name

Definition at line 245 of file cfl_symboltable.cpp.

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:
rName Symbolic name to merge
Returns:
Index of rName
Exceptions:
Exception 
  • invalid name (id 43)

Definition at line 172 of file cfl_symboltable.cpp.

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

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

Parameters:
index New index
rName New 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 140 of file cfl_symboltable.cpp.

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

Get the largest index in use.

Definition at line 94 of file cfl_symboltable.cpp.

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

Set maximum index which this SymbolTable accepts.

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

Definition at line 83 of file cfl_symboltable.cpp.

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

Get maximum index which this SymbolTable accepts.

Definition at line 78 of file cfl_symboltable.cpp.

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

Set name of SymbolTable.

Reimplemented from faudes::Type.

Definition at line 60 of file cfl_symboltable.cpp.

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

Return name of SymbolTable.

Reimplemented from faudes::Type.

Definition at line 55 of file cfl_symboltable.cpp.

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

Restrict to specified indicees.

Parameters:
rDomain Indicees to keep.

Definition at line 230 of file cfl_symboltable.cpp.

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

Set default names ("1", "2", "3", .

..) for index.

Parameters:
index Index for which to set the default name

Definition at line 205 of file cfl_symboltable.cpp.

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:
index Index to specify entry
rName New esymbolic name for index
Exceptions:
Exception 
  • name already associated with another index (id 41)
  • invalid name (id 43)

Definition at line 180 of file cfl_symboltable.cpp.

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

Size of symboltabel.

Definition at line 73 of file cfl_symboltable.cpp.

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

Symbolic name lookup.

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

Definition at line 254 of file cfl_symboltable.cpp.

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:
rName Candidate symbolic name
Returns:
Unique symbolic name

Definition at line 116 of file cfl_symboltable.cpp.

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:
rName Symbolic name to test
Returns:
True, if name is a valid symbol

Definition at line 99 of file cfl_symboltable.cpp.


Member Data Documentation

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

Index lookup map.

Definition at line 263 of file cfl_symboltable.h.

Upper limit (incl).

Definition at line 269 of file cfl_symboltable.h.

std::string faudes::SymbolTable::mMyName [private]

Name of the SymbolTable.

Definition at line 260 of file cfl_symboltable.h.

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

Name lookup map.

Definition at line 266 of file cfl_symboltable.h.

Largest used index + 1.

Definition at line 272 of file cfl_symboltable.h.

static event symbol table (should go to faudes::Generator, or faudes)

Definition at line 275 of file cfl_symboltable.h.


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

libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen