libzypp 17.31.23
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
27namespace 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 // Explicitely select the overload we want, clang seems to choke if there is a static overload for the
138 // member function we want to capture in std::mem_fn (fixes GH-478)
139 const std::string & (Arch::*memfn)( ) const = &Arch::asString;
140 return str::join( make_transform_iterator( cset.begin(), std::mem_fn( memfn ) ),
141 make_transform_iterator( cset.end(), std::mem_fn( memfn ) ) );
142 }
143
144 public:
145 struct CompatEntry;
146 private:
147 Arch( const CompatEntry & );
149 };
151
165 extern const Arch Arch_empty;
166
168 extern const Arch Arch_noarch;
169
171 extern const Arch Arch_pentium4;
173 extern const Arch Arch_pentium3;
174
176 extern const Arch Arch_x86_64_v4;
178 extern const Arch Arch_x86_64_v3;
180 extern const Arch Arch_x86_64_v2;
182 extern const Arch Arch_x86_64;
184 extern const Arch Arch_athlon;
186 extern const Arch Arch_i686;
188 extern const Arch Arch_i586;
190 extern const Arch Arch_i486;
192 extern const Arch Arch_i386;
193
195 extern const Arch Arch_s390x;
197 extern const Arch Arch_s390;
198
200 extern const Arch Arch_ppc64le;
201
203 extern const Arch Arch_ppc64p7;
205 extern const Arch Arch_ppc64;
207 extern const Arch Arch_ppc;
208
210 extern const Arch Arch_ia64;
211
213 extern const Arch Arch_alphaev67;
215 extern const Arch Arch_alphaev6;
217 extern const Arch Arch_alphapca56;
219 extern const Arch Arch_alphaev56;
221 extern const Arch Arch_alphaev5;
223 extern const Arch Arch_alpha;
224
226 extern const Arch Arch_sparc64v;
228 extern const Arch Arch_sparc64;
230 extern const Arch Arch_sparcv9v;
232 extern const Arch Arch_sparcv9;
234 extern const Arch Arch_sparcv8;
236 extern const Arch Arch_sparc;
237
239 extern const Arch Arch_aarch64;
240
242 extern const Arch Arch_armv7tnhl; /* exists? */
244 extern const Arch Arch_armv7thl; /* exists? */
245
247 extern const Arch Arch_armv7hnl, /* legacy: */Arch_armv7nhl;
249 extern const Arch Arch_armv7hl;
251 extern const Arch Arch_armv6hl;
252
254 extern const Arch Arch_armv8hl;
256 extern const Arch Arch_armv8l;
258 extern const Arch Arch_armv7l;
260 extern const Arch Arch_armv6l;
262 extern const Arch Arch_armv5tejl;
264 extern const Arch Arch_armv5tel;
266 extern const Arch Arch_armv5tl;
268 extern const Arch Arch_armv5l;
270 extern const Arch Arch_armv4tl;
272 extern const Arch Arch_armv4l;
274 extern const Arch Arch_armv3l;
275
277 extern const Arch Arch_riscv64;
278
280 extern const Arch Arch_sh3;
281
283 extern const Arch Arch_sh4;
285 extern const Arch Arch_sh4a;
286
288 extern const Arch Arch_m68k;
289
291 extern const Arch Arch_mips;
293 extern const Arch Arch_mipsel;
295 extern const Arch Arch_mips64;
297 extern const Arch Arch_mips64el;
299
301
303 inline std::ostream & operator<<( std::ostream & str, const Arch & obj )
304 { return str << obj.asString(); }
305
307 inline std::ostream & dumpAsXmlOn( std::ostream & str, const Arch & obj )
308 { return str << "<arch>" << obj << "</arch>"; }
309
313 inline bool operator==( const Arch & lhs, const Arch & rhs )
314 { return lhs.asString() == rhs.asString(); }
315
317 inline bool operator==( const Arch & lhs, const std::string & rhs )
318 { return lhs.asString() == rhs; }
319
321 inline bool operator==( const std::string & lhs, const Arch & rhs )
322 { return lhs == rhs.asString(); }
323
325 inline bool operator!=( const Arch & lhs, const Arch & rhs )
326 { return !( lhs == rhs ); }
327
329 inline bool operator!=( const Arch & lhs, const std::string & rhs )
330 { return !( lhs == rhs ); }
331
333 inline bool operator!=( const std::string & lhs, const Arch & rhs )
334 { return !( lhs == rhs ); }
336
338
343 {
347 ArchCompatibleWith( const Arch & targetArch_r )
348 : _targetArch( targetArch_r )
349 {}
351 bool operator()( const Arch & rhs ) const
352 { return rhs.compatibleWith( _targetArch ); }
353 };
354
356} // namespace zypp
358
360namespace std
361{
363 template<>
364#ifdef __clang__
365constexpr
366#endif
367 inline bool less<zypp::Arch>::operator()( const zypp::Arch & lhs, const zypp::Arch & rhs ) const
368 { return lhs.compare( rhs ) < 0; }
370} // namespace zypp
372#endif // ZYPP_ARCH_H
Architecture.
Definition: Arch.h:37
const Arch Arch_mips64el
Definition: Arch.h:297
const Arch Arch_alphaev6
Definition: Arch.h:215
const Arch Arch_m68k
Definition: Arch.h:288
const Arch Arch_x86_64_v2
Definition: Arch.h:180
const Arch Arch_armv7l
Definition: Arch.h:258
bool operator!=(const Arch &lhs, const std::string &rhs)
Definition: Arch.h:329
std::ostream & dumpAsXmlOn(std::ostream &str, const Arch &obj)
XML output.
Definition: Arch.h:307
const Arch Arch_ppc64
Definition: Arch.h:205
const Arch Arch_mips
Definition: Arch.h:291
const Arch Arch_x86_64_v3
Definition: Arch.h:178
const Arch Arch_sparcv8
Definition: Arch.h:234
const Arch Arch_i586
Definition: Arch.h:188
const Arch Arch_armv3l
Definition: Arch.h:274
const Arch Arch_armv7hl
Definition: Arch.h:249
const Arch Arch_sh4a
Definition: Arch.h:285
const Arch Arch_i486
Definition: Arch.h:190
const Arch Arch_athlon
Definition: Arch.h:184
bool operator!=(const std::string &lhs, const Arch &rhs)
Definition: Arch.h:333
const Arch Arch_armv5tejl
Definition: Arch.h:262
bool operator==(const std::string &lhs, const Arch &rhs)
Definition: Arch.h:321
const CompatEntry * _entry
Definition: Arch.h:148
Arch baseArch() const
Definition: Arch.cc:519
std::set< Arch, CompareByGT< Arch > > CompatSet
Reversed arch order, best Arch first.
Definition: Arch.h:117
const Arch Arch_armv4tl
Definition: Arch.h:270
const Arch Arch_sparc64
Definition: Arch.h:228
const char * c_str() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: Arch.h:59
const Arch Arch_alphaev67
Definition: Arch.h:213
static std::string asString(const CompatSet &cset)
Definition: Arch.h:135
const Arch Arch_pentium3
Definition: Arch.h:173
static int compare(const Arch &lhs, const Arch &rhs)
Arch comparison (static version).
Definition: Arch.h:112
const Arch Arch_sh3
Definition: Arch.h:280
const Arch Arch_armv7thl
Definition: Arch.h:244
const Arch Arch_sparc64v
Definition: Arch.h:226
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:325
const Arch Arch_armv8l
Definition: Arch.h:256
const Arch Arch_s390x
Definition: Arch.h:195
const Arch Arch_mips64
Definition: Arch.h:295
int compare(const Arch &rhs) const
Arch comparison.
Definition: Arch.cc:556
const Arch Arch_empty
This is an empty Arch represented by an empty string.
Definition: Arch.h:165
Arch()
Default ctor Arc_noarch.
Definition: Arch.cc:458
const Arch Arch_sparc
Definition: Arch.h:236
const Arch Arch_armv5tel
Definition: Arch.h:264
bool operator==(const Arch &lhs, const std::string &rhs)
Definition: Arch.h:317
const Arch Arch_pentium4
Definition: Arch.h:171
static CompatSet compatSet(const Arch &targetArch_r)
Return a set of all Arch's compatibleWith a targetArch_r.
Definition: Arch.cc:564
unsigned size() const
Size of the string representation.
Definition: Arch.h:67
bool isBuiltIn() const
Whether this is a buitin (or known) architecture.
Definition: Arch.cc:503
IdString idStr() const
String representation of Arch.
Definition: Arch.cc:487
const Arch Arch_armv7hnl
Definition: Arch.h:247
const Arch Arch_s390
Definition: Arch.h:197
const Arch Arch_armv5tl
Definition: Arch.h:266
const Arch Arch_sparcv9v
Definition: Arch.h:230
const Arch Arch_armv7tnhl
Definition: Arch.h:242
const Arch Arch_armv8hl
Definition: Arch.h:254
const Arch Arch_ia64
Definition: Arch.h:210
IdString::IdType id() const
Expert backdoor.
Definition: Arch.h:71
bool operator==(const Arch &lhs, const Arch &rhs)
Definition: Arch.h:313
const Arch Arch_riscv64
Definition: Arch.h:277
const Arch Arch_aarch64
Definition: Arch.h:239
const Arch Arch_armv6l
Definition: Arch.h:260
const Arch Arch_alphapca56
Definition: Arch.h:217
const Arch Arch_mipsel
Definition: Arch.h:293
const Arch Arch_x86_64_v4
Definition: Arch.h:176
const Arch Arch_alphaev56
Definition: Arch.h:219
const Arch Arch_i686
Definition: Arch.h:186
const Arch Arch_ppc64le
Definition: Arch.h:200
const Arch Arch_ppc64p7
Definition: Arch.h:203
const Arch Arch_noarch
Definition: Arch.h:168
const Arch Arch_ppc
Definition: Arch.h:207
const Arch Arch_sparcv9
Definition: Arch.h:232
const Arch Arch_armv4l
Definition: Arch.h:272
const Arch Arch_sh4
Definition: Arch.h:283
std::ostream & operator<<(std::ostream &str, const Arch &obj)
stream output.
Definition: Arch.h:303
const Arch Arch_i386
Definition: Arch.h:192
const std::string & asString() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: Arch.cc:495
const Arch Arch_alphaev5
Definition: Arch.h:221
const Arch Arch_alpha
Definition: Arch.h:223
const Arch Arch_armv5l
Definition: Arch.h:268
bool compatibleWith(const Arch &targetArch_r) const
Compatibility relation.
Definition: Arch.cc:511
const Arch Arch_x86_64
Definition: Arch.h:182
static Arch baseArch(const Arch &targetArch_r)
Definition: Arch.h:101
const Arch Arch_armv6hl
Definition: Arch.h:251
Access to the sat-pools string space.
Definition: IdString.h:43
sat::detail::IdType IdType
Definition: IdString.h:45
IdType id() const
Expert backdoor.
Definition: IdString.h:122
Definition: Arch.h:361
String related utilities and Regular expression matching.
std::string join(TIterator begin, TIterator end, const C_Str &sep_r=" ")
Join strings using separator sep_r (defaults to BLANK).
Definition: String.h:776
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
const Arch Arch_armv7nhl
Definition: Arch.h:247
Functor finding compatible architectures.
Definition: Arch.h:343
Arch _targetArch
The target architecture.
Definition: Arch.h:345
ArchCompatibleWith(const Arch &targetArch_r)
Ctor taking the target architecture.
Definition: Arch.h:347
bool operator()(const Arch &rhs) const
Call Arch::compatibleWith ( _targetArch ) on rhs.
Definition: Arch.h:351
Holds an architecture ID and its compatible relation.
Definition: Arch.cc:39