Rice  1.5.2
 All Classes Files Functions Variables Typedefs Friends Pages
Public Member Functions | List of all members
Rice::Enum< Enum_T, Enum_Traits > Class Template Reference

A wrapper for enumerated types. More...

#include <Enum.hpp>

Inheritance diagram for Rice::Enum< Enum_T, Enum_Traits >:
Rice::Module_impl< Data_Type< Enum_T >, Enum< Enum_T, Enum_Traits > > Rice::Data_Type< Enum_T > Rice::Module_impl< Base_T, Derived_T >

Public Member Functions

 Enum ()
 Default constructor.
 
 Enum (char const *name, Module module=rb_cObject)
 Construct and initialize.
 
 Enum (Enum const &other)
 Copy constructor.
 
Enumoperator= (Enum const &other)
 Assignment operator.
 
virtual ~Enum ()
 Destructor.
 
Enum< Enum_T, Enum_Traits > & define_value (char const *name, Enum_T value)
 Define a new enum value. More...
 
void swap (Enum &other)
 
- Public Member Functions inherited from Rice::Module_impl< Data_Type< Enum_T >, Enum< Enum_T, Enum_Traits > >
 Module_impl (T const &arg)
 
Enum< Enum_T, Enum_Traits > & add_handler (Functor_T functor)
 Define an exception handler. More...
 
Enum< Enum_T, Enum_Traits > & define_method (Identifier name, Func_T func, Arguments *arguments=0)
 Define an instance method. More...
 
Enum< Enum_T, Enum_Traits > & define_method (Identifier name, Func_T func, Arg const &arg)
 
Enum< Enum_T, Enum_Traits > & define_singleton_method (Identifier name, Func_T func, Arguments *arguments=0)
 Define a singleton method. More...
 
Enum< Enum_T, Enum_Traits > & define_singleton_method (Identifier name, Func_T func, Arg const &arg)
 
Enum< Enum_T, Enum_Traits > & define_module_function (Identifier name, Func_T func, Arguments *arguments=0)
 Define a module function. More...
 
Enum< Enum_T, Enum_Traits > & define_module_function (Identifier name, Func_T func, Arg const &arg)
 
Enum< Enum_T, Enum_Traits > & define_iterator (Iterator_T(T::*begin)(), Iterator_T(T::*end)(), Identifier name="each")
 Define an iterator. More...
 
Enum< Enum_T, Enum_Traits > & include_module (Module const &inc)
 Include a module. More...
 
Enum< Enum_T, Enum_Traits > & const_set (Identifier name, Object value)
 Set a constant. More...
 
Object const_get (Identifier name) const
 Get a constant. More...
 
bool const_defined (Identifier name) const
 Determine whether a constant is defined. More...
 
void remove_const (Identifier name)
 Remove a constant. More...
 
Module define_module (char const *name)
 Define a module under this module. More...
 
Class define_class (char const *name, Object superclass=rb_cObject)
 Define a class under this module. More...
 
Data_Type< T > define_class (char const *name)
 Define a new data class under this module. More...
 
Data_Type< T > define_class (char const *name)
 Define a new data class under this module. More...
 
- Public Member Functions inherited from Rice::Data_Type< Enum_T >
 Data_Type ()
 Default constructor which does not bind. More...
 
 Data_Type (Module const &v)
 Constructor which takes a Module. More...
 
virtual ~Data_Type ()
 Destructor.
 
virtual Data_Typeoperator= (Module const &klass)
 Assignment operator which takes a Module. More...
 
Data_Type< Enum_T > & define_constructor (Constructor_T constructor, Arguments *arguments=0)
 Define a constructor for the class. More...
 
Data_Type< Enum_T > & define_constructor (Constructor_T constructor, Arg const &arg)
 
Data_Type< Enum_T > & define_director ()
 Register a Director class for this class. More...
 
virtual detail::Abstract_Caster * caster () const
 
- Public Member Functions inherited from Rice::Module_impl< Base_T, Derived_T >
template<typename T >
 Module_impl (T const &arg)
 
template<typename Exception_T , typename Functor_T >
Derived_T & add_handler (Functor_T functor)
 Define an exception handler. More...
 
template<typename Func_T >
Derived_T & define_method (Identifier name, Func_T func, Arguments *arguments=0)
 Define an instance method. More...
 
template<typename Func_T >
Derived_T & define_method (Identifier name, Func_T func, Arg const &arg)
 
template<typename Func_T >
Derived_T & define_singleton_method (Identifier name, Func_T func, Arguments *arguments=0)
 Define a singleton method. More...
 
template<typename Func_T >
Derived_T & define_singleton_method (Identifier name, Func_T func, Arg const &arg)
 
template<typename Func_T >
Derived_T & define_module_function (Identifier name, Func_T func, Arguments *arguments=0)
 Define a module function. More...
 
template<typename Func_T >
Derived_T & define_module_function (Identifier name, Func_T func, Arg const &arg)
 
template<typename T , typename Iterator_T >
Derived_T & define_iterator (Iterator_T(T::*begin)(), Iterator_T(T::*end)(), Identifier name="each")
 Define an iterator. More...
 
Derived_T & include_module (Module const &inc)
 Include a module. More...
 
Derived_T & const_set (Identifier name, Object value)
 Set a constant. More...
 
Object const_get (Identifier name) const
 Get a constant. More...
 
bool const_defined (Identifier name) const
 Determine whether a constant is defined. More...
 
void remove_const (Identifier name)
 Remove a constant. More...
 
Module define_module (char const *name)
 Define a module under this module. More...
 
Class define_class (char const *name, Object superclass=rb_cObject)
 Define a class under this module. More...
 
template<typename T >
Data_Type< T > define_class (char const *name)
 Define a new data class under this module. More...
 
template<typename T , typename T_Base_T >
Data_Type< T > define_class (char const *name)
 Define a new data class under this module. More...
 

Additional Inherited Members

- Public Types inherited from Rice::Data_Type< Enum_T >
typedef Enum_T Type
 The C++ type being held.
 
- Static Public Member Functions inherited from Rice::Data_Type< Enum_T >
static Module klass ()
 Explictly return the Ruby type. More...
 
static Enum_T * from_ruby (Object x)
 Convert ruby object x to type T. More...
 
static bool is_bound ()
 Determine if the type is bound. More...
 
- Static Public Attributes inherited from Rice::Data_Type< Enum_T >
static std::auto_ptr
< detail::Abstract_Caster > 
caster_
 
- Static Protected Member Functions inherited from Rice::Data_Type< Enum_T >
static Data_Type bind (Module const &klass)
 Bind a Data_Type to a VALUE. More...
 

Detailed Description

template<typename Enum_T, typename Enum_Traits = Default_Enum_Traits<Enum_T>>
class Rice::Enum< Enum_T, Enum_Traits >

A wrapper for enumerated types.

Provides a simple type-safe wrapper for enumerated types. At the ruby level, the class will have convenience methods for iterating over all the defined enum values, converting the values to strings, and more.

Parameters
Enum_Tthe enumerated type
Enum_Traitsspecifies the traits of the enumerated type.

Example:

* enum Color { Red, Green, Blue };
* Enum<Color> rb_cColor = define_enum<Color>("Color")
* .define_value("Red", Red)
* .define_value("Green", Green)
* .define_value("Blue", Blue);
*
Examples:
enum/sample_enum.cpp.

Member Function Documentation

template<typename Enum_T, typename Enum_Traits = Default_Enum_Traits<Enum_T>>
Enum<Enum_T, Enum_Traits>& Rice::Enum< Enum_T, Enum_Traits >::define_value ( char const *  name,
Enum_T  value 
)

Define a new enum value.

Parameters
namethe name of the enum value.
valuethe value to associate with name.
Returns
*this

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