libzypp 17.31.23
EnumClass.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
11#ifndef ZYPP_BASE_ENUMCLASS_H
12#define ZYPP_BASE_ENUMCLASS_H
13
14#include <iosfwd>
15
16#include <zypp-core/base/PtrTypes.h>
17
19namespace zypp
20{
22 namespace base
23 {
46 template<typename TEnumDef>
47 class EnumClass : public TEnumDef
48 {
49 public:
50 typedef typename TEnumDef::Enum Enum;
51 typedef typename std::underlying_type<Enum>::type Integral;
52
53 EnumClass( Enum val_r ) : _val( val_r ) {}
54
64 Enum asEnum() const { return _val; }
65
75 Integral asIntegral() const { return static_cast<Integral>(_val); }
76
77 friend bool operator==( const EnumClass & lhs, const EnumClass & rhs ) { return lhs._val == rhs._val; }
78 friend bool operator!=( const EnumClass & lhs, const EnumClass & rhs ) { return lhs._val != rhs._val; }
79 friend bool operator< ( const EnumClass & lhs, const EnumClass & rhs ) { return lhs._val < rhs._val; }
80 friend bool operator<=( const EnumClass & lhs, const EnumClass & rhs ) { return lhs._val <= rhs._val; }
81 friend bool operator> ( const EnumClass & lhs, const EnumClass & rhs ) { return lhs._val > rhs._val; }
82 friend bool operator>=( const EnumClass & lhs, const EnumClass & rhs ) { return lhs._val >= rhs._val; }
83
84 private:
85 Enum _val;
86 };
87 } // namespace base
89} // namespace zypp
91#endif // ZYPP_BASE_ENUMCLASS_H
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
bool operator==(const SetRelation::Enum &lhs, const SetCompare &rhs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool operator>=(const IdString &lhs, const char *rhs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: IdString.h:220
bool operator!=(const SetRelation::Enum &lhs, const SetCompare &rhs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool operator<=(const IdString &lhs, const char *rhs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: IdString.h:188