I am having a file of strings by which I want to create an enum with values named by the strings. For example the list is:
"a" "b" "c" "d" ...
I would like to get an enum like this
enum SomeEnum { a, b, c, d };
Thanks.
I am having a file of strings by which I want to create an enum with values named by the strings. For example the list is:
"a" "b" "c" "d" ...
I would like to get an enum like this
enum SomeEnum { a, b, c, d };
Thanks.
I suggest that you use any of the popular scripting languages (perl, python, tcl) and parse the file and generate enums that you like.
You could use X-Macros, then you only need to place your enum/string in the myfile.h.  
#ifndef ENUM_CONVERT
#define ENUM_CONVERT(val)  val
#define ENUM_HEADER enum SomeEnum
#endif
ENUM_HEADER
{
ENUM_CONVERT(a),
ENUM_CONVERT(b),
ENUM_CONVERT(c),
ENUM_CONVERT(d)
};
#include "myFile.h"  // This declares the enum
#define MKSTR(a)           #a
#define ENUM_CONVERT(val)  MKSTR(val)
#define ENUM_HEADER        char *myStrList[]=
#include "myFile.h"  // This defines the stringList
