cEnum Class Reference
[Internal classes]

Provides string representation for enums. More...

#include <cenum.h>

Inheritance diagram for cEnum:
cOwnedObject cNamedObject cObject

List of all members.

Public Member Functions

std::string str () const
Constructors, destructor, assignment.

 cEnum (const char *name=NULL)
 cEnum (const char *name, const char *str,...)
 cEnum (const cEnum &cenum)
virtual ~cEnum ()
cEnumoperator= (const cEnum &list)
Redefined cObject member functions.

virtual cEnumdup () const
virtual std::string info () const
Insertion and lookup.

void insert (int value, const char *name)
const char * getStringFor (int value)
int lookup (const char *name, int fallback=-1)

Static Public Member Functions

static cEnumfind (const char *name)
static cEnumget (const char *name)

Detailed Description

Provides string representation for enums.

The class basically implements effective integer-to-string and string-to-integer mapping. Primary usage is to support displaying symbolic names for integer values that represent some code (such as an enum or #define).


Constructor & Destructor Documentation

cEnum::cEnum ( const char *  name,
const char *  str,
  ... 
)

FIXME document properly: arglist: (enumname, string1, value1, string2, value2, .

.., NULL)

Example:

 enum State { IDLE=0, BUSY };
 cEnum stateEnum("state", "IDLE", IDLE, "BUSY", BUSY, NULL);
 

Member Function Documentation

virtual cEnum* cEnum::dup (  )  const [inline, virtual]

Creates and returns an exact copy of this object.

See cObject for more details.

Reimplemented from cObject.

static cEnum* cEnum::find ( const char *  name  )  [static]

Finds a registered enum by name.

Returns NULL if not found.

static cEnum* cEnum::get ( const char *  name  )  [static]

Returns the enum with the given name.

Throws an error if not found.

const char* cEnum::getStringFor ( int  value  ) 

Look up value and return string representation.

Return NULL if not found.

virtual std::string cEnum::info (  )  const [virtual]

Produces a one-line description of the object's contents.

See cObject for more details.

Reimplemented from cObject.

void cEnum::insert ( int  value,
const char *  name 
)

Add an item to the enum.

If that numeric code exist, overwrite it.

int cEnum::lookup ( const char *  name,
int  fallback = -1 
)

Look up string and return numeric code.

If not found, return second argument (or -1).

cEnum& cEnum::operator= ( const cEnum list  ) 

Assignment operator.

The name member is not copied; see cOwnedObject's operator=() for more details.


The documentation for this class was generated from the following file:
Generated on Tue Dec 2 11:16:28 2014 for OMNeT++ Simulation Library by  doxygen 1.6.3