Public Member Functions | Private Attributes

Enumeration Class Reference

Implements an extensible enumeration type. More...

#include <Enumeration.h>

List of all members.

Public Member Functions

 Enumeration ()
 ~Enumeration ()
void bind (const std::string &name, int val=-1)
int find (const std::string &name)
const std::string & find (int val)

Private Attributes

std::map< std::string, int > mEnumerators
std::map< int, std::string > mEnumeratorValues
std::string mDefaultString

Detailed Description

Implements an extensible enumeration type.


Constructor & Destructor Documentation

Enumeration::Enumeration (  )  [inline]
Enumeration::~Enumeration (  )  [inline]

Member Function Documentation

void Enumeration::bind ( const std::string &  name,
int  val = -1 
)

Binds a string constant to a numeric value.

Parameters:
name A const reference to a string.
val Integer to use for an ID. Default value of -1 indicates an automatic value assignment.
Note:
Negative values are interpreted as requesting that numeric ID's be automatically generated.
Attempts to assign a string constant to a numeric ID that is already bound will be ignored.
Attempts to add duplicate string constants will be ignored.
const std::string & Enumeration::find ( int  val  ) 

Gets a string constant that's been bound to a numeric ID.

Returns:
Returns the requested string constant or an empty string if not found.
int Enumeration::find ( const std::string &  name  ) 

Gets a numeric ID that's been bound to a string constant.

Returns:
Returns the requested value or -1 if not found.

Member Data Documentation

std::string Enumeration::mDefaultString [private]
std::map<std::string, int> Enumeration::mEnumerators [private]
std::map<int, std::string> Enumeration::mEnumeratorValues [private]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines