|
Boost : |
Subject: [boost] Answers re BENUM library for automated enum streaming
From: Tony D (tony_in_da_uk_at_[hidden])
Date: 2008-09-15 18:17:37
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)
- smart enums requires user-maintained "meta-data" - from the smart enum docs:
bool init = (::EnumIO<Foo>::the() (Bar, "bar") (Baz, "baz")), true;
- BENUM supports optional mark-up mixed in with the enumerations to capture use of bit masking, guiding conversion to/from pipe-separated identifiers
- BENUM supports many optional "features" including bitwise operations,
incrementing and arithmetic operations, while smart-enums supports
arithmetic and increment
- both provide iteration over enumerations
- smart enums supports automated range checking, with handling via throw, wrap, modulo
The benum.test.cpp file shows a very complex example usage highlighting the features. Sorry for not working in to it gently. Note that all that extra mark-up etc. is optional and not needed by simple enumerations without bit masking/ORing etc..
Regards,
Tony
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk