Shadowrun: Awakened 29 September 2011 - Build 871
Public Member Functions | Protected Attributes
Dictionary< Key, Value > Class Template Reference

#include <Dictionary.h>

Inheritance diagram for Dictionary< Key, Value >:

List of all members.

Public Member Functions

__inline Value getDefaultValue () const
__inline Value getSafe (Key id) const
__inline bool has (Key id) const
__inline void remove (Key id)
__inline void setDefaultValue (Value val)

Protected Attributes

Value _defaultValue

Detailed Description

template<class Key, class Value>
class Dictionary< Key, Value >

This class extends std::map by adding a few utility functions

Definition at line 11 of file Dictionary.h.


Member Function Documentation

template<class Key, class Value>
__inline Value Dictionary< Key, Value >::getDefaultValue ( ) const [inline]

Definition at line 17 of file Dictionary.h.

{
template<class Key, class Value>
__inline Value Dictionary< Key, Value >::getSafe ( Key  id) const [inline]

Returns the value associated with the given key If the key is not found, the default value for this dictionary is returned

Definition at line 24 of file Dictionary.h.

Referenced by Support::Stopwatch::AccumulateTime(), and SraData::DbStream::RetrieveStream().

    {
        std::map<Key, Value>::const_iterator iter = find(id);
        if(iter == end())
            return _defaultValue;
        else
            return iter->second;
    }
template<class Key, class Value>
__inline bool Dictionary< Key, Value >::has ( Key  id) const [inline]

Returns true if this object contains an entry with the given ID

Definition at line 36 of file Dictionary.h.

    {
        std::map<Key, Value>::const_iterator iter = find(id);
        if(iter == end())
            return false;
        else
            return true;
    }
template<class Key, class Value>
__inline void Dictionary< Key, Value >::remove ( Key  id) [inline]

If an entry associated with the given key is in this dictionary it is deleted

Definition at line 49 of file Dictionary.h.

Referenced by SraData::DbStream::CheckHasMoreRows().

    {
        std::map<Key, Value>::iterator iter = find(id);
        if(iter != end())
            erase(iter);
    }
template<class Key, class Value>
__inline void Dictionary< Key, Value >::setDefaultValue ( Value  val) [inline]

Definition at line 18 of file Dictionary.h.

{

Member Data Documentation

template<class Key, class Value>
Value Dictionary< Key, Value >::_defaultValue [protected]

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

Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.

GNU Lesser General Public License 3 Sourceforge.net