libFAUDES
Sections
Index
|
faudes::SymbolTable Class Reference#include <symboltable.h>
Inherits faudes::Type.
List of all members.
Detailed Description
A SymbolTable associates sybolic names with indices.
Symbolic names are restricted to printable ascii, no quoatation ("), 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 symboltable.h.
|
Public Member Functions |
| SymbolTable (void) |
| Creates a new SymbolTable.
|
const std::string & | Name (void) const |
| Return name of SymbolTable.
|
void | Name (const std::string &rName) |
| Set name of SymbolTable.
|
Idx | Size (void) |
| 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 accapts.
|
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 SymbolTable * | GlobalEventSymbolTablep (void) |
| Get Static Symboltable ref.
|
Private Member Functions |
void | DoRead (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0) |
| Dummy, symboltable does not provide token io.
|
void | DoWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const |
| Dummy, symboltable does not provide token io.
|
Private Attributes |
std::string | mMyName |
| Name of the SymbolTable.
|
std::map< std::string, Idx > | mIndexMap |
| 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::vGenerator, or faudes)
|
Constructor & Destructor Documentation
faudes::SymbolTable::SymbolTable |
( |
void |
|
) |
|
Member Function Documentation
const std::string & faudes::SymbolTable::Name |
( |
void |
|
) |
const [virtual] |
void faudes::SymbolTable::Name |
( |
const std::string & |
rName |
) |
[virtual] |
Idx faudes::SymbolTable::Size |
( |
void |
|
) |
|
void faudes::SymbolTable::Clear |
( |
void |
|
) |
[virtual] |
Idx faudes::SymbolTable::MaxIndex |
( |
void |
|
) |
const |
void faudes::SymbolTable::MaxIndex |
( |
Idx |
index |
) |
|
Idx faudes::SymbolTable::LastIndex |
( |
void |
|
) |
const |
std::string faudes::SymbolTable::Symbol |
( |
Idx |
index |
) |
const |
Symbolic name lookup.
- Parameters:
-
- Returns:
- Symbolic name of index, or empty string "" for non-existent index
Definition at line 237 of file 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 228 of file symboltable.cpp.
bool faudes::SymbolTable::Exists |
( |
Idx |
index |
) |
const |
Test existence of index.
- Parameters:
-
- Returns:
- True, if index exists
Definition at line 248 of file 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 254 of file 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 (") and no blanks. The no-quotes-restriction simplifies file io (see tokenreader.h), other restrictions are cosmetic.
- Parameters:
-
| rName | Symbolic name to test |
- Returns:
- True, if name is a valid symbol
Definition at line 84 of file 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 101 of file 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 125 of file 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:
-
Definition at line 157 of file symboltable.cpp.
void faudes::SymbolTable::SetEntry |
( |
Idx |
index, |
|
|
const std::string & |
rName | |
|
) |
| | |
Set symbolic name for existing entry.
If the name is the emptystring, the 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 165 of file 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 186 of file symboltable.cpp.
void faudes::SymbolTable::ClrEntry |
( |
Idx |
index |
) |
|
void faudes::SymbolTable::ClrEntry |
( |
const std::string & |
rName |
) |
|
Delete entry by symbol.
- Parameters:
-
| rName | Symbolic name to delete |
Definition at line 205 of file symboltable.cpp.
void faudes::SymbolTable::RestrictDomain |
( |
const IndexSet & |
rDomain |
) |
|
Restrict to specified indicees.
- Parameters:
-
| rDomain | Indicees to keep. |
Definition at line 213 of file symboltable.cpp.
SymbolTable * faudes::SymbolTable::GlobalEventSymbolTablep |
( |
void |
|
) |
[static] |
void faudes::SymbolTable::DoRead |
( |
TokenReader & |
rTr, |
|
|
const std::string & |
rLabel = "" , |
|
|
const Type * |
pContext = 0 | |
|
) |
| | [private, virtual] |
void faudes::SymbolTable::DoWrite |
( |
TokenWriter & |
rTw, |
|
|
const std::string & |
rLabel = "" , |
|
|
const Type * |
pContext = 0 | |
|
) |
| | const [private, virtual] |
Member Data Documentation
The documentation for this class was generated from the following files:
|