00001 /*---------------------------------------------------------------------\ 00002 | ____ _ __ __ ___ | 00003 | |__ / \ / / . \ . \ | 00004 | / / \ V /| _/ _/ | 00005 | / /__ | | | | | | | 00006 | /_____||_| |_| |_| | 00007 | | 00008 \---------------------------------------------------------------------*/ 00012 #ifndef ZYPP_RESKIND_H 00013 #define ZYPP_RESKIND_H 00014 00015 #include <iosfwd> 00016 #include <string> 00017 00018 #include "zypp/base/Deprecated.h" 00019 #include "zypp/base/String.h" 00020 #include "zypp/IdStringType.h" 00021 00023 namespace zypp 00024 { 00025 00027 // 00028 // CLASS NAME : ResKind 00029 // 00035 class ResKind : public IdStringType<ResKind> 00036 { 00037 public: 00041 static const ResKind nokind; 00042 00043 static const ResKind package; 00044 static const ResKind patch; 00045 static const ResKind pattern; 00046 static const ResKind product; 00047 static const ResKind srcpackage; 00049 00050 public: 00052 ResKind() {} 00053 00055 explicit ResKind( sat::detail::IdType id_r ) : _str( str::toLower(IdString(id_r).c_str()) ) {} 00056 explicit ResKind( const IdString & idstr_r ) : _str( str::toLower(idstr_r.c_str()) ) {} 00057 explicit ResKind( const std::string & str_r ) : _str( str::toLower(str_r) ) {} 00058 explicit ResKind( const char * cstr_r ) : _str( str::toLower(cstr_r) ) {} 00059 00060 public: 00066 static std::string satIdent( const ResKind & refers_r, const std::string & name_r ); 00068 std::string satIdent( const std::string & name_r ) const 00069 { return satIdent( *this, name_r ); } 00070 00071 private: 00072 static int _doCompare( const char * lhs, const char * rhs ) 00073 { 00074 if ( lhs == rhs ) return 0; 00075 if ( lhs && rhs ) return ::strcasecmp( lhs, rhs ); 00076 return( lhs ? 1 : -1 ); 00077 } 00078 00079 private: 00080 friend class IdStringType<ResKind>; 00081 IdString _str; 00082 }; 00083 00085 } // namespace zypp 00087 #endif // ZYPP_RESKIND_H