ML Reference
ml::EnumField Class Reference

Field to encapsulate an enumerated value. More...

#include <mlFields.h>

Inheritance diagram for ml::EnumField:
ml::Field

List of all members.

Public Member Functions

 EnumField ()
 Default contructor, do not call it.
 EnumField (const std::string &name)
 Default contructor, do not call it.
 EnumField (const std::string &name, const std::string enumerationItemNames[], size_t numEnumerationItems)
 Constructor, creates a field with a name to manage an enum value.
 EnumField (const std::string &name, const char *const *enumerationItemNames, size_t numEnumerationItems)
 Constructor, creates a field with a name to manage an enum value.
 EnumField (const std::string &name, const std::vector< std::string > &enumerationItemNames)
 Constructor, creates a field with a name to manage an enum value.
virtual ~EnumField ()
 Destroys this field and releases internally allocated memory.
void setStringValue (const std::string &value)
 Sets value of the field to the enum item with given name value.
void setStringValueDefaulted (const std::string &value, int defaultItem)
 If value equals one of the enum item names, set the field to this item, otherwise set it to defaultItem.
void setEnumValue (int index)
 Sets field value to index.
std::string getStringValue () const
 Returns the value of the field as string value.
const char * getStringValue (size_t index) const
 Returns the value at index of the field as a string value.
int getEnumValue () const
 Returns the current enum value as integer.
size_t getNumEnumerationItems () const
 Returns the number of registered enum values defined in constructor.
virtual MLint isValidValue ()
 Returns 1 if field is valid, otherwise 0.
Deprecated
size_t getEnumNum () const
 EnumField (const std::string &name, const std::string enumNames[], size_t enumNum, int *valuePtr)
 EnumField (const std::string &name, const char *const *enumNames, size_t enumNum, int *valuePtr)

Detailed Description

Field to encapsulate an enumerated value.

Definition at line 338 of file mlFields.h.


Constructor & Destructor Documentation

ml::EnumField::EnumField ( )

Default contructor, do not call it.

ml::EnumField::EnumField ( const std::string &  name)

Default contructor, do not call it.

ml::EnumField::EnumField ( const std::string &  name,
const std::string  enumerationItemNames[],
size_t  numEnumerationItems 
)

Constructor, creates a field with a name to manage an enum value.

The value range for the enum value is [0, numEnumerationItems-1]. The value names are defined by enumerationItemNames. The maximum number of enum entries is ML_INT32_MAX, minimum is 1; exceeding that will lead to fatal errors, even on 64 bit systems. Note that enumerationItemNames must contain at least numEnumerationItems string values.

ml::EnumField::EnumField ( const std::string &  name,
const char *const *  enumerationItemNames,
size_t  numEnumerationItems 
)

Constructor, creates a field with a name to manage an enum value.

The value range for the enum value is [0, numEnumerationItems-1]. The value names are defined by enumerationItemNames. The maximum number of enum entries is ML_INT32_MAX, minimum is 1; exceeding that will lead to fatal errors, even on 64 bit systems. Note that enumerationItemNames must contain at least numEnumerationItems string values.

ml::EnumField::EnumField ( const std::string &  name,
const std::vector< std::string > &  enumerationItemNames 
)

Constructor, creates a field with a name to manage an enum value.

The field creates the value buffer internally. The value range for the enum value is [0, enumerationItemNames.size-1]. The value names are defined by enumerationItemNames. The maximum number of enum entries is ML_INT32_MAX, minimum is 1; exceeding that will lead to fatal errors, even on 64 bit systems. The default enum value is 0.

virtual ml::EnumField::~EnumField ( ) [virtual]

Destroys this field and releases internally allocated memory.

ml::EnumField::EnumField ( const std::string &  name,
const std::string  enumNames[],
size_t  enumNum,
int *  valuePtr 
)
ml::EnumField::EnumField ( const std::string &  name,
const char *const *  enumNames,
size_t  enumNum,
int *  valuePtr 
)

Member Function Documentation

size_t ml::EnumField::getEnumNum ( ) const [inline]
Deprecated:
Use getNumEnumerationItems() instead.

Definition at line 448 of file mlFields.h.

int ml::EnumField::getEnumValue ( ) const

Returns the current enum value as integer.

size_t ml::EnumField::getNumEnumerationItems ( ) const

Returns the number of registered enum values defined in constructor.

const char* ml::EnumField::getStringValue ( size_t  index) const

Returns the value at index of the field as a string value.

setStringValue must be able to interpret this returned string correctly. Setting strings to invalid indexes will lead to fatal errors.

std::string ml::EnumField::getStringValue ( ) const [virtual]

Returns the value of the field as string value.

setStringValue must be able to interpret this returned string correctly. On invalid enumValues the first string item is returned.

Implements ml::Field.

virtual MLint ml::EnumField::isValidValue ( ) [virtual]

Returns 1 if field is valid, otherwise 0.

Reimplemented from ml::Field.

void ml::EnumField::setEnumValue ( int  index)

Sets field value to index.

void ml::EnumField::setStringValue ( const std::string &  value) [virtual]

Sets value of the field to the enum item with given name value.

If the value enum item is not found, the call is ignored. The comparison is done case-sensitive.

Implements ml::Field.

void ml::EnumField::setStringValueDefaulted ( const std::string &  value,
int  defaultItem 
)

If value equals one of the enum item names, set the field to this item, otherwise set it to defaultItem.


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