NOTE: This project is new. The code generator is fully functional and feature rich, now fully unit tested. The implementation of the generated interface is now complete as well. Feel free to take a look by downloading the code from subversion (click the Source link) if you'd like and giving it a try. Feedback welcome.
It's easier to show examples than to write documentation (but it's coming). Here's an example where Fruit.enum is the input, and Fruit.hpp, Fruit.ipp, and Fruit.cpp are generated as a result. http://code.google.com/p/enumgen/source/browse/#svn/trunk/demo
If you're a C++ programmer, I hope you find this useful, and recognize the amount of effort put into generating clean and efficient C++ code.
C++ classes have desirable properties that regular enum types do not yet(*) have. Some of the benefits class hold over raw enums are are:
classes are forward-declarable, enums are not. (yet) classes can prevent implicit conversions to ints classes can have member functions and are generally extensible, enums are not. Therefore I created a code-gen tool which reads a simple input file and generates a complete C++ class (header/implementation files) for you to include in your projects and use directly instead of regular enums.
user provided code can extend the generated class interface a fairly extensive introspection interface for the generated code to query the enumerator names, values, and aliases ability to create enum objects out of strings that spell their name or one of their aliases ability to ask an enum object for a string representation of its enum value The code generator itself is written in Common Lisp. Currently I've tested with CLISP, SBCL, and ECL, but it should be simple enough to get working elsewhere. You'll need to install a CL implementation to generate C++ code, however, once you generate your C++ source files, they can be compiled into your C++ project without the need for a lisp environment whatsoever. There is absolutely no dependency on lisp except to run the code generator itself.
(*) I'm aware of the future C++0x standard and new strongly-typed, forward-declarable enums. However that will only help improve this generated code, and does not obviate it. One reason is the ability to have MEMBER FUNCTIONS of an enum is still not on the table. I plan to make heavy use of these new enum functions as the new standard implementations become available and widespread.
Copyright © 2013 Black Duck Software, Inc. and its contributors, Some Rights Reserved. Unless otherwise marked, this work is licensed under a Creative Commons Attribution 3.0 Unported License . Ohloh ® and the Ohloh logo are trademarks of Black Duck Software, Inc. in the United States and/or other jurisdictions. All other trademarks are the property of their respective holders.