00001
00002
00003
00004
00005
00006
00007
00008
00012 #ifndef ZYPP_ARCH_H
00013 #define ZYPP_ARCH_H
00014
00015 #include <iosfwd>
00016 #include <functional>
00017 #include <set>
00018 #include <string>
00019
00020 #include "zypp/RelCompare.h"
00021 #include "zypp/base/String.h"
00022 #include "zypp/base/Iterator.h"
00023
00025 namespace zypp
00026 {
00027
00029
00030
00031
00034 class Arch
00035 {
00036 public:
00038 Arch();
00040 explicit
00041 Arch( const std::string & rhs );
00042
00043 public:
00045 const std::string & asString() const;
00046
00048 bool empty() const
00049 { return asString().empty(); }
00050
00059 bool compatibleWith( const Arch & targetArch_r ) const;
00060
00066 int compare( const Arch & rhs ) const;
00067
00069 static int compare( const Arch & lhs, const Arch & rhs )
00070 { return lhs.compare( rhs ); }
00071
00072 public:
00074 typedef std::set<Arch,CompareByGT<Arch> > CompatSet;
00075
00089 static CompatSet compatSet( const Arch & targetArch_r );
00090
00092 static std::string asString( const CompatSet & cset )
00093 {
00094 return str::join( make_transform_iterator( cset.begin(), std::mem_fun_ref(&Arch::asString) ),
00095 make_transform_iterator( cset.end(), std::mem_fun_ref(&Arch::asString) ) );
00096 }
00097
00098 public:
00099 struct CompatEntry;
00100 private:
00101 Arch( const CompatEntry & );
00102 const CompatEntry * _entry;
00103 };
00105
00114 extern const Arch Arch_noarch;
00115
00117 extern const Arch Arch_x86_64;
00119 extern const Arch Arch_athlon;
00121 extern const Arch Arch_i686;
00123 extern const Arch Arch_i586;
00125 extern const Arch Arch_i486;
00127 extern const Arch Arch_i386;
00128
00130 extern const Arch Arch_s390x;
00132 extern const Arch Arch_s390;
00133
00135 extern const Arch Arch_ppc64;
00137 extern const Arch Arch_ppc;
00138
00140 extern const Arch Arch_ia64;
00142
00144
00146 inline std::ostream & operator<<( std::ostream & str, const Arch & obj )
00147 { return str << obj.asString(); }
00148
00152 inline bool operator==( const Arch & lhs, const Arch & rhs )
00153 { return lhs.asString() == rhs.asString(); }
00154
00156 inline bool operator==( const Arch & lhs, const std::string & rhs )
00157 { return lhs.asString() == rhs; }
00158
00160 inline bool operator==( const std::string & lhs, const Arch & rhs )
00161 { return lhs == rhs.asString(); }
00162
00164 inline bool operator!=( const Arch & lhs, const Arch & rhs )
00165 { return !( lhs == rhs ); }
00166
00168 inline bool operator!=( const Arch & lhs, const std::string & rhs )
00169 { return !( lhs == rhs ); }
00170
00172 inline bool operator!=( const std::string & lhs, const Arch & rhs )
00173 { return !( lhs == rhs ); }
00175
00177
00181 struct ArchCompatibleWith : public std::unary_function<Arch,bool>
00182 {
00184 Arch _targetArch;
00186 ArchCompatibleWith( const Arch & targetArch_r )
00187 : _targetArch( targetArch_r )
00188 {}
00190 bool operator()( const Arch & rhs ) const
00191 { return rhs.compatibleWith( _targetArch ); }
00192 };
00193
00195 }
00197
00199 namespace std
00200 {
00201
00202 template<>
00203 inline bool less<zypp::Arch>::operator()( const zypp::Arch & lhs, const zypp::Arch & rhs ) const
00204 { return lhs.compare( rhs ) < 0; }
00206 }
00208 #endif // ZYPP_ARCH_H