To handle the #if statements below, I decided to explore a different route.
If I pass the enum's as strings as Robert suggests, I can avoid the issue.
It provides a higher level of backwards compatibility and is slightly easier
to maintain.

I've created some Macros to wrap the enums and generate standard enums and a
string map.  The enums will look like this:

DECLARE_ENUM (myenum)
{
    ENUM_CONST(enum_1)
    ENUM_CONST_NUM(enum_2, 200)
    ENUM_CONST(enum_three)
    ENUM_END
};


The standard enum macros will look like this:
  #define DECLARE_ENUM(x) enum x
  #define ENUM_CONST_NUM(x,n) x = n,
  #define ENUM_CONST(x) x,
  #define ENUM_END


And the string map macros will look like this:
#define DECLARE_ENUM(x) struct enum_strings_##x : std::map<unsigned int,
std::string> { enum_strings_##x ()
#define ENUM_CONST_NUM(x,n) this->operator[]( x ) = # x;
#define ENUM_CONST(x) this->operator[]( x ) = # x;
#define ENUM_END }


Are there are significant objections to this approach?  Is there anyway to
improve it?
If not, I'll continue my slow pace towards Online Tiles in this direction.

--Jeff



> ---------- Forwarded message ----------
> From: Robert Vollmert <rvollmert-li...@gmx.net>
> To: crawl-ref-discuss@lists.sourceforge.net
> Date: Wed, 27 Apr 2011 23:15:26 +0200
> Subject: Re: [Crawl-ref-discuss] Online Tiles - Data Format
>
> On Apr 27, 2011, at 23:12, Jeff Johnson wrote:
> > For example there is this:
> >   #if TAG_MAJOR_VERSION == 32
> >       OBJ_UNKNOWN_I, // (use unknown) labeled as books in invent.cc {dlb}
> >   #endif
>
> The enum value is to be removed, but not until save compatibility is broken
> anyway by bumping TAG_MAJOR_VERSION.
>
> By the way, have you considered serializing these enum values as strings
> (i.e., "unknown_i")?
>
> Cheers
> Robert
>
>
>
>
>
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Crawl-ref-discuss mailing list
Crawl-ref-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/crawl-ref-discuss

Reply via email to