Boost logo

Boost :

Subject: Re: [boost] Answers re BENUM library for automated enum streaming
From: Marcus Lindblom (macke_at_[hidden])
Date: 2008-09-16 05:50:28


Tony D wrote:
> Hi all,
>
> Markus: apologies for not including the full URL. The file is benum_v1.zip at http://www.boostpro.com/vault/
>
> Full URL is hhttp://www.boostpro.com/vault/index.php?action=downloadfile&filename=benum_v1.zip&directory=&PHPSESSID=b088ed5a443221683e910543098c9107 - note Google Chrome mistakes it for a query, but the vault CGI doesn't seem to cope with %3D/%26 encoding of = and &.
>
> Thorsten / Marcus: roughly comparing to smart enum proposal:
> - BENUM _automates_ conversions based on stringified source code,
> which (postulating an extra macro "BENUM" hard-coding your favourite
> selection of meta-data container and optional features) allows
> BENUM(X, A = 1, B, C = 22, D = B|N);
> to approximate
> enum X { A = 1, B, C = 22, D = B|N };
> and needs no further code to be streamable etc (preprocessor macros allow
> run-time cross-referencing of stringified source code with array of actual values)

Neat!

However, is it possible to define a separate mapping if one would like?

For instance, I like my strings to be lower case, and without prefixes,
whereas my enums need a bit more scaffolding:

enum Context { CXT_APP, CXT_PHYS, CXT_VIS }
enum Aspect { ASP_APP, ASP_PHYS}
CXT_APP = "app", CXT_PHYS = "phys", etc.
ASP_APP = "app", ASP_PHYS = "phys", etc.

> - smart enums requires user-maintained "meta-data" - from the smart enum docs:
> bool init = (::EnumIO<Foo>::the() (Bar, "bar") (Baz, "baz")), true;

EnumIO only does that, and it hides the usage of EnumIO<> from the
header file, thus it is very lean and efficient.

How much extra template code is instantiated in each source file
including BENUM-use?

Cheers,
/Marcus


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk