bit::SymbolMap< S, I > Class Template Reference

An enumerated map of symbols. More...

#include <SymbolMap.hh>

List of all members.

Public Member Functions

 SymbolMap ()
void write (FILE *file) const
 Write symbol map in a file assuming that S = std::string.
void read (FILE *file)
 Read symbol map from a file assuming that S = std::string.
insert_dummy (const S &symbol=S())
 Insert a dummy index that does not have any mapping from symbol to index.
insert (const S &symbol)
 Insert a symbol to the map but only if it does not exist yet.
insert_new (const S &symbol)
 Insert a symbol to the map raising an error if the symbol exists already.
index (const S &symbol) const
 Return the index of the symbol raising an error if the symbol does not exist.
index_nothrow (const S &symbol) const
 Return the index of the symbol returning negative if symbol does not exist.
const S & at (I index) const
 Return the symbol with the given index.
S & at (I index)
 Return the symbol with the given index.
size () const
 Return the size of the map.

Private Types

typedef std::map< S, I > Map

Private Attributes

std::vector< S > m_symbols
 Symbols in the map.
Map m_indices
 Indices of the symbols.


Detailed Description

template<typename S, typename I>
class bit::SymbolMap< S, I >

An enumerated map of symbols.


Member Typedef Documentation

template<typename S, typename I>
typedef std::map<S, I> bit::SymbolMap< S, I >::Map [private]
 


Constructor & Destructor Documentation

template<typename S, typename I>
bit::SymbolMap< S, I >::SymbolMap  )  [inline]
 


Member Function Documentation

template<typename S, typename I>
S& bit::SymbolMap< S, I >::at index  )  [inline]
 

Return the symbol with the given index.

template<typename S, typename I>
const S& bit::SymbolMap< S, I >::at index  )  const [inline]
 

Return the symbol with the given index.

template<typename S, typename I>
I bit::SymbolMap< S, I >::index const S &  symbol  )  const [inline]
 

Return the index of the symbol raising an error if the symbol does not exist.

template<typename S, typename I>
I bit::SymbolMap< S, I >::index_nothrow const S &  symbol  )  const [inline]
 

Return the index of the symbol returning negative if symbol does not exist.

template<typename S, typename I>
I bit::SymbolMap< S, I >::insert const S &  symbol  )  [inline]
 

Insert a symbol to the map but only if it does not exist yet.

Use insert_new() if reinsert should raise error.

Parameters:
symbol = symbol to insert
Returns:
the index of the inserted or existing symbol

template<typename S, typename I>
I bit::SymbolMap< S, I >::insert_dummy const S &  symbol = S()  )  [inline]
 

Insert a dummy index that does not have any mapping from symbol to index.

template<typename S, typename I>
I bit::SymbolMap< S, I >::insert_new const S &  symbol  )  [inline]
 

Insert a symbol to the map raising an error if the symbol exists already.

Parameters:
symbol = symbol to insert
Returns:
the index of the inserted symbol

template<typename S, typename I>
void bit::SymbolMap< S, I >::read FILE *  file  )  [inline]
 

Read symbol map from a file assuming that S = std::string.

Exceptions:
std::string if fails

template<typename S, typename I>
I bit::SymbolMap< S, I >::size  )  const [inline]
 

Return the size of the map.

template<typename S, typename I>
void bit::SymbolMap< S, I >::write FILE *  file  )  const [inline]
 

Write symbol map in a file assuming that S = std::string.


Member Data Documentation

template<typename S, typename I>
Map bit::SymbolMap< S, I >::m_indices [private]
 

Indices of the symbols.

template<typename S, typename I>
std::vector<S> bit::SymbolMap< S, I >::m_symbols [private]
 

Symbols in the map.


The documentation for this class was generated from the following file:
Generated on Mon Jan 8 15:51:04 2007 for bit by  doxygen 1.4.6