Enum Class Reference

An object-oriented enumerator class which uses QStrings instead of compiler symbols, and provides bidirectional mapping between QStrings and int values. More...

#include <enum.h>

Inheritance diagram for Enum:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 Enum (int enumval=0)
 Enum (const Enum &other)
virtual ~Enum ()
virtual QString toString () const
 Converts from the int value to a String.
virtual bool fromString (QString str)
 Converts from a string to the internal enum value.
virtual int intValue () const
bool operator= (int other)
bool operator= (QString other)
bool operator== (const Enum &other) const
bool operator!= (const Enum &other) const
bool operator< (const Enum &other) const
bool operator> (const Enum &other) const
QStringList names () const
 
Returns:
an ordered list of symbols

virtual const NameMap & nameMap () const=0
 
Returns:
a mapping of names to values


Static Protected Member Functions

static NameMap & initMap (NameMap &nameMap, QStringList nameList, bool &initialized, int startIndex=0)
 Adds symbols to the map with enum values starting at 0.

Protected Attributes

int m_Val

Detailed Description

An object-oriented enumerator class which uses QStrings instead of compiler symbols, and provides bidirectional mapping between QStrings and int values.

No compiler symbols are introduced.

Definition at line 19 of file enum.h.


Member Function Documentation

bool Enum::fromString ( QString  str  )  [virtual]

Converts from a string to the internal enum value.

returns false if an invalid string is passed in.

Definition at line 32 of file enum.cpp.

References m_Val, and nameMap().

Referenced by CustomerType::CustomerType(), operator=(), and Customer::setTypeString().

Here is the call graph for this function:

NameMap & Enum::initMap ( NameMap &  nameMap,
QStringList  nameList,
bool &  initialized,
int  startIndex = 0 
) [static, protected]

Adds symbols to the map with enum values starting at 0.

Parameters:
nameMap - the destination map to contain strings to numbers
nameList - a string list of names to add to the map, with optional =value suffixes
initialized - if true, do nothing (to avoid repeat-redundant calls
  • if false, set to true after initializing.

Definition at line 86 of file enum.cpp.

Referenced by CustomerType::nameMap().


The documentation for this class was generated from the following files:
Generated on Wed Sep 30 01:15:44 2009 for oopapidocs by  doxygen 1.5.1