libtenum
|
00001 00008 #ifndef TENUM_DETAIL_ENUM_HPP_ 00009 #define TENUM_DETAIL_ENUM_HPP_ 00010 00011 #ifndef IN_TENUM_HPP_ 00012 # error "This header should not be included directly. Please use tenum.hpp." 00013 #endif 00014 00015 #include <tenum/detail/type.hpp> 00016 00025 #define TENUM_TUPLE_CREATE(value_m,integer_value_m,name_m) \ 00026 (value_m,integer_value_m,name_m) 00027 00032 #define TENUM_TUPLE_GET_VALUE(tuple_m) \ 00033 BOOST_PP_TUPLE_ELEM(3,0,tuple_m) 00034 00039 #define TENUM_TUPLE_GET_INTEGER_VALUE(tuple_m) \ 00040 BOOST_PP_TUPLE_ELEM(3,1,tuple_m) 00041 00046 #define TENUM_TUPLE_GET_NAME(tuple_m) \ 00047 BOOST_PP_TUPLE_ELEM(3,2,tuple_m) 00048 00056 #define TENUM_TUPLE(value_m) \ 00057 TENUM_TUPLE_CREATE(value_m,BOOST_PP_EMPTY(),BOOST_PP_STRINGIZE(value_m)) 00058 00065 #define TENUM_TUPLE_VALUED(value_m,integer_value_m) \ 00066 TENUM_TUPLE_CREATE(value_m,=integer_value_m,BOOST_PP_STRINGIZE(value_m)) 00067 00074 #define TENUM_TUPLE_NAMED(value_m,name_m) \ 00075 TENUM_TUPLE_CREATE(value_m,BOOST_PP_EMPTY(),name_m) 00076 00082 #define TENUM_TUPLE_VALUED_NAMED(value_m,integer_value_m,name_m) \ 00083 TENUM_TUPLE_CREATE(value_m,=integer_value_m,name_m) 00084 00089 #define TENUM_ELEMENT(value_m) \ 00090 (TENUM_TUPLE(value_m)) 00091 00096 #define TENUM_ELEMENT_VALUED(value_m,integer_value_m) \ 00097 (TENUM_TUPLE_VALUED(value_m,integer_value_m)) 00098 00103 #define TENUM_ELEMENT_NAMED(value_m,name_m) \ 00104 (TENUM_TUPLE_NAMED(value_m,name_m)) 00105 00110 #define TENUM_ELEMENT_VALUED_NAMED(value_m,integer_value_m,name_m) \ 00111 (TENUM_TUPLE_VALUED_NAMED(value_m,integer_value_m,name_m)) 00112 00113 #define TENUM_ENUM_VALUES_COMPLETE_EACH(_1,_2,value_m) \ 00114 TENUM_TUPLE(value_m) 00115 #define TENUM_ENUM_VALUES_COMPLETE(values_m) \ 00116 BOOST_PP_SEQ_TRANSFORM(TENUM_ENUM_VALUES_COMPLETE_EACH, ~, values_m) 00117 00118 #define TENUM_ENUM_VALUES_DEFINITION_EACH(_1,_2,tuple_m) \ 00119 TENUM_TUPLE_GET_VALUE(tuple_m) TENUM_TUPLE_GET_INTEGER_VALUE(tuple_m), 00120 #define TENUM_ENUM_VALUES_DEFINITION(tuples_m) \ 00121 BOOST_PP_SEQ_FOR_EACH(TENUM_ENUM_VALUES_DEFINITION_EACH, ~, tuples_m) 00122 00141 #ifdef BOOST_NO_SCOPED_ENUMS 00142 00143 # define TENUM_ENUM_DEFINITION(type_m,tuples_m,underlying_m) \ 00144 struct type_m { \ 00145 enum BOOST_PP_CAT(type_m,_e) underlying_m { \ 00146 TENUM_ENUM_VALUES_DEFINITION(tuples_m) \ 00147 }; \ 00148 }; \ 00149 typedef type_m :: BOOST_PP_CAT(type_m,_e) TENUM_TYPE(type_m); 00150 00151 #else 00152 00153 # define TENUM_ENUM_DEFINITION(type_m,tuples_m,underlying_m) \ 00154 enum class type_m underlying_m { \ 00155 TENUM_ENUM_VALUES_DEFINITION(tuples_m) \ 00156 }; \ 00157 typedef type_m TENUM_TYPE(type_m); 00158 00159 #endif /* BOOST_NO_SCOPED_ENUMS */ 00160 00161 #endif /* TENUM_DETAIL_ENUM_HPP_ */