00001
00002
00003
00004
00005
00006
00007
00008
00012 #ifndef ZYPP_EDITION_H
00013 #define ZYPP_EDITION_H
00014
00015 #include <iosfwd>
00016 #include <string>
00017 #include <functional>
00018
00019 #include "zypp/IdStringType.h"
00020 #include "zypp/RelCompare.h"
00021 #include "zypp/Range.h"
00022
00024 namespace zypp
00025 {
00026
00028
00029
00030
00060 class Edition : public IdStringType<Edition>
00061 {
00062 public:
00064 typedef unsigned epoch_t;
00065
00067 static const epoch_t noepoch = 0;
00068
00073 static const Edition noedition;
00074
00075 public:
00077 Edition() {}
00078
00080 explicit Edition( IdString::IdType id_r ) : _str( id_r ) {}
00081 explicit Edition( const IdString & idstr_r ) : _str( idstr_r ) {}
00082 explicit Edition( const std::string & str_r ) : _str( str_r ) {}
00083 explicit Edition( const char * cstr_r ) : _str( cstr_r ) {}
00084
00086 Edition( const std::string & version_r,
00087 const std::string & release_r,
00088 epoch_t epoch_r = noepoch );
00090 Edition( const char * version_r,
00091 const char * release_r,
00092 epoch_t epoch_r = noepoch );
00093
00095 Edition( const std::string & version_r,
00096 const std::string & release_r,
00097 const std::string & epoch_r );
00099 Edition( const char * version_r,
00100 const char * release_r,
00101 const char * epoch_r );
00102
00103 public:
00105 epoch_t epoch() const;
00106
00108 std::string version() const;
00109
00111 std::string release() const;
00112
00113 public:
00117 typedef zypp::Compare<Edition> Compare;
00118
00122 typedef Range<Edition> CompareRange;
00123
00124 public:
00130 static int match( const Edition & lhs, const Edition & rhs ) { return match( lhs.idStr(), rhs.idStr() ); }
00131 static int match( const Edition & lhs, const IdString & rhs ) { return match( lhs.idStr(), rhs ); }
00132 static int match( const Edition & lhs, const std::string & rhs ) { return _doMatch( lhs.c_str(), rhs.c_str() ); }
00133 static int match( const Edition & lhs, const char * rhs ) { return _doMatch( lhs.c_str(), rhs );}
00134
00135 static int match( const IdString & lhs, const Edition & rhs ) { return match( lhs, rhs.idStr() ); }
00136 static int match( const IdString & lhs, const IdString & rhs ) { return lhs.compareEQ( rhs ) ? 0 :
00137 _doMatch( lhs.c_str(), rhs.c_str() ); }
00138 static int match( const IdString & lhs, const std::string & rhs ) { return _doMatch( lhs.c_str(), rhs.c_str() ); }
00139 static int match( const IdString & lhs, const char * rhs ) { return _doMatch( lhs.c_str(), rhs ); }
00140
00141 static int match( const std::string & lhs, const Edition & rhs ) { return _doMatch( lhs.c_str(), rhs.c_str() );}
00142 static int match( const std::string & lhs, const IdString & rhs ) { return _doMatch( lhs.c_str(), rhs.c_str() ); }
00143 static int match( const std::string & lhs, const std::string & rhs ) { return _doMatch( lhs.c_str(), rhs.c_str() ); }
00144 static int match( const std::string & lhs, const char * rhs ) { return _doMatch( lhs.c_str(), rhs ); }
00145
00146 static int match( const char * lhs, const Edition & rhs ) { return _doMatch( lhs, rhs.c_str() );}
00147 static int match( const char * lhs, const IdString & rhs ) { return _doMatch( lhs, rhs.c_str() ); }
00148 static int match( const char * lhs, const std::string & rhs ) { return _doMatch( lhs, rhs.c_str() ); }
00149 static int match( const char * lhs, const char * rhs ) { return _doMatch( lhs, rhs ); }
00150
00151 int match( const Edition & rhs ) const { return match( idStr(), rhs.idStr() ); }
00152 int match( const IdString & rhs ) const { return match( idStr(), rhs ); }
00153 int match( const std::string & rhs ) const { return _doMatch( c_str(), rhs.c_str() ); }
00154 int match( const char * rhs ) const { return _doMatch( c_str(), rhs ); }
00156
00160 struct Match: public std::binary_function<Edition,Edition,int>
00161 {
00162 int operator()( const Edition & lhs, const Edition & rhs ) const
00163 { return Edition::match( lhs, rhs ); }
00164 };
00165
00169 typedef Range<Edition, Match> MatchRange;
00170
00171 private:
00172 static int _doCompare( const char * lhs, const char * rhs );
00173 static int _doMatch( const char * lhs, const char * rhs );
00174
00175 private:
00176 friend class IdStringType<Edition>;
00177 IdString _str;
00178 };
00180
00182 }
00184 #endif // ZYPP_EDITION_H