Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Enumeration Class Reference

Class representing an enumeration set. More...

#include <Enum.h>

List of all members.

Public Methods

bool operator== (Enumeration const &e) const
 Equality of Enumerations means sharing the same EnumerationCore.

bool operator!= (Enumeration const &e) const
 Equality of Enumerations means sharing the same EnumerationCore.

 Enumeration (std::string const &s)
 Construct a new Enumeration, creating and binding to a new EnumerationCore.

std::string getToken (int value) const
 Lookup an element's token by its value.

int getValue (std::string const &token) const
 Lookup an element's value by its token.

int size () const
 Get the number of items in the Enumeration set.

std::string __repr__ () const
 Return a string representation of the Enumeration (used by SWIG/Python).

const std::vector< EnumLinkeach () const
 Return an ordered vector of Enums in this Enumeration.

const std::vector< std::string > eachToken () const
 Return an ordered vector of string values in this Enumeration.

const std::vector< int > eachValue () const
 Return an ordered vector of string values in this Enumeration.

const std::vector< EnumLinkrange (EnumLink const &a, EnumLink const &b) const
 Get a list of Enums in the range between two Enums (inclusive).

const std::vector< EnumLinkrange (std::string const &a, std::string const &b) const
 Get a list of Enums in the range between two strings (inclusive).

const std::vector< EnumLinkrange (int a, int b) const
 Get a list of Enums in the range between two values (inclusive).

bool contains (EnumLink const &x) const
 Test for inclusion in the Enumeration set.

bool contains (int value) const
 Test for inclusion in the Enumeration set.

bool contains (std::string const &token) const
 Test for inclusion in the Enumeration set.

EnumLink last () const
 Return the last enum in the Enumeration set.

EnumLink first () const
 Return the first enum in the Enumeration set.

EnumLink operator[] (int value) const
 accessor for lookup by value

EnumLink operator[] (std::string const &token) const
 accessor for lookup by token


Friends

class EnumLink


Detailed Description

Class representing an enumeration set.

A class representing an ordered set of unique items that can be indexed by number or token.

Enumerations are usually created as static const class members, together with Enum<> members that use the static Enumeration as the template argument. For example:

     class Foo {
     public:
         static const Enumeration MyEnumeration;
         Enum<MyEnumeration> MyEnum;
         ...
     };

When defining the Enumeration, specify the items in order as a white-space separated string, as in:

     Enumeration Foo::MyEnumeration("apple orange cherry");


Constructor & Destructor Documentation

Enumeration::Enumeration std::string const &    s [inline]
 

Construct a new Enumeration, creating and binding to a new EnumerationCore.

The enumeration tokens are must be separated by white-space and can have an optional value assignment. Tokens without explicit values will be assigned sequential values following the last specified value. The initial default value is zero.

Examples:

  • "zero one two three"
  • "one=1 two three ten=10 eleven"


Member Function Documentation

std::string Enumeration::__repr__   const [inline]
 

Return a string representation of the Enumeration (used by SWIG/Python).

bool Enumeration::contains std::string const &    token const [inline]
 

Test for inclusion in the Enumeration set.

bool Enumeration::contains int    value const [inline]
 

Test for inclusion in the Enumeration set.

bool Enumeration::contains EnumLink const &    x const [inline]
 

Test for inclusion in the Enumeration set.

const std::vector< EnumLink > Enumeration::each   [inline]
 

Return an ordered vector of Enums in this Enumeration.

const std::vector< std::string > Enumeration::eachToken   [inline]
 

Return an ordered vector of string values in this Enumeration.

const std::vector< int > Enumeration::eachValue   [inline]
 

Return an ordered vector of string values in this Enumeration.

EnumLink Enumeration::first   [inline]
 

Return the first enum in the Enumeration set.

std::string Enumeration::getToken int    value const [inline]
 

Lookup an element's token by its value.

int Enumeration::getValue std::string const &    token const [inline]
 

Lookup an element's value by its token.

EnumLink Enumeration::last   [inline]
 

Return the last enum in the Enumeration set.

bool Enumeration::operator!= Enumeration const &    e const [inline]
 

Equality of Enumerations means sharing the same EnumerationCore.

bool Enumeration::operator== Enumeration const &    e const [inline]
 

Equality of Enumerations means sharing the same EnumerationCore.

EnumLink Enumeration::operator[] std::string const &    token const [inline]
 

accessor for lookup by token

EnumLink Enumeration::operator[] int    value const [inline]
 

accessor for lookup by value

const std::vector< EnumLink > Enumeration::range int    a,
int    b
const [inline]
 

Get a list of Enums in the range between two values (inclusive).

const std::vector< EnumLink > Enumeration::range std::string const &    a,
std::string const &    b
const [inline]
 

Get a list of Enums in the range between two strings (inclusive).

const std::vector< EnumLink > Enumeration::range EnumLink const &    a,
EnumLink const &    b
const [inline]
 

Get a list of Enums in the range between two Enums (inclusive).

int Enumeration::size   const [inline]
 

Get the number of items in the Enumeration set.


Friends And Related Function Documentation

friend class EnumLink [friend]
 


The documentation for this class was generated from the following file:
SimData version pre-0.4.0. For more information on SimData, visit the SimData Homepage.

Generated on Tue Oct 14 12:06:40 2003, using Doxygen 1.2.18.

[SF.net]