I've required this functionality several times for debugging/analyzing code from others.
For this, I've written a Perl script which generates a class with several overloaded toString
methods. Each toString
method takes an Enum
as an argument and returns const char*
.
Of course, the script doesn't parse C++ for enums itself, but uses ctags for generating symbol table.
The Perl script is here: http://heinitz-it.de/download/enum2string/enum2string.pl.html