00001
00002
00003
00004
00005
00006
00007
00008
00012 #ifndef ZYPP_BASE_KINDOF_H
00013 #define ZYPP_BASE_KINDOF_H
00014
00015 #include <iosfwd>
00016
00017 #include "zypp/base/String.h"
00018
00020 namespace zypp
00021 {
00022
00024
00025
00026
00044 template<class _Tp>
00045 class KindOf
00046 {
00047 public:
00049 KindOf()
00050 {}
00054 explicit
00055 KindOf( const std::string & value_r )
00056 : _value( str::toLower(value_r) )
00057 {}
00059 ~KindOf()
00060 {}
00061 public:
00063 const std::string & asString() const
00064 { return _value; }
00065
00071 int compare( const KindOf & rhs ) const
00072 { return _value.compare( rhs._value ); }
00073
00074 private:
00076 std::string _value;
00077 };
00079
00081
00082 template<class _Tp>
00083 inline std::ostream & operator<<( std::ostream & str, const KindOf<_Tp> & obj )
00084 { return str << obj.asString(); }
00086
00088
00090
00091 template<class _Tp>
00092 inline bool operator==( const KindOf<_Tp> & lhs, const KindOf<_Tp> & rhs )
00093 { return lhs.asString() == rhs.asString(); }
00094
00096 template<class _Tp>
00097 inline bool operator==( const KindOf<_Tp> & lhs, const std::string & rhs )
00098 { return lhs.asString() == str::toLower(rhs); }
00099
00101 template<class _Tp>
00102 inline bool operator==( const std::string & lhs, const KindOf<_Tp> & rhs )
00103 { return str::toLower(lhs) == rhs.asString(); }
00105
00107
00108 template<class _Tp>
00109 inline bool operator!=( const KindOf<_Tp> & lhs, const KindOf<_Tp> & rhs )
00110 { return !( lhs == rhs ); }
00111
00113 template<class _Tp>
00114 inline bool operator!=( const KindOf<_Tp> & lhs, const std::string & rhs )
00115 { return !( lhs == rhs ); }
00116
00118 template<class _Tp>
00119 inline bool operator!=( const std::string & lhs, const KindOf<_Tp> & rhs )
00120 { return !( lhs == rhs ); }
00122
00124
00125 template<class _Tp>
00126 inline bool operator<( const KindOf<_Tp> & lhs, const KindOf<_Tp> & rhs )
00127 { return lhs.asString() < rhs.asString(); }
00129
00131 }
00133 #endif // ZYPP_BASE_KINDOF_H