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 ///////////////////////////////////////////////////////////////////
58 /** \name Builtin architecture constants.
60 * Defined outside Arch as e.g. \c Arch_i386, because some names,
61 * like \c i388, are used as \c #define, thus unusable as identifier
66 extern const Arch Arch_noarch;
69 extern const Arch Arch_x86_64;
71 extern const Arch Arch_athlon;
73 extern const Arch Arch_i686;
75 extern const Arch Arch_i586;
77 extern const Arch Arch_i486;
79 extern const Arch Arch_i386;
82 extern const Arch Arch_s390x;
84 extern const Arch Arch_s390;
87 extern const Arch Arch_ppc64;
89 extern const Arch Arch_ppc;
92 extern const Arch Arch_ia64;
95 ///////////////////////////////////////////////////////////////////
98 : _value( Arch_noarch._value )
101 ///////////////////////////////////////////////////////////////////
103 /** \relates Arch stream output. */
104 inline std::ostream & operator<<( std::ostream & str, const Arch & obj )
105 { return str << obj.asString(); }
107 /** \name Comparison based on string value. */
110 inline bool operator==( const Arch & lhs, const Arch & rhs )
111 { return lhs.asString() == rhs.asString(); }
114 inline bool operator==( const Arch & lhs, const std::string & rhs )
115 { return lhs.asString() == rhs; }
118 inline bool operator==( const std::string & lhs, const Arch & rhs )
119 { return lhs == rhs.asString(); }
122 inline bool operator!=( const Arch & lhs, const Arch & rhs )
123 { return !( lhs == rhs ); }
126 inline bool operator!=( const Arch & lhs, const std::string & rhs )
127 { return !( lhs == rhs ); }
130 inline bool operator!=( const std::string & lhs, const Arch & rhs )
131 { return !( lhs == rhs ); }
134 ///////////////////////////////////////////////////////////////////
136 /** Functor finding compatible architectures.
137 * \see Arch::compatibleWith
139 struct ArchCompatibleWith : public std::unary_function<Arch,bool>
141 /** The target architecture */
143 /** Ctor taking the target architecture */
144 ArchCompatibleWith( const Arch & targetArch_r )
145 : _targetArch( targetArch_r )
147 /** Call Arch::compatibleWith ( \c _targetArch ) on \a rhs. */
148 bool operator()( const Arch & rhs ) const
149 { return rhs.compatibleWith( _targetArch ); }
152 /////////////////////////////////////////////////////////////////
154 ///////////////////////////////////////////////////////////////////
156 ///////////////////////////////////////////////////////////////////
158 { /////////////////////////////////////////////////////////////////
159 /** \relates Arch Default order for std::container based on string value.*/
161 inline bool less<zypp::Arch>::operator()( const zypp::Arch & lhs, const zypp::Arch & rhs ) const
162 { return lhs.asString() < rhs.asString(); }
163 /////////////////////////////////////////////////////////////////
165 ///////////////////////////////////////////////////////////////////
166 #endif // ZYPP_ARCH_H