CppUnit project page CppUnit home page

enum2string.h

Go to the documentation of this file.
00001 
00016 #if defined( CPPTL_ENUM_DECL )
00017 
00018 # define CPPTL_ENUM_TYPE( EnumType ) \
00019    enum EnumType {
00020 
00021 # define CPPTL_ENUM( name ) \
00022    name,
00023 
00024 # define CPPTL_ENUM_ASSIGN( name, value ) \
00025    name = value,
00026 
00027 // Declares the enum type and its values
00028 CPPTL_ENUM_DECL
00029    cpptl_dummy_enum_value
00030 };
00031 
00032 # undef CPPTL_ENUM_TYPE
00033 # undef CPPTL_ENUM
00034 # undef CPPTL_ENUM_ASSIGN
00035 
00036 # define CPPTL_ENUM_TYPE( EnumType )                           \
00037    inline const char *toString( EnumType cpptl_enum_value_ ) { \
00038       switch ( cpptl_enum_value_ ) {                           \
00039 
00040 # define CPPTL_ENUM( name )  \
00041    case name: return #name; \
00042 
00043 # define CPPTL_ENUM_ASSIGN( name, value ) \
00044    CPPTL_ENUM( name )
00045 
00046 // Dclares toString() function for the EnumType
00047 CPPTL_ENUM_DECL
00048       default:
00049          return "<invalid enum value>";
00050       }
00051    }
00052 
00053 # undef CPPTL_ENUM_TYPE
00054 # undef CPPTL_ENUM
00055 # undef CPPTL_ENUM_ASSIGN
00056 # undef CPPTL_ENUM_DECL
00057 
00058 #endif // #if defined( CPPTL_ENUM_DECL )

SourceForge Logo hosts this site. Send comments to:
CppUnit Developers