Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef ENUM_HPP_
00009 #define ENUM_HPP_
00010
00011 #include <boost/enum.hpp>
00012
00013
00014 #include <iostream>
00015 #include <sstream>
00016 #include <string.h>
00017
00018
00019 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
00020 # pragma once
00021 #endif
00022
00023 #define TELEKYB_ENUM_getAllDomainNames \
00024 static std::string getAllDomainNames(char sep) \
00025 { \
00026 std::stringstream ss; \
00027 std::string separator(""); \
00028 for(unsigned int i = 0; i < size; i++) \
00029 { \
00030 ss << separator << names((domain)i); \
00031 separator = sep; \
00032 } \
00033 return ss.str(); \
00034 }
00035
00036 #define TELEKYB_ENUM_getEnumName(elem) \
00037 static const char* getEnumName() \
00038 { \
00039 return BOOST_PP_STRINGIZE(elem); \
00040 }
00041
00042 #define TELEKYB_ENUM(_name, _seq) \
00043 class _name : public boost::detail::enum_base<_name> \
00044 { \
00045 public: \
00046 BOOST_ENUM_domain(_seq, 0, 1) \
00047 _name() {} \
00048 _name(domain index) : boost::detail::enum_base<_name>(index) {} \
00049 _name(const boost::detail::enum_base<_name>& derived) : boost::detail::enum_base<_name>(derived.index()) {} \
00050 BOOST_ENUM_get_by_name(_name, _seq, 0, 1) \
00051 TELEKYB_ENUM_getAllDomainNames \
00052 TELEKYB_ENUM_getEnumName(_name) \
00053 private: \
00054 friend class boost::detail::enum_base<_name>; \
00055 BOOST_ENUM_names(_seq, 0, 1) \
00056 BOOST_ENUM_values_identity() \
00057 }; \
00058 struct _name ## BaseEnum { \
00059 typedef boost::detail::enum_base<_name> Type; \
00060 };
00061
00062 #define TELEKYB_ENUM_VALUES(_name, _type, _seq) \
00063 class _name : public boost::detail::enum_base<_name, _type> \
00064 { \
00065 public: \
00066 BOOST_ENUM_domain(_seq, 0, 2) \
00067 _name() {} \
00068 _name(domain index) : boost::detail::enum_base<_name, _type>(index) {} \
00069 _name(const boost::detail::enum_base<_name, _type>& derived) : boost::detail::enum_base<_name, _type>(derived.index()) {} \
00070 BOOST_ENUM_get_by_name(_name, _seq, 0, 2) \
00071 TELEKYB_ENUM_getAllDomainNames \
00072 TELEKYB_ENUM_getEnumName(_name) \
00073 private: \
00074 friend class boost::detail::enum_base<_name, _type>; \
00075 BOOST_ENUM_names(_seq, 0, 2) \
00076 BOOST_ENUM_values(_seq, 0, 1, 2) \
00077 }; \
00078 template<typename T_ = _type> \
00079 struct _name ## BaseEnum { \
00080 typedef boost::detail::enum_base<_name, T_> Type; \
00081 };
00082
00083 #define TELEKYB_BITFIELD(_name, _seq) \
00084 class _name : public boost::detail::bitfield_base<_name> \
00085 { \
00086 public: \
00087 BOOST_BITFIELD_domain(_seq, 0, 2) \
00088 _name() {} \
00089 _name(domain index) : boost::detail::bitfield_base<_name>(index) {} \
00090 _name(const boost::detail::bitfield_base<_name>& derived) : boost::detail::bitfield_base<_name>(derived.index()) {} \
00091 BOOST_ENUM_get_by_name(_name, _seq, 0, 2) \
00092 TELEKYB_ENUM_getAllDomainNames \
00093 TELEKYB_ENUM_getEnumName(_name) \
00094 private: \
00095 friend class boost::detail::bitfield_access; \
00096 _name(value_type raw, int) : boost::detail::bitfield_base<_name>(raw, 0) {} \
00097 BOOST_BITFIELD_names(_seq, 0, 2) \
00098 BOOST_BITFIELD_values(_seq, 0, 1, 2) \
00099 }; \
00100 struct _name ## BaseEnum { \
00101 typedef boost::detail::enum_base<_name> Type; \
00102 };
00103
00104
00105
00106 #endif