Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   Compound Members  

CEnumDictionary Class Template Reference

Template class that converts string to enum, or enum to strings. More...

#include <EnumDictionary.h>

List of all members.

Public Methods


Detailed Description

template<class Enum, size_t size>
class CEnumDictionary< Enum, size >

Template class that converts string to enum, or enum to strings.

Parameters:
Enum  Enumerated type
size  Value of the last valid entry of the enumerated type
Example:
                // the enum type
                enum MyEnum
                {
                        SomeValue = 1,
                        SomeOtherValue = 2,
                        TheLastValue = 4
                };

                // the strings matching the enum values
                static const SI_Char* g_szMyEnumStrings[] =
                {
                        "SomeValue",
                        "SomeOtherValue",
                        "TheLastValue"
                };

                // The Enum dictionary to convert from enum to string
                // or string to enum
                CEnumDictionary<MyEnum, TheLastValue> l_dict( g_szMyEnumStrings );


Constructor & Destructor Documentation

template<class Enum, size_t size>
CEnumDictionary< Enum, size >::CEnumDictionary SI_Char const **    in_ppStringArray [inline]
 

Constructor.

Parameters:
in_ppStringArray  Array containing the strings.
Warning:
in_ppStringArray is not freed upon destruction.
Example:
                // example of typical in_ppStringArray
                static const SI_Char* g_szMyEnumStrings[] =
                {
                        "SomeValue",
                        "SomeOtherValue",
                        "TheLastValue"
                };


Member Function Documentation

template<class Enum, size_t size>
SI_Bool CEnumDictionary< Enum, size >::ToEnum Enum &    out_rEnum,
const SI_Char *    in_pValue
const [inline]
 

Convert from string to enum.

Parameters:
out_rEnum  Resulting enum value
in_pValue  String value to convert
Return values:
false  There is no matching enum value
true  The matching enum value was found
Example:
                CEnumDictionary<EnumType, LastEnumValue> l_EnumDict(g_szMyEnumStrings);
                EnumType l_EnumValue;
                if (!l_EnumDict.ToEnum(l_EnumValue, "LastEnumValue"))
                {
                        // conversion failed
                }

template<class Enum, size_t size>
const SI_Char* CEnumDictionary< Enum, size >::ToString Enum    in_Value const [inline]
 

Convert from enum to string.

Parameters:
in_Value  Enum value to convert
Returns:
String representation of the enum value
Warning:
The returned string should not be modified
Example:
                CEnumDictionary<EnumType, LastEnumValue> l_EnumDict(g_szMyEnumStrings);
                const SI_Char *l_szStringValue = l_EnumDict.ToString(LastEnumValue);


The documentation for this class was generated from the following file: © Copyright 2001-2003 Avid Technology, Inc. All rights reserved.

© Copyright 2001-2003 Avid Technology, Inc. All rights reserved.