libzypp 17.31.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
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 return str::join( make_transform_iterator( cset.begin(), std::mem_fn(&Arch::asString) ),
138 make_transform_iterator( cset.end(), std::mem_fn(&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_armv8hl;
247 extern const Arch Arch_armv8l;
249 extern const Arch Arch_armv7l;
251 extern const Arch Arch_armv6l;
253 extern const Arch Arch_armv5tejl;
255 extern const Arch Arch_armv5tel;
257 extern const Arch Arch_armv5tl;
259 extern const Arch Arch_armv5l;
261 extern const Arch Arch_armv4tl;
263 extern const Arch Arch_armv4l;
265 extern const Arch Arch_armv3l;
266
268 extern const Arch Arch_riscv64;
269
271 extern const Arch Arch_sh3;
272
274 extern const Arch Arch_sh4;
276 extern const Arch Arch_sh4a;
277
279 extern const Arch Arch_m68k;
280
282 extern const Arch Arch_mips;
284 extern const Arch Arch_mipsel;
286 extern const Arch Arch_mips64;
288 extern const Arch Arch_mips64el;
290
292
294 inline std::ostream & operator<<( std::ostream & str, const Arch & obj )
295 { return str << obj.asString(); }
296
298 inline std::ostream & dumpAsXmlOn( std::ostream & str, const Arch & obj )
299 { return str << "<arch>" << obj << "</arch>"; }
300
304 inline bool operator==( const Arch & lhs, const Arch & rhs )
305 { return lhs.asString() == rhs.asString(); }
306
308 inline bool operator==( const Arch & lhs, const std::string & rhs )
309 { return lhs.asString() == rhs; }
310
312 inline bool operator==( const std::string & lhs, const Arch & rhs )
313 { return lhs == rhs.asString(); }
314
316 inline bool operator!=( const Arch & lhs, const Arch & rhs )
317 { return !( lhs == rhs ); }
318
320 inline bool operator!=( const Arch & lhs, const std::string & rhs )
321 { return !( lhs == rhs ); }
322
324 inline bool operator!=( const std::string & lhs, const Arch & rhs )
325 { return !( lhs == rhs ); }
327
329
334 {
338 ArchCompatibleWith( const Arch & targetArch_r )
339 : _targetArch( targetArch_r )
340 {}
342 bool operator()( const Arch & rhs ) const
343 { return rhs.compatibleWith( _targetArch ); }
344 };
345
347} // namespace zypp
349
351namespace std
352{
354 template<>
355#ifdef __clang__
356constexpr
357#endif
358 inline bool less<zypp::Arch>::operator()( const zypp::Arch & lhs, const zypp::Arch & rhs ) const
359 { return lhs.compare( rhs ) < 0; }
361} // namespace zypp
363#endif // ZYPP_ARCH_H
Architecture.
Definition: Arch.h:37
const Arch Arch_mips64el
Definition: Arch.h:288
const Arch Arch_alphaev6
Definition: Arch.h:206
const Arch Arch_m68k
Definition: Arch.h:279
const Arch Arch_armv7l
Definition: Arch.h:249
bool operator!=(const Arch &lhs, const std::string &rhs)
Definition: Arch.h:320
std::ostream & dumpAsXmlOn(std::ostream &str, const Arch &obj)
XML output.
Definition: Arch.h:298
const Arch Arch_ppc64
Definition: Arch.h:196
const Arch Arch_mips
Definition: Arch.h:282
const Arch Arch_sparcv8
Definition: Arch.h:225
const Arch Arch_i586
Definition: Arch.h:179
const Arch Arch_armv3l
Definition: Arch.h:265
const Arch Arch_armv7hl
Definition: Arch.h:240
const Arch Arch_sh4a
Definition: Arch.h:276
const Arch Arch_i486
Definition: Arch.h:181
const Arch Arch_athlon
Definition: Arch.h:175
bool operator!=(const std::string &lhs, const Arch &rhs)
Definition: Arch.h:324
const Arch Arch_armv5tejl
Definition: Arch.h:253
bool operator==(const std::string &lhs, const Arch &rhs)
Definition: Arch.h:312
const CompatEntry * _entry
Definition: Arch.h:145
Arch baseArch() const
Definition: Arch.cc:513
std::set< Arch, CompareByGT< Arch > > CompatSet
Reversed arch order, best Arch first.
Definition: Arch.h:117
const Arch Arch_armv4tl
Definition: Arch.h:261
const Arch Arch_sparc64
Definition: Arch.h:219
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:204
static std::string asString(const CompatSet &cset)
Definition: Arch.h:135
const Arch Arch_pentium3
Definition: Arch.h:170
static int compare(const Arch &lhs, const Arch &rhs)
Arch comparison (static version).
Definition: Arch.h:112
const Arch Arch_sh3
Definition: Arch.h:271
const Arch Arch_armv7thl
Definition: Arch.h:235
const Arch Arch_sparc64v
Definition: Arch.h:217
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:316
const Arch Arch_armv8l
Definition: Arch.h:247
const Arch Arch_s390x
Definition: Arch.h:186
const Arch Arch_mips64
Definition: Arch.h:286
int compare(const Arch &rhs) const
Arch comparison.
Definition: Arch.cc:550
const Arch Arch_empty
This is an empty Arch represented by an empty string.
Definition: Arch.h:162
Arch()
Default ctor Arc_noarch.
Definition: Arch.cc:452
const Arch Arch_sparc
Definition: Arch.h:227
const Arch Arch_armv5tel
Definition: Arch.h:255
bool operator==(const Arch &lhs, const std::string &rhs)
Definition: Arch.h:308
const Arch Arch_pentium4
Definition: Arch.h:168
static CompatSet compatSet(const Arch &targetArch_r)
Return a set of all Arch's compatibleWith a targetArch_r.
Definition: Arch.cc:558
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:497
IdString idStr() const
String representation of Arch.
Definition: Arch.cc:481
const Arch Arch_armv7hnl
Definition: Arch.h:238
const Arch Arch_s390
Definition: Arch.h:188
const Arch Arch_armv5tl
Definition: Arch.h:257
const Arch Arch_sparcv9v
Definition: Arch.h:221
const Arch Arch_armv7tnhl
Definition: Arch.h:233
const Arch Arch_armv8hl
Definition: Arch.h:245
const Arch Arch_ia64
Definition: Arch.h:201
IdString::IdType id() const
Expert backdoor.
Definition: Arch.h:71
bool operator==(const Arch &lhs, const Arch &rhs)
Definition: Arch.h:304
const Arch Arch_riscv64
Definition: Arch.h:268
const Arch Arch_aarch64
Definition: Arch.h:230
const Arch Arch_armv6l
Definition: Arch.h:251
const Arch Arch_alphapca56
Definition: Arch.h:208
const Arch Arch_mipsel
Definition: Arch.h:284
const Arch Arch_alphaev56
Definition: Arch.h:210
const Arch Arch_i686
Definition: Arch.h:177
const Arch Arch_ppc64le
Definition: Arch.h:191
const Arch Arch_ppc64p7
Definition: Arch.h:194
const Arch Arch_noarch
Definition: Arch.h:165
const Arch Arch_ppc
Definition: Arch.h:198
const Arch Arch_sparcv9
Definition: Arch.h:223
const Arch Arch_armv4l
Definition: Arch.h:263
const Arch Arch_sh4
Definition: Arch.h:274
std::ostream & operator<<(std::ostream &str, const Arch &obj)
stream output.
Definition: Arch.h:294
const Arch Arch_i386
Definition: Arch.h:183
const std::string & asString() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: Arch.cc:489
const Arch Arch_alphaev5
Definition: Arch.h:212
const Arch Arch_alpha
Definition: Arch.h:214
const Arch Arch_armv5l
Definition: Arch.h:259
bool compatibleWith(const Arch &targetArch_r) const
Compatibility relation.
Definition: Arch.cc:505
const Arch Arch_x86_64
Definition: Arch.h:173
static Arch baseArch(const Arch &targetArch_r)
Definition: Arch.h:101
const Arch Arch_armv6hl
Definition: Arch.h:242
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:352
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:238
Functor finding compatible architectures.
Definition: Arch.h:334
Arch _targetArch
The target architecture.
Definition: Arch.h:336
ArchCompatibleWith(const Arch &targetArch_r)
Ctor taking the target architecture.
Definition: Arch.h:338
bool operator()(const Arch &rhs) const
Call Arch::compatibleWith ( _targetArch ) on rhs.
Definition: Arch.h:342
Holds an architecture ID and its compatible relation.
Definition: Arch.cc:39