libzypp  17.5.1
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_ppc64le;
192 
194  extern const Arch Arch_ppc64p7;
196  extern const Arch Arch_ppc64;
198  extern const Arch Arch_ppc;
199 
201  extern const Arch Arch_ia64;
202 
204  extern const Arch Arch_alphaev67;
206  extern const Arch Arch_alphaev6;
208  extern const Arch Arch_alphapca56;
210  extern const Arch Arch_alphaev56;
212  extern const Arch Arch_alphaev5;
214  extern const Arch Arch_alpha;
215 
217  extern const Arch Arch_sparc64v;
219  extern const Arch Arch_sparc64;
221  extern const Arch Arch_sparcv9v;
223  extern const Arch Arch_sparcv9;
225  extern const Arch Arch_sparcv8;
227  extern const Arch Arch_sparc;
228 
230  extern const Arch Arch_aarch64;
231 
233  extern const Arch Arch_armv7tnhl; /* exists? */
235  extern const Arch Arch_armv7thl; /* exists? */
236 
238  extern const Arch Arch_armv7hnl, /* legacy: */Arch_armv7nhl;
240  extern const Arch Arch_armv7hl;
242  extern const Arch Arch_armv6hl;
243 
245  extern const Arch Arch_armv7l;
247  extern const Arch Arch_armv6l;
249  extern const Arch Arch_armv5tejl;
251  extern const Arch Arch_armv5tel;
253  extern const Arch Arch_armv5tl;
255  extern const Arch Arch_armv5l;
257  extern const Arch Arch_armv4tl;
259  extern const Arch Arch_armv4l;
261  extern const Arch Arch_armv3l;
262 
264  extern const Arch Arch_sh3;
265 
267  extern const Arch Arch_sh4;
269  extern const Arch Arch_sh4a;
270 
272  extern const Arch Arch_m68k;
273 
275  extern const Arch Arch_mips;
277  extern const Arch Arch_mipsel;
279  extern const Arch Arch_mips64;
281  extern const Arch Arch_mips64el;
283 
285 
287  inline std::ostream & operator<<( std::ostream & str, const Arch & obj )
288  { return str << obj.asString(); }
289 
291  inline std::ostream & dumpAsXmlOn( std::ostream & str, const Arch & obj )
292  { return str << "<arch>" << obj << "</arch>"; }
293 
297  inline bool operator==( const Arch & lhs, const Arch & rhs )
298  { return lhs.asString() == rhs.asString(); }
299 
301  inline bool operator==( const Arch & lhs, const std::string & rhs )
302  { return lhs.asString() == rhs; }
303 
305  inline bool operator==( const std::string & lhs, const Arch & rhs )
306  { return lhs == rhs.asString(); }
307 
309  inline bool operator!=( const Arch & lhs, const Arch & rhs )
310  { return !( lhs == rhs ); }
311 
313  inline bool operator!=( const Arch & lhs, const std::string & rhs )
314  { return !( lhs == rhs ); }
315 
317  inline bool operator!=( const std::string & lhs, const Arch & rhs )
318  { return !( lhs == rhs ); }
320 
322 
326  struct ArchCompatibleWith : public std::unary_function<Arch,bool>
327  {
331  ArchCompatibleWith( const Arch & targetArch_r )
332  : _targetArch( targetArch_r )
333  {}
335  bool operator()( const Arch & rhs ) const
336  { return rhs.compatibleWith( _targetArch ); }
337  };
338 
340 } // namespace zypp
342 
344 namespace std
345 {
346 
347  template<>
348  inline bool less<zypp::Arch>::operator()( const zypp::Arch & lhs, const zypp::Arch & rhs ) const
349  { return lhs.compare( rhs ) < 0; }
351 } // namespace zypp
353 #endif // ZYPP_ARCH_H
const Arch Arch_sh3
Definition: Arch.h:264
const Arch Arch_sparc64
Definition: Arch.h:219
const Arch Arch_armv3l
Definition: Arch.h:261
bool operator!=(const std::string &lhs, const Arch &rhs)
Definition: Arch.h:317
static int compare(const Arch &lhs, const Arch &rhs)
Arch comparison (static version).
Definition: Arch.h:112
unsigned size() const
Size of the string representation.
Definition: Arch.h:67
const Arch Arch_sh4
Definition: Arch.h:267
const Arch Arch_armv5tejl
Definition: Arch.h:249
bool operator!=(const Arch &lhs, const Arch &rhs)
Definition: Arch.h:309
Architecture.
Definition: Arch.h:36
bool operator==(const std::string &lhs, const Arch &rhs)
Definition: Arch.h:305
std::string join(TIterator begin, TIterator end, const C_Str &sep_r=" ")
Join strings using separator sep_r (defaults to BLANK).
Definition: String.h:742
std::ostream & operator<<(std::ostream &str, const Arch &obj)
Definition: Arch.h:287
bool empty() const
Test for an empty Arch (this is Arch_epmty, not Arch_noarch ).
Definition: Arch.h:63
const Arch Arch_alpha
Definition: Arch.h:214
std::set< Arch, CompareByGT< Arch > > CompatSet
Reversed arch order, best Arch first.
Definition: Arch.h:117
IdType id() const
Expert backdoor.
Definition: IdString.h:115
const Arch Arch_mips
Definition: Arch.h:275
const Arch Arch_i386
Definition: Arch.h:183
const Arch Arch_athlon
Definition: Arch.h:175
const Arch Arch_alphaev67
Definition: Arch.h:204
String related utilities and Regular expression matching.
const Arch Arch_armv5l
Definition: Arch.h:255
Definition: Arch.h:344
Access to the sat-pools string space.
Definition: IdString.h:41
const Arch Arch_s390x
Definition: Arch.h:186
const Arch Arch_pentium3
Definition: Arch.h:170
int compare(const Arch &rhs) const
Arch comparison.
Definition: Arch.cc:542
const Arch Arch_empty
Definition: Arch.h:162
bool compatibleWith(const Arch &targetArch_r) const
Compatibility relation.
Definition: Arch.cc:497
const Arch Arch_ppc64le
Definition: Arch.h:191
const Arch Arch_ppc
Definition: Arch.h:198
bool operator==(const Arch &lhs, const Arch &rhs)
Definition: Arch.h:297
const char * c_str() const
Definition: Arch.h:59
const Arch Arch_sparcv9v
Definition: Arch.h:221
const Arch Arch_armv6hl
Definition: Arch.h:242
const Arch Arch_aarch64
Definition: Arch.h:230
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:233
bool operator==(const Arch &lhs, const std::string &rhs)
Definition: Arch.h:301
const Arch Arch_alphaev5
Definition: Arch.h:212
const Arch Arch_alphaev56
Definition: Arch.h:210
const Arch Arch_noarch
Definition: Arch.h:165
const Arch Arch_sh4a
Definition: Arch.h:269
sat::detail::IdType IdType
Definition: IdString.h:44
const Arch Arch_armv7thl
Definition: Arch.h:235
const Arch Arch_mips64
Definition: Arch.h:279
const Arch Arch_mipsel
Definition: Arch.h:277
Arch baseArch() const
Definition: Arch.cc:505
const Arch Arch_sparc
Definition: Arch.h:227
const Arch Arch_armv7l
Definition: Arch.h:245
const Arch Arch_i486
Definition: Arch.h:181
const Arch Arch_s390
Definition: Arch.h:188
const Arch Arch_m68k
Definition: Arch.h:272
const Arch Arch_sparcv9
Definition: Arch.h:223
IdString::IdType id() const
Expert backdoor.
Definition: Arch.h:71
static CompatSet compatSet(const Arch &targetArch_r)
Return a set of all Arch&#39;s compatibleWith a targetArch_r.
Definition: Arch.cc:550
bool operator!=(const Arch &lhs, const std::string &rhs)
Definition: Arch.h:313
const Arch Arch_armv5tl
Definition: Arch.h:253
const Arch Arch_x86_64
Definition: Arch.h:173
const Arch Arch_ppc64p7
Definition: Arch.h:194
const Arch Arch_armv7nhl
const Arch Arch_alphaev6
Definition: Arch.h:206
const Arch Arch_ppc64
Definition: Arch.h:196
static Arch baseArch(const Arch &targetArch_r)
Definition: Arch.h:101
const Arch Arch_sparc64v
Definition: Arch.h:217
ArchCompatibleWith(const Arch &targetArch_r)
Ctor taking the target architecture.
Definition: Arch.h:331
const Arch Arch_armv4tl
Definition: Arch.h:257
IdString idStr() const
String representation of Arch.
Definition: Arch.cc:473
const Arch Arch_armv4l
Definition: Arch.h:259
Arch()
Default ctor Arc_noarch.
Definition: Arch.cc:444
const Arch Arch_pentium4
Definition: Arch.h:168
const Arch Arch_sparcv8
Definition: Arch.h:225
const Arch Arch_alphapca56
Definition: Arch.h:208
const Arch Arch_armv7hl
Definition: Arch.h:240
const Arch Arch_armv5tel
Definition: Arch.h:251
bool isBuiltIn() const
Whether this is a buitin (or known) architecture.
Definition: Arch.cc:489
Arch _targetArch
The target architecture.
Definition: Arch.h:329
const std::string & asString() const
Definition: Arch.cc:481
const Arch Arch_armv6l
Definition: Arch.h:247
bool operator()(const Arch &rhs) const
Call Arch::compatibleWith ( _targetArch ) on rhs.
Definition: Arch.h:335
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
const Arch Arch_i586
Definition: Arch.h:179
const Arch Arch_mips64el
Definition: Arch.h:281
const Arch Arch_i686
Definition: Arch.h:177
std::ostream & dumpAsXmlOn(std::ostream &str, const Arch &obj)
Definition: Arch.h:291
const Arch Arch_armv7hnl
Definition: Arch.h:238
Functor finding compatible architectures.
Definition: Arch.h:326
Holds an architecture ID and it&#39;s compatible relation.
Definition: Arch.cc:38
const Arch Arch_ia64
Definition: Arch.h:201