12 #ifndef ZYPP_BASE_FLAGS_H
13 #define ZYPP_BASE_FLAGS_H
57 template<
typename Enum>
66 explicit Flags(
unsigned flag_r ) :
_val( flag_r ) {}
78 operator unsigned()
const {
return _val; }
102 bool testFlag( Enum flag_r )
const {
return (
_val & flag_r ) == flag_r; }
109 template<
typename Enum>
110 inline std::ostream & operator<<( std::ostream & str, const Flags<Enum> & obj )
114 #define ZYPP_DECLARE_FLAGS(Name,Enum) typedef zypp::base::Flags<Enum> Name
117 #define ZYPP_DECLARE_OPERATORS_FOR_FLAGS(Name) \
118 inline Name operator&( Name::enum_type lhs, Name::enum_type rhs ) { return Name( lhs ) &= rhs; } \
119 inline Name operator&( Name::enum_type lhs, Name rhs ) { return rhs &= lhs; } \
120 inline Name operator|( Name::enum_type lhs, Name::enum_type rhs ) { return Name( lhs ) |= rhs; } \
121 inline Name operator|( Name::enum_type lhs, Name rhs ) { return rhs |= lhs; } \
122 inline Name operator^( Name::enum_type lhs, Name::enum_type rhs ) { return Name( lhs ) ^= rhs; } \
123 inline Name operator^( Name::enum_type lhs, Name rhs ) { return rhs ^= lhs; } \
124 inline Name operator~( Name::enum_type lhs ) { return ~Name( lhs ); }
127 #define ZYPP_DECLARE_FLAGS_AND_OPERATORS(Name,Enum) \
128 ZYPP_DECLARE_FLAGS(Name,Enum); \
129 ZYPP_DECLARE_OPERATORS_FOR_FLAGS(Name)
137 #endif // ZYPP_BASE_FLAGS_H
Flags & operator|=(Flags rhs)
Flags & operator^=(Flags rhs)
Flags & operator&=(Flags rhs)
Flags & setFlag(Enum flag_r, bool newval_r)
Flags operator|(Enum rhs) const
Flags & setFlag(Enum flag_r)
Flags operator&(Flags rhs) const
Flags operator|(Flags rhs) const
A type-safe way of storing OR-combinations of enum values (like QTs QFlags).
Flags & unsetFlag(Enum flag_r)
Flags & operator^=(Enum rhs)
Flags & operator|=(Enum rhs)
Flags & unsetFlag(Flags flag_r)
Flags operator^(Enum rhs) const
Flags operator^(Flags rhs) const
Flags & operator&=(Enum rhs)
Flags & setFlag(Flags flag_r, bool newval_r)
Flags & setFlag(Flags flag_r)
bool testFlag(Flags flag_r) const
bool testFlag(Enum flag_r) const
Flags operator&(Enum rhs) const
std::string hexstring(char n, int w=4)