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;
52 /** Order on Arch (arbitrary).
53 * \todo Adjust logical operators below to follow compare.
55 int compare( const Arch & rhs ) const
56 { return (_score < rhs._score) ? -1 : ((_score > rhs._score ) ? 1 : 0); }
59 /** String representation of Arch. */
63 ///////////////////////////////////////////////////////////////////
65 /** \name Builtin architecture constants.
67 * Defined outside Arch as e.g. \c Arch_i386, because some names,
68 * like \c i388, are used as \c #define, thus unusable as identifier
73 extern const Arch Arch_noarch;
74 extern const Arch Arch_src;
77 extern const Arch Arch_x86_64;
79 extern const Arch Arch_athlon;
81 extern const Arch Arch_i686;
83 extern const Arch Arch_i586;
85 extern const Arch Arch_i486;
87 extern const Arch Arch_i386;
90 extern const Arch Arch_s390x;
92 extern const Arch Arch_s390;
95 extern const Arch Arch_ppc64;
97 extern const Arch Arch_ppc;
100 extern const Arch Arch_ia64;
103 ///////////////////////////////////////////////////////////////////
106 : _value( Arch_noarch._value )
109 ///////////////////////////////////////////////////////////////////
111 /** \relates Arch stream output. */
112 inline std::ostream & operator<<( std::ostream & str, const Arch & obj )
113 { return str << obj.asString(); }
115 /** \name Comparison based on string value. */
118 inline bool operator==( const Arch & lhs, const Arch & rhs )
119 { return lhs.asString() == rhs.asString(); }
122 inline bool operator==( const Arch & lhs, const std::string & rhs )
123 { return lhs.asString() == rhs; }
126 inline bool operator==( const std::string & lhs, const Arch & rhs )
127 { return lhs == rhs.asString(); }
130 inline bool operator!=( const Arch & lhs, const Arch & rhs )
131 { return !( lhs == rhs ); }
134 inline bool operator!=( const Arch & lhs, const std::string & rhs )
135 { return !( lhs == rhs ); }
138 inline bool operator!=( const std::string & lhs, const Arch & rhs )
139 { return !( lhs == rhs ); }
142 ///////////////////////////////////////////////////////////////////
144 /** Functor finding compatible architectures.
145 * \see Arch::compatibleWith
147 struct ArchCompatibleWith : public std::unary_function<Arch,bool>
149 /** The target architecture */
151 /** Ctor taking the target architecture */
152 ArchCompatibleWith( const Arch & targetArch_r )
153 : _targetArch( targetArch_r )
155 /** Call Arch::compatibleWith ( \c _targetArch ) on \a rhs. */
156 bool operator()( const Arch & rhs ) const
157 { return rhs.compatibleWith( _targetArch ); }
160 /////////////////////////////////////////////////////////////////
162 ///////////////////////////////////////////////////////////////////
164 ///////////////////////////////////////////////////////////////////
166 { /////////////////////////////////////////////////////////////////
167 /** \relates Arch Default order for std::container based on string value.*/
169 inline bool less<zypp::Arch>::operator()( const zypp::Arch & lhs, const zypp::Arch & rhs ) const
170 { return lhs.asString() < rhs.asString(); }
171 /////////////////////////////////////////////////////////////////
173 ///////////////////////////////////////////////////////////////////
174 #endif // ZYPP_ARCH_H