Boost logo

Boost Users :

From: Alan M. Carroll (amc_at_[hidden])
Date: 2006-09-04 20:48:47


I have never found anything better than using a Perl script on the side. I also ended up writing a bijection class, which is like a map except both types are keys, which lets you easily convert from enum to string and vice versa. My Perl script then generates the code to initialize the bijection.

At 10:12 AM 9/4/2006, you wrote:
>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


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