libzypp  13.10.6
Arch.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_ARCH_H
13 #define ZYPP_ARCH_H
14 
15 #include <iosfwd>
16 #include <functional>
17 #include <set>
18 #include <string>
19 
20 #include "zypp/base/String.h"
21 #include "zypp/base/Iterator.h"
22 
23 #include "zypp/IdStringType.h"
24 #include "zypp/RelCompare.h"
25 
27 namespace zypp
28 {
29 
31  //
32  // CLASS NAME : Arch
33  //
36  class Arch
37  {
38  public:
40  Arch();
41 
43  explicit Arch( IdString::IdType id_r );
44  explicit Arch( const IdString & idstr_r );
45  explicit Arch( const std::string & str_r );
46  explicit Arch( const char * cstr_r );
47 
48  public:
55  IdString idStr() const;
57  const std::string & asString() const;
59  const char * c_str() const
60  { return asString().c_str(); }
61 
63  bool empty() const
64  { return asString().empty(); }
65 
67  unsigned size() const
68  { return asString().size(); }
69 
72  { return idStr().id(); }
74 
75  public:
81  bool isBuiltIn() const;
82 
83  public:
92  bool compatibleWith( const Arch & targetArch_r ) const;
93 
98  Arch baseArch() const;
99 
101  static Arch baseArch( const Arch & targetArch_r )
102  { return targetArch_r.baseArch(); }
103 
109  int compare( const Arch & rhs ) const;
110 
112  static int compare( const Arch & lhs, const Arch & rhs )
113  { return lhs.compare( rhs ); }
114 
115  public:
117  typedef std::set<Arch,CompareByGT<Arch> > CompatSet;
118 
132  static CompatSet compatSet( const Arch & targetArch_r );
133 
135  static std::string asString( const CompatSet & cset )
136  {
137  return str::join( make_transform_iterator( cset.begin(), std::mem_fun_ref(&Arch::asString) ),
138  make_transform_iterator( cset.end(), std::mem_fun_ref(&Arch::asString) ) );
139  }
140 
141  public:
142  struct CompatEntry;
143  private:
144  Arch( const CompatEntry & );
146  };
148 
162  extern const Arch Arch_empty;
163 
165  extern const Arch Arch_noarch;
166 
168  extern const Arch Arch_pentium4;
170  extern const Arch Arch_pentium3;
171 
173  extern const Arch Arch_x86_64;
175  extern const Arch Arch_athlon;
177  extern const Arch Arch_i686;
179  extern const Arch Arch_i586;
181  extern const Arch Arch_i486;
183  extern const Arch Arch_i386;
184 
186  extern const Arch Arch_s390x;
188  extern const Arch Arch_s390;
189 
191  extern const Arch Arch_ppc64p7;
193  extern const Arch Arch_ppc64;
195  extern const Arch Arch_ppc;
196 
198  extern const Arch Arch_ia64;
199 
201  extern const Arch Arch_alphaev67;
203  extern const Arch Arch_alphaev6;
205  extern const Arch Arch_alphapca56;
207  extern const Arch Arch_alphaev56;
209  extern const Arch Arch_alphaev5;
211  extern const Arch Arch_alpha;
212 
214  extern const Arch Arch_sparc64v;
216  extern const Arch Arch_sparc64;
218  extern const Arch Arch_sparcv9v;
220  extern const Arch Arch_sparcv9;
222  extern const Arch Arch_sparcv8;
224  extern const Arch Arch_sparc;
225 
227  extern const Arch Arch_aarch64;
229  extern const Arch Arch_armv7tnhl;
231  extern const Arch Arch_armv7thl;
233  extern const Arch Arch_armv7nhl;
235  extern const Arch Arch_armv7hl;
237  extern const Arch Arch_armv7l;
239  extern const Arch Arch_armv6hl;
241  extern const Arch Arch_armv6l;
243  extern const Arch Arch_armv5tejl;
245  extern const Arch Arch_armv5tel;
247  extern const Arch Arch_armv5l;
249  extern const Arch Arch_armv4tl;
251  extern const Arch Arch_armv4l;
253  extern const Arch Arch_armv3l;
254 
256  extern const Arch Arch_sh3;
257 
259  extern const Arch Arch_sh4;
261  extern const Arch Arch_sh4a;
263 
265 
267  inline std::ostream & operator<<( std::ostream & str, const Arch & obj )
268  { return str << obj.asString(); }
269 
271  inline std::ostream & dumpAsXmlOn( std::ostream & str, const Arch & obj )
272  { return str << "<arch>" << obj << "</arch>"; }
273 
277  inline bool operator==( const Arch & lhs, const Arch & rhs )
278  { return lhs.asString() == rhs.asString(); }
279 
281  inline bool operator==( const Arch & lhs, const std::string & rhs )
282  { return lhs.asString() == rhs; }
283 
285  inline bool operator==( const std::string & lhs, const Arch & rhs )
286  { return lhs == rhs.asString(); }
287 
289  inline bool operator!=( const Arch & lhs, const Arch & rhs )
290  { return !( lhs == rhs ); }
291 
293  inline bool operator!=( const Arch & lhs, const std::string & rhs )
294  { return !( lhs == rhs ); }
295 
297  inline bool operator!=( const std::string & lhs, const Arch & rhs )
298  { return !( lhs == rhs ); }
300 
302 
306  struct ArchCompatibleWith : public std::unary_function<Arch,bool>
307  {
311  ArchCompatibleWith( const Arch & targetArch_r )
312  : _targetArch( targetArch_r )
313  {}
315  bool operator()( const Arch & rhs ) const
316  { return rhs.compatibleWith( _targetArch ); }
317  };
318 
320 } // namespace zypp
322 
324 namespace std
325 {
326 
327  template<>
328  inline bool less<zypp::Arch>::operator()( const zypp::Arch & lhs, const zypp::Arch & rhs ) const
329  { return lhs.compare( rhs ) < 0; }
331 } // namespace zypp
333 #endif // ZYPP_ARCH_H
const Arch Arch_sh3
Definition: Arch.h:256
const Arch Arch_sparc64
Definition: Arch.h:216
const Arch Arch_armv3l
Definition: Arch.h:253
bool operator!=(const std::string &lhs, const Arch &rhs)
Definition: Arch.h:297
static int compare(const Arch &lhs, const Arch &rhs)
Arch comparison (static version).
Definition: Arch.h:112
bool compatibleWith(const Arch &targetArch_r) const
Compatibility relation.
Definition: Arch.cc:518
const Arch Arch_sh4
Definition: Arch.h:259
const std::string & asString() const
Definition: Arch.cc:502
const Arch Arch_armv5tejl
Definition: Arch.h:243
bool operator!=(const Arch &lhs, const Arch &rhs)
Definition: Arch.h:289
Architecture.
Definition: Arch.h:36
bool operator==(const std::string &lhs, const Arch &rhs)
Definition: Arch.h:285
std::ostream & operator<<(std::ostream &str, const Arch &obj)
Definition: Arch.h:267
IdType id() const
Expert backdoor.
Definition: IdString.h:103
IdString::IdType id() const
Expert backdoor.
Definition: Arch.h:71
const Arch Arch_alpha
Definition: Arch.h:211
std::set< Arch, CompareByGT< Arch > > CompatSet
Reversed arch order, best Arch first.
Definition: Arch.h:117
const Arch Arch_i386
Definition: Arch.h:183
const Arch Arch_athlon
Definition: Arch.h:175
const Arch Arch_alphaev67
Definition: Arch.h:201
bool operator()(const Arch &rhs) const
Call Arch::compatibleWith ( _targetArch ) on rhs.
Definition: Arch.h:315
const Arch Arch_armv5l
Definition: Arch.h:247
IdString idStr() const
String representation of Arch.
Definition: Arch.cc:494
Access to the sat-pools string space.
Definition: IdString.h:39
const Arch Arch_s390x
Definition: Arch.h:186
const Arch Arch_pentium3
Definition: Arch.h:170
const Arch Arch_empty
Definition: Arch.h:162
const Arch Arch_ppc
Definition: Arch.h:195
bool empty() const
Test for an empty Arch (this is Arch_epmty, not Arch_noarch ).
Definition: Arch.h:63
bool operator==(const Arch &lhs, const Arch &rhs)
Definition: Arch.h:277
const Arch Arch_sparcv9v
Definition: Arch.h:218
const Arch Arch_armv6hl
Definition: Arch.h:239
const Arch Arch_aarch64
Definition: Arch.h:227
int compare(const Arch &rhs) const
Arch comparison.
Definition: Arch.cc:563
const CompatEntry * _entry
Definition: Arch.h:145
static std::string asString(const CompatSet &cset)
Definition: Arch.h:135
const Arch Arch_armv7tnhl
Definition: Arch.h:229
bool operator==(const Arch &lhs, const std::string &rhs)
Definition: Arch.h:281
std::string join(_Iterator begin, _Iterator end, const C_Str &sep_r=" ")
Join strings using separator sep_r (defaults to BLANK).
Definition: String.h:635
const Arch Arch_alphaev5
Definition: Arch.h:209
const Arch Arch_alphaev56
Definition: Arch.h:207
const Arch Arch_noarch
Definition: Arch.h:165
const Arch Arch_sh4a
Definition: Arch.h:261
sat::detail::IdType IdType
Definition: IdString.h:42
const Arch Arch_armv7thl
Definition: Arch.h:231
const Arch Arch_sparc
Definition: Arch.h:224
const Arch Arch_armv7l
Definition: Arch.h:237
const Arch Arch_i486
Definition: Arch.h:181
const Arch Arch_s390
Definition: Arch.h:188
const Arch Arch_sparcv9
Definition: Arch.h:220
const Arch Arch_armv7nhl
Definition: Arch.h:233
static CompatSet compatSet(const Arch &targetArch_r)
Return a set of all Arch&#39;s compatibleWith a targetArch_r.
Definition: Arch.cc:571
bool operator!=(const Arch &lhs, const std::string &rhs)
Definition: Arch.h:293
const Arch Arch_x86_64
Definition: Arch.h:173
const Arch Arch_ppc64p7
Definition: Arch.h:191
const char * c_str() const
Definition: Arch.h:59
const Arch Arch_alphaev6
Definition: Arch.h:203
const Arch Arch_ppc64
Definition: Arch.h:193
static Arch baseArch(const Arch &targetArch_r)
Definition: Arch.h:101
const Arch Arch_sparc64v
Definition: Arch.h:214
ArchCompatibleWith(const Arch &targetArch_r)
Ctor taking the target architecture.
Definition: Arch.h:311
const Arch Arch_armv4tl
Definition: Arch.h:249
const Arch Arch_armv4l
Definition: Arch.h:251
Arch()
Default ctor Arc_noarch.
Definition: Arch.cc:465
const Arch Arch_pentium4
Definition: Arch.h:168
Arch baseArch() const
Definition: Arch.cc:526
const Arch Arch_sparcv8
Definition: Arch.h:222
bool isBuiltIn() const
Whether this is a buitin (or known) architecture.
Definition: Arch.cc:510
const Arch Arch_alphapca56
Definition: Arch.h:205
const Arch Arch_armv7hl
Definition: Arch.h:235
const Arch Arch_armv5tel
Definition: Arch.h:245
Arch _targetArch
The target architecture.
Definition: Arch.h:309
const Arch Arch_armv6l
Definition: Arch.h:241
const Arch Arch_i586
Definition: Arch.h:179
unsigned size() const
Size of the string representation.
Definition: Arch.h:67
const Arch Arch_i686
Definition: Arch.h:177
std::ostream & dumpAsXmlOn(std::ostream &str, const Arch &obj)
Definition: Arch.h:271
Functor finding compatible architectures.
Definition: Arch.h:306
Holds an architecture ID and it&#39;s compatible relation.
Definition: Arch.cc:38
const Arch Arch_ia64
Definition: Arch.h:198