Mirror reflection library - Rubber type-erasure utility 0.5.13
|
00001 00010 #ifndef RUBBER_SPECIFIERS_1103151301_HPP 00011 #define RUBBER_SPECIFIERS_1103151301_HPP 00012 00013 #include <rubber/config.hpp> 00014 #include <rubber/range.hpp> 00015 #include <mirror/specifier_tags.hpp> 00016 #include <puddle/specifiers.hpp> 00017 00018 RUBBER_NAMESPACE_BEGIN 00019 00021 00025 class specifier 00026 { 00027 private: 00028 static inline bool category_matches(unsigned a, unsigned b) 00029 { 00030 return (a & b) == b; 00031 } 00032 00033 puddle::specifier_category _cat; 00034 public: 00036 template <typename Specifier> 00037 specifier(Specifier s) 00038 : _cat(puddle::get_category(s)) 00039 { } 00040 00042 friend bool operator == (const specifier& a, const specifier& b) 00043 { 00044 return a._cat == b._cat; 00045 } 00046 00048 friend bool operator != (const specifier& a, const specifier& b) 00049 { 00050 return a._cat != b._cat; 00051 } 00052 00054 friend bool operator <= (const specifier& a, const specifier& b) 00055 { 00056 return a._cat <= b._cat; 00057 } 00058 00060 friend bool operator >= (const specifier& a, const specifier& b) 00061 { 00062 return a._cat >= b._cat; 00063 } 00064 00066 friend bool operator < (const specifier& a, const specifier& b) 00067 { 00068 return a._cat < b._cat; 00069 } 00070 00072 friend bool operator > (const specifier& a, const specifier& b) 00073 { 00074 return a._cat > b._cat; 00075 } 00076 00078 puddle::specifier_category category(void) const 00079 { 00080 return _cat; 00081 } 00082 00084 inline bool is_a(puddle::specifier_category cat) const 00085 { 00086 return category_matches( 00087 unsigned(category()), 00088 unsigned(cat) 00089 ); 00090 } 00091 00092 #ifdef MIRROR_DOCUMENTATION_ONLY 00093 00094 00099 bool is_X(void) const; 00100 #endif 00101 #define RUBBER_HELPER_MAKE_SPEC_IS_X(SPEC, KW, GRP, I, X) \ 00102 inline bool is_## SPEC(void) const \ 00103 { \ 00104 return is_a(puddle::specifier_category::spec_ ## SPEC ## _tag); \ 00105 } 00106 MIRROR_FOR_EACH_SPECIFIER(RUBBER_HELPER_MAKE_SPEC_IS_X, _) 00107 #undef RUBBER_HELPER_MAKE_SPEC_IS_X 00108 00109 }; 00110 00111 RUBBER_NAMESPACE_END 00112 00113 #endif //include guard 00114