|
Go to the documentation of this file.
9 #ifndef ADOBE_ENUM_OPS_HPP
10 #define ADOBE_ENUM_OPS_HPP
61 namespace implementation {
64 #if !defined(ADOBE_NO_DOCUMENTATION)
65 inline signed char promote_enum ( signed char e) { return e; }
66 inline unsigned char promote_enum ( unsigned char e) { return e; }
67 inline signed short promote_enum ( signed short e) { return e; }
68 inline unsigned short promote_enum ( unsigned short e) { return e; }
69 inline signed int promote_enum ( signed int e) { return e; }
70 inline unsigned int promote_enum ( unsigned int e) { return e; }
71 inline signed long promote_enum ( signed long e) { return e; }
72 inline unsigned long promote_enum ( unsigned long e) { return e; }
74 #ifdef BOOST_HAS_LONG_LONG
75 inline signed long long promote_enum ( signed long long e) { return e; }
76 inline unsigned long long promote_enum ( unsigned long long e) { return e; }
89 #define ADOBE_DEFINE_BITSET_OPS(EnumType) \
90 inline EnumType operator~(EnumType a) \
92 return EnumType(~adobe::implementation::promote_enum(a)); \
95 inline EnumType operator|(EnumType lhs, EnumType rhs) \
97 return EnumType(adobe::implementation::promote_enum(lhs) \
98 | adobe::implementation::promote_enum(rhs)); \
101 inline EnumType operator&(EnumType lhs, EnumType rhs) \
103 return EnumType(adobe::implementation::promote_enum(lhs) \
104 & adobe::implementation::promote_enum(rhs)); \
107 inline EnumType operator^(EnumType lhs, EnumType rhs) \
109 return EnumType(adobe::implementation::promote_enum(lhs) \
110 ^ adobe::implementation::promote_enum(rhs)); \
113 inline EnumType& operator&=(EnumType& lhs, EnumType rhs) \
115 return lhs = lhs & rhs; \
118 inline EnumType& operator|=(EnumType& lhs, EnumType rhs) \
120 return lhs = lhs | rhs; \
123 inline EnumType& operator^=(EnumType& lhs, EnumType rhs) \
125 return lhs = lhs ^ rhs; \
130 #define ADOBE_DEFINE_ARITHMETIC_OPS(EnumType) \
131 inline EnumType operator+(EnumType a) \
133 return EnumType(+adobe::implementation::promote_enum(a)); \
136 inline EnumType operator-(EnumType a) \
138 return EnumType(-adobe::implementation::promote_enum(a)); \
141 inline EnumType operator+(EnumType lhs, EnumType rhs) \
143 return EnumType(adobe::implementation::promote_enum(lhs) \
144 + adobe::implementation::promote_enum(rhs)); \
147 inline EnumType operator-(EnumType lhs, EnumType rhs) \
149 return EnumType(adobe::implementation::promote_enum(lhs) \
150 - adobe::implementation::promote_enum(rhs)); \
153 inline EnumType operator*(EnumType lhs, EnumType rhs) \
155 return EnumType(adobe::implementation::promote_enum(lhs) \
156 * adobe::implementation::promote_enum(rhs)); \
159 inline EnumType operator/(EnumType lhs, EnumType rhs) \
161 return EnumType(adobe::implementation::promote_enum(lhs) \
162 / adobe::implementation::promote_enum(rhs)); \
165 inline EnumType operator%(EnumType lhs, EnumType rhs) \
167 return EnumType(adobe::implementation::promote_enum(lhs) \
168 % adobe::implementation::promote_enum(rhs)); \
171 inline EnumType& operator+=(EnumType& lhs, EnumType rhs) \
173 return lhs = lhs + rhs; \
176 inline EnumType& operator-=(EnumType& lhs, EnumType rhs) \
178 return lhs = lhs - rhs; \
181 inline EnumType& operator*=(EnumType& lhs, EnumType rhs) \
183 return lhs = lhs * rhs; \
186 inline EnumType& operator/=(EnumType& lhs, EnumType rhs) \
188 return lhs = lhs / rhs; \
191 inline EnumType& operator%=(EnumType& lhs, EnumType rhs) \
193 return lhs = lhs % rhs; \
|