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 _value.compare( rhs._value ); }
58 /** Architecture of the current working system
60 * \todo Eliminate this, it's not task of a data type to
61 * detect and define what the system architecture is.
63 static const Arch System;
66 /** String representation of Arch. */
69 ///////////////////////////////////////////////////////////////////
71 /** \name Builtin architecture constants.
73 * Defined outside Arch as e.g. \c Arch_i386, because some names,
74 * like \c i388, are used as \c #define, thus unusable as identifier
79 extern const Arch Arch_noarch;
82 extern const Arch Arch_x86_64;
84 extern const Arch Arch_athlon;
86 extern const Arch Arch_i686;
88 extern const Arch Arch_i586;
90 extern const Arch Arch_i486;
92 extern const Arch Arch_i386;
95 extern const Arch Arch_s390x;
97 extern const Arch Arch_s390;
100 extern const Arch Arch_ppc64;
102 extern const Arch Arch_ppc;
105 extern const Arch Arch_ia64;
108 ///////////////////////////////////////////////////////////////////
111 : _value( Arch_noarch._value )
114 ///////////////////////////////////////////////////////////////////
116 /** \relates Arch stream output. */
117 inline std::ostream & operator<<( std::ostream & str, const Arch & obj )
118 { return str << obj.asString(); }
120 /** \name Comparison based on string value. */
123 inline bool operator==( const Arch & lhs, const Arch & rhs )
124 { return lhs.asString() == rhs.asString(); }
127 inline bool operator==( const Arch & lhs, const std::string & rhs )
128 { return lhs.asString() == rhs; }
131 inline bool operator==( const std::string & lhs, const Arch & rhs )
132 { return lhs == rhs.asString(); }
135 inline bool operator!=( const Arch & lhs, const Arch & rhs )
136 { return !( lhs == rhs ); }
139 inline bool operator!=( const Arch & lhs, const std::string & rhs )
140 { return !( lhs == rhs ); }
143 inline bool operator!=( const std::string & lhs, const Arch & rhs )
144 { return !( lhs == rhs ); }
147 ///////////////////////////////////////////////////////////////////
149 /** Functor finding compatible architectures.
150 * \see Arch::compatibleWith
152 struct ArchCompatibleWith : public std::unary_function<Arch,bool>
154 /** The target architecture */
156 /** Ctor taking the target architecture */
157 ArchCompatibleWith( const Arch & targetArch_r )
158 : _targetArch( targetArch_r )
160 /** Call Arch::compatibleWith ( \c _targetArch ) on \a rhs. */
161 bool operator()( const Arch & rhs ) const
162 { return rhs.compatibleWith( _targetArch ); }
165 /////////////////////////////////////////////////////////////////
167 ///////////////////////////////////////////////////////////////////
169 ///////////////////////////////////////////////////////////////////
171 { /////////////////////////////////////////////////////////////////
172 /** \relates Arch Default order for std::container based on string value.*/
174 inline bool less<zypp::Arch>::operator()( const zypp::Arch & lhs, const zypp::Arch & rhs ) const
175 { return lhs.asString() < rhs.asString(); }
176 /////////////////////////////////////////////////////////////////
178 ///////////////////////////////////////////////////////////////////
179 #endif // ZYPP_ARCH_H