1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
19 ///////////////////////////////////////////////////////////////////
21 { /////////////////////////////////////////////////////////////////
23 ///////////////////////////////////////////////////////////////////
28 * \todo improve compatibleWith implementation
29 * \todo unify strings and optimize opertor==
34 /** Default ctor 'noarch' */
36 /** Ctor from string. */
38 Arch( const std::string & rhs );
42 /** String representation of Arch. */
43 const std::string & asString() const
47 /** Compatibility relation.
48 * \return \c True iff \c this is compatible with \a rhs.
50 bool compatibleWith( const Arch & rhs ) const;
53 /** String representation of Arch. */
56 ///////////////////////////////////////////////////////////////////
59 /** \relates Arch Builtin architecture.
60 * Outside Arch, because some names, like \c i388, are used
61 * as \c #define, thus unusable as identifier.
63 extern const Arch Arch_noarch;
65 extern const Arch Arch_x86_64;
66 extern const Arch Arch_athlon;
67 extern const Arch Arch_i686;
68 extern const Arch Arch_i586;
69 extern const Arch Arch_i486;
70 extern const Arch Arch_i386;
72 extern const Arch Arch_s390x;
73 extern const Arch Arch_s390;
75 extern const Arch Arch_ppc64;
76 extern const Arch Arch_ppc;
78 extern const Arch Arch_ia64;
81 ///////////////////////////////////////////////////////////////////
84 : _value( Arch_noarch._value )
87 ///////////////////////////////////////////////////////////////////
91 inline std::ostream & operator<<( std::ostream & str, const Arch & obj )
92 { return str << obj.asString(); }
95 inline bool operator==( const Arch & lhs, const Arch & rhs )
96 { return lhs.asString() == rhs.asString(); }
98 inline bool operator==( const Arch & lhs, const std::string & rhs )
99 { return lhs.asString() == rhs; }
101 inline bool operator==( const std::string & lhs, const Arch & rhs )
102 { return lhs == rhs.asString(); }
105 inline bool operator!=( const Arch & lhs, const Arch & rhs )
106 { return !( lhs == rhs ); }
108 inline bool operator!=( const Arch & lhs, const std::string & rhs )
109 { return !( lhs == rhs ); }
111 inline bool operator!=( const std::string & lhs, const Arch & rhs )
112 { return !( lhs == rhs ); }
116 ///////////////////////////////////////////////////////////////////
118 /** Functor finding compatible architectures.
119 * \see Arch::compatibleWith
121 struct ArchCompatibleWith : public std::unary_function<Arch,bool>
123 /** The target architecture */
125 /** Ctor taking the target architecture */
126 ArchCompatibleWith( const Arch & targetArch_r )
127 : _targetArch( targetArch_r )
129 /** Call Arch::compatibleWith ( \c _targetArch ) on \a rhs. */
130 bool operator()( const Arch & rhs ) const
131 { return rhs.compatibleWith( _targetArch ); }
134 /////////////////////////////////////////////////////////////////
136 ///////////////////////////////////////////////////////////////////
138 ///////////////////////////////////////////////////////////////////
140 { /////////////////////////////////////////////////////////////////
141 /** \relates Arch Order relation for std::container classes. */
143 inline bool less<zypp::Arch>::operator()( const zypp::Arch & lhs, const zypp::Arch & rhs ) const
144 { return lhs.asString() < rhs.asString(); }
145 /////////////////////////////////////////////////////////////////
147 ///////////////////////////////////////////////////////////////////
148 #endif // ZYPP_ARCH_H