Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r70209 - sandbox/enums/boost/enums/scoped
From: vicente.botet_at_[hidden]
Date: 2011-03-19 15:58:18


Author: viboes
Date: 2011-03-19 15:58:17 EDT (Sat, 19 Mar 2011)
New Revision: 70209
URL: http://svn.boost.org/trac/boost/changeset/70209

Log:
Enums: Addednamespace aware macros
Text files modified:
   sandbox/enums/boost/enums/scoped/emulation.hpp | 84 ++++++++++++++++++++++++++++++++++++++++
   1 files changed, 84 insertions(+), 0 deletions(-)

Modified: sandbox/enums/boost/enums/scoped/emulation.hpp
==============================================================================
--- sandbox/enums/boost/enums/scoped/emulation.hpp (original)
+++ sandbox/enums/boost/enums/scoped/emulation.hpp 2011-03-19 15:58:17 EDT (Sat, 19 Mar 2011)
@@ -23,10 +23,55 @@
 #include <boost/conversion/convert_to.hpp>
 #include <boost/preprocessor/if.hpp>
 #include <boost/preprocessor/empty.hpp>
+#include <boost/preprocessor.hpp>
 #include <boost/enums/config.hpp>
 
 #ifndef BOOST_ENUMS_DOXYGEN_INVOKED
 
+// macro to get the namespace par of a sequence (NS1) ... (NSn) (ENUM)
+// returns (NS1) ... (NSn)
+
+#define BOOST_ENUMS_DETAIL_NAMESPACE_SEQ(SEQ) \
+ BOOST_PP_SEQ_POP_BACK(SEQ)
+
+
+// macro to get the namespace par of a sequence (NS1) ... (NSn) (ENUM)
+// returns ENUM
+
+#define BOOST_ENUMS_DETAIL_ENUM(SEQ) \
+ BOOST_PP_SEQ_ELEM(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(SEQ)), SEQ)
+
+// macro to generate the following code from a sequence (NS1) ... (NSn)
+// namespace NS1 {
+// ...
+// namespace NSn {
+
+#define BOOST_ENUMS_DETAIL_NAMESPACE_OPEN_(r, data, elem) namespace elem {
+
+#define BOOST_ENUMS_DETAIL_NAMESPACE_OPEN(SEQ) \
+ BOOST_PP_SEQ_FOR_EACH(BOOST_ENUMS_DETAIL_NAMESPACE_OPEN_, ~, SEQ)
+
+
+// macro to generate the following code from a sequence (NS1) ... (NSn)
+// }
+// ...
+// }
+
+#define BOOST_ENUMS_DETAIL_NAMESPACE_CLOSE_(r, data, elem) }
+#define BOOST_ENUMS_DETAIL_NAMESPACE_CLOSE(SEQ) \
+ BOOST_PP_SEQ_FOR_EACH(BOOST_ENUMS_DETAIL_NAMESPACE_CLOSE_, ~, SEQ)
+
+// macro to generate the following code from a sequence (NS1) ... (NSn)
+// NS1::...NSn::
+
+#define BOOST_ENUMS_DETAIL_NAMESPACE_(r, data, elem) elem ::
+#define BOOST_ENUMS_DETAIL_NAMESPACE(SEQ) \
+BOOST_PP_SEQ_FOR_EACH(BOOST_ENUMS_DETAIL_NAMESPACE_, ~, SEQ)
+
+#define BOOST_ENUMS_DETAIL_CLASS(SEQ) \
+ BOOST_ENUMS_DETAIL_NAMESPACE(BOOST_ENUMS_DETAIL_NAMESPACE_SEQ(SEQ)) BOOST_ENUMS_DETAIL_ENUM(SEQ)
+
+
 #ifndef BOOST_NO_SCOPED_ENUMS
     #define BOOST_ENUMS_DETAIL_BINARY_OPERATOR(EC, UT, OP) \
       inline BOOST_CONSTEXPR bool operator OP(EC lhs, EC rhs) { \
@@ -312,6 +357,45 @@
     BOOST_ENUMS_DETAIL_SCOPING_TYPE_SPEC(EC) \
     BOOST_ENUMS_DETAIL_IS_ENUM_TYPE_SPEC(EC)
 
+#define BOOST_ENUM_NS_CLASS_START(NS_EC, UT) \
+ BOOST_ENUMS_DETAIL_NAMESPACE_OPEN(BOOST_ENUMS_DETAIL_NAMESPACE_SEQ(NS_EC)) \
+ BOOST_ENUM_CLASS_START(BOOST_ENUMS_DETAIL_ENUM(NS_EC), UT)
+
+#define BOOST_ENUM_NS_TYPE_START(NS_EC, UT) \
+ BOOST_ENUMS_DETAIL_NAMESPACE_OPEN(BOOST_ENUMS_DETAIL_NAMESPACE_SEQ(NS_EC)) \
+ BOOST_ENUM_TYPE_START(BOOST_ENUMS_DETAIL_ENUM(NS_EC), UT)
+
+#define BOOST_ENUM_NS_CLASS_END(NS_EC, UT) \
+ BOOST_ENUM_CLASS_END(BOOST_ENUMS_DETAIL_ENUM(NS_EC), UT) \
+ BOOST_ENUMS_DETAIL_NAMESPACE_CLOSE(BOOST_ENUMS_DETAIL_NAMESPACE_SEQ(NS_EC)) \
+ BOOST_ENUMS_SPECIALIZATIONS(BOOST_ENUMS_DETAIL_CLASS(NS_EC), UT)
+
+
+#define BOOST_ENUM_NS_TYPE_END(NS_EC, UT) \
+ BOOST_ENUM_TYPE_END(BOOST_ENUMS_DETAIL_ENUM(NS_EC), UT) \
+ BOOST_ENUMS_DETAIL_NAMESPACE_CLOSE(BOOST_ENUMS_DETAIL_NAMESPACE_SEQ(NS_EC)) \
+ BOOST_ENUMS_SPECIALIZATIONS(BOOST_ENUMS_DETAIL_CLASS(NS_EC), UT)
+
+#define BOOST_ENUM_NS_CLASS_NO_CONS_END(NS_EC, UT) \
+ BOOST_ENUM_CLASS_NO_CONS_END(BOOST_ENUMS_DETAIL_ENUM(NS_EC), UT) \
+ BOOST_ENUMS_DETAIL_NAMESPACE_CLOSE(BOOST_ENUMS_DETAIL_NAMESPACE_SEQ(NS_EC)) \
+ BOOST_ENUMS_SPECIALIZATIONS(BOOST_ENUMS_DETAIL_CLASS(NS_EC), UT)
+
+#define BOOST_ENUM_NS_TYPE_NO_CONS_END(NS_EC, UT) \
+ BOOST_ENUM_TYPE_NO_CONS_END(BOOST_ENUMS_DETAIL_ENUM(NS_EC), UT) \
+ BOOST_ENUMS_DETAIL_NAMESPACE_CLOSE(BOOST_ENUMS_DETAIL_NAMESPACE_SEQ(NS_EC)) \
+ BOOST_ENUMS_SPECIALIZATIONS(BOOST_ENUMS_DETAIL_CLASS(NS_EC), UT)
+
+#define BOOST_ENUM_NS_CLASS_CONS_END(NS_EC, UT) \
+ BOOST_ENUM_CLASS_CONS_END(BOOST_ENUMS_DETAIL_ENUM(NS_EC), UT) \
+ BOOST_ENUMS_DETAIL_NAMESPACE_CLOSE(BOOST_ENUMS_DETAIL_NAMESPACE_SEQ(NS_EC)) \
+ BOOST_ENUMS_SPECIALIZATIONS(BOOST_ENUMS_DETAIL_CLASS(NS_EC), UT)
+
+#define BOOST_ENUM_NS_TYPE_CONS_END(NS_EC, UT) \
+ BOOST_ENUM_TYPE_CONS_END(BOOST_ENUMS_DETAIL_ENUM(NS_EC), UT) \
+ BOOST_ENUMS_DETAIL_NAMESPACE_CLOSE(BOOST_ENUMS_DETAIL_NAMESPACE_SEQ(NS_EC)) \
+ BOOST_ENUMS_SPECIALIZATIONS(BOOST_ENUMS_DETAIL_CLASS(NS_EC), UT)
+
 
 #endif // BOOST_ENUMS_SCOPED_EMULATION_HPP
 #endif


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk