Boost logo

Boost Users :

From: Andrew Schweitzer (a.schweitzer.grps_at_[hidden])
Date: 2006-09-04 11:12:03


I have done very little searching, but it seemed worth just asking...
sorry if this is newsgroup pollution:

Does anyone have a favored way to convert large enums into stings
suitable for printing?

For example, we have an enum declared:

enum eFurniture
{
eOT_chair = 1,
eOT_stool =2,
eOT_sofa =3,
...
eOT_lounger = 1000,
};

It would be really nice if there were a programmatic way to do something
like:

STRINGED_ENUM(eFurniture)
        E_STRING(eOT_chair, 1)
        E_STRING(eOT_stool, 2)
        E_STRING(eOT_sofa, 3)
        ...
        E_STRING(eOT_lounger, 1000)

and then there would be a programmatic way to get both the enum and the
string, such as

eFurniture eTheAntique = eOT_stool;
//and then...
char* szTheAntique[128];
GetEnumString<eObjectTypes>(eTheAntique, szTheAntique);
printf("the antique is %s\n", szTheAntique);

//or maybe...
char* szTheAntique = eFurniture_STRING_TABLE[eTheAntique];

Any recomendations?

Thanks,
Andy.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net