oopapidocs  2.0
Enum Class Reference

An object-oriented enumerator class. More...

#include <enum.h>

Inheritance diagram for Enum:

List of all members.

Public Member Functions

virtual const NameMap & nameMap () const =0
 You must override this method for your specific enumerator type.
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
QStringList names () const

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.

Detailed Description

An object-oriented enumerator class.

This enum uses QStrings instead of compiler symbols, and provides bidirectional mapping between QStrings and int values. No compiler symbols are introduced.

Does not have the same limitation as QMetaEnum, which must be attached to a particular Q_OBJECT class.

This is an abstract class, and derived types can be used as custom QVariant property types provided they are declared and registered also.

Definition at line 26 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 nameMap().

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 112 of file enum.cpp.

References nameMap().

Referenced by Preference::nameMap().

Here is the call graph for this function:

int Enum::intValue ( ) const [virtual]
Returns:
integer equivalent of this enumerated value

Definition at line 70 of file enum.cpp.

virtual const NameMap& Enum::nameMap ( ) const [pure virtual]

You must override this method for your specific enumerator type.

Returns:
a QMap<QString, int>

Implemented in Preference.

Referenced by fromString(), initMap(), names(), and toString().

QStringList Enum::names ( ) const
Returns:
an ordered list of symbols

Definition at line 23 of file enum.cpp.

References nameMap().

Here is the call graph for this function:


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Enumerations