libzypp: zypp/Arch.h Source File

libzypp 17.25.10

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
71 IdString::IdType id() const
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 & );
145 const CompatEntry * _entry;
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_riscv64;
265
267 extern const Arch Arch_sh3;
268
270 extern const Arch Arch_sh4;
272 extern const Arch Arch_sh4a;
273
275 extern const Arch Arch_m68k;
276
278 extern const Arch Arch_mips;
280 extern const Arch Arch_mipsel;
282 extern const Arch Arch_mips64;
284 extern const Arch Arch_mips64el;
286
288
290 inline std::ostream & operator<<( std::ostream & str, const Arch & obj )
291 { return str << obj.asString(); }
292
294 inline std::ostream & dumpAsXmlOn( std::ostream & str, const Arch & obj )
295 { return str << "<arch>" << obj << "</arch>"; }
296
300 inline bool operator==( const Arch & lhs, const Arch & rhs )
301 { return lhs.asString() == rhs.asString(); }
302
304 inline bool operator==( const Arch & lhs, const std::string & rhs )
305 { return lhs.asString() == rhs; }
306
308 inline bool operator==( const std::string & lhs, const Arch & rhs )
309 { return lhs == rhs.asString(); }
310
312 inline bool operator!=( const Arch & lhs, const Arch & rhs )
313 { return !( lhs == rhs ); }
314
316 inline bool operator!=( const Arch & lhs, const std::string & rhs )
317 { return !( lhs == rhs ); }
318
320 inline bool operator!=( const std::string & lhs, const Arch & rhs )
321 { return !( lhs == rhs ); }
323
325
329 struct ArchCompatibleWith : public std::unary_function<Arch,bool>
330 {
332 Arch _targetArch;
334 ArchCompatibleWith( const Arch & targetArch_r )
335 : _targetArch( targetArch_r )
336 {}
338 bool operator()( const Arch & rhs ) const
339 { return rhs.compatibleWith( _targetArch ); }
340 };
341
343 } // namespace zypp
345
347 namespace std
348 {
350 template<>
351 #ifdef __clang__
352 constexpr
353 #endif
354 inline bool less<zypp::Arch>::operator()( const zypp::Arch & lhs, const zypp::Arch & rhs ) const
355 { return lhs.compare( rhs ) < 0; }
357 } // namespace zypp
359 #endif // ZYPP_ARCH_H
IdStringType.h
Iterator.h
RelCompare.h
String.h
zypp::Arch
Architecture.
Definition: Arch.h:37
zypp::Arch::Arch_mips64el
const Arch Arch_mips64el
Definition: Arch.h:284
zypp::Arch::Arch_alphaev6
const Arch Arch_alphaev6
Definition: Arch.h:206
zypp::Arch::Arch_m68k
const Arch Arch_m68k
Definition: Arch.h:275
zypp::Arch::Arch_armv7l
const Arch Arch_armv7l
Definition: Arch.h:245
zypp::Arch::c_str
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
zypp::Arch::operator!=
bool operator!=(const Arch &lhs, const std::string &rhs)
Definition: Arch.h:316
zypp::Arch::dumpAsXmlOn
std::ostream & dumpAsXmlOn(std::ostream &str, const Arch &obj)
XML output.
Definition: Arch.h:294
zypp::Arch::Arch_ppc64
const Arch Arch_ppc64
Definition: Arch.h:196
zypp::Arch::Arch_mips
const Arch Arch_mips
Definition: Arch.h:278
zypp::Arch::Arch_sparcv8
const Arch Arch_sparcv8
Definition: Arch.h:225
zypp::Arch::Arch_i586
const Arch Arch_i586
Definition: Arch.h:179
zypp::Arch::Arch_armv3l
const Arch Arch_armv3l
Definition: Arch.h:261
zypp::Arch::Arch_armv7hl
const Arch Arch_armv7hl
Definition: Arch.h:240
zypp::Arch::Arch_sh4a
const Arch Arch_sh4a
Definition: Arch.h:272
zypp::Arch::Arch_i486
const Arch Arch_i486
Definition: Arch.h:181
zypp::Arch::Arch_athlon
const Arch Arch_athlon
Definition: Arch.h:175
zypp::Arch::operator!=
bool operator!=(const std::string &lhs, const Arch &rhs)
Definition: Arch.h:320
zypp::Arch::Arch_armv5tejl
const Arch Arch_armv5tejl
Definition: Arch.h:249
zypp::Arch::operator==
bool operator==(const std::string &lhs, const Arch &rhs)
Definition: Arch.h:308
zypp::Arch::_entry
const CompatEntry * _entry
Definition: Arch.h:145
zypp::Arch::baseArch
Arch baseArch() const
Definition: Arch.cc:509
zypp::Arch::CompatSet
std::set< Arch, CompareByGT< Arch > > CompatSet
Reversed arch order, best Arch first.
Definition: Arch.h:117
zypp::Arch::Arch_armv4tl
const Arch Arch_armv4tl
Definition: Arch.h:257
zypp::Arch::Arch_sparc64
const Arch Arch_sparc64
Definition: Arch.h:219
zypp::Arch::Arch_alphaev67
const Arch Arch_alphaev67
Definition: Arch.h:204
zypp::Arch::asString
static std::string asString(const CompatSet &cset)
Definition: Arch.h:135
zypp::Arch::Arch_pentium3
const Arch Arch_pentium3
Definition: Arch.h:170
zypp::Arch::compare
static int compare(const Arch &lhs, const Arch &rhs)
Arch comparison (static version).
Definition: Arch.h:112
zypp::Arch::Arch_sh3
const Arch Arch_sh3
Definition: Arch.h:267
zypp::Arch::Arch_armv7thl
const Arch Arch_armv7thl
Definition: Arch.h:235
zypp::Arch::Arch_sparc64v
const Arch Arch_sparc64v
Definition: Arch.h:217
zypp::Arch::empty
bool empty() const
Test for an empty Arch (this is Arch_epmty, not Arch_noarch ).
Definition: Arch.h:63
zypp::Arch::operator!=
bool operator!=(const Arch &lhs, const Arch &rhs)
Definition: Arch.h:312
zypp::Arch::Arch_s390x
const Arch Arch_s390x
Definition: Arch.h:186
zypp::Arch::Arch_mips64
const Arch Arch_mips64
Definition: Arch.h:282
zypp::Arch::compare
int compare(const Arch &rhs) const
Arch comparison.
Definition: Arch.cc:546
zypp::Arch::Arch_empty
const Arch Arch_empty
This is an empty Arch represented by an empty string.
Definition: Arch.h:162
zypp::Arch::Arch
Arch()
Default ctor Arc_noarch.
Definition: Arch.cc:448
zypp::Arch::Arch_sparc
const Arch Arch_sparc
Definition: Arch.h:227
zypp::Arch::Arch_armv5tel
const Arch Arch_armv5tel
Definition: Arch.h:251
zypp::Arch::operator==
bool operator==(const Arch &lhs, const std::string &rhs)
Definition: Arch.h:304
zypp::Arch::Arch_pentium4
const Arch Arch_pentium4
Definition: Arch.h:168
zypp::Arch::compatSet
static CompatSet compatSet(const Arch &targetArch_r)
Return a set of all Arch's compatibleWith a targetArch_r.
Definition: Arch.cc:554
zypp::Arch::size
unsigned size() const
Size of the string representation.
Definition: Arch.h:67
zypp::Arch::isBuiltIn
bool isBuiltIn() const
Whether this is a buitin (or known) architecture.
Definition: Arch.cc:493
zypp::Arch::idStr
IdString idStr() const
String representation of Arch.
Definition: Arch.cc:477
zypp::Arch::Arch_armv7hnl
const Arch Arch_armv7hnl
Definition: Arch.h:238
zypp::Arch::Arch_s390
const Arch Arch_s390
Definition: Arch.h:188
zypp::Arch::Arch_armv5tl
const Arch Arch_armv5tl
Definition: Arch.h:253
zypp::Arch::Arch_sparcv9v
const Arch Arch_sparcv9v
Definition: Arch.h:221
zypp::Arch::Arch_armv7tnhl
const Arch Arch_armv7tnhl
Definition: Arch.h:233
zypp::Arch::Arch_ia64
const Arch Arch_ia64
Definition: Arch.h:201
zypp::Arch::id
IdString::IdType id() const
Expert backdoor.
Definition: Arch.h:71
zypp::Arch::operator==
bool operator==(const Arch &lhs, const Arch &rhs)
Definition: Arch.h:300
zypp::Arch::Arch_riscv64
const Arch Arch_riscv64
Definition: Arch.h:264
zypp::Arch::Arch_aarch64
const Arch Arch_aarch64
Definition: Arch.h:230
zypp::Arch::Arch_armv6l
const Arch Arch_armv6l
Definition: Arch.h:247
zypp::Arch::Arch_alphapca56
const Arch Arch_alphapca56
Definition: Arch.h:208
zypp::Arch::Arch_mipsel
const Arch Arch_mipsel
Definition: Arch.h:280
zypp::Arch::Arch_alphaev56
const Arch Arch_alphaev56
Definition: Arch.h:210
zypp::Arch::Arch_i686
const Arch Arch_i686
Definition: Arch.h:177
zypp::Arch::Arch_ppc64le
const Arch Arch_ppc64le
Definition: Arch.h:191
zypp::Arch::Arch_ppc64p7
const Arch Arch_ppc64p7
Definition: Arch.h:194
zypp::Arch::Arch_noarch
const Arch Arch_noarch
Definition: Arch.h:165
zypp::Arch::Arch_ppc
const Arch Arch_ppc
Definition: Arch.h:198
zypp::Arch::Arch_sparcv9
const Arch Arch_sparcv9
Definition: Arch.h:223
zypp::Arch::Arch_armv4l
const Arch Arch_armv4l
Definition: Arch.h:259
zypp::Arch::Arch_sh4
const Arch Arch_sh4
Definition: Arch.h:270
zypp::Arch::operator<<
std::ostream & operator<<(std::ostream &str, const Arch &obj)
stream output.
Definition: Arch.h:290
zypp::Arch::Arch_i386
const Arch Arch_i386
Definition: Arch.h:183
zypp::Arch::asString
const std::string & asString() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: Arch.cc:485
zypp::Arch::Arch_alphaev5
const Arch Arch_alphaev5
Definition: Arch.h:212
zypp::Arch::Arch_alpha
const Arch Arch_alpha
Definition: Arch.h:214
zypp::Arch::Arch_armv5l
const Arch Arch_armv5l
Definition: Arch.h:255
zypp::Arch::compatibleWith
bool compatibleWith(const Arch &targetArch_r) const
Compatibility relation.
Definition: Arch.cc:501
zypp::Arch::Arch_x86_64
const Arch Arch_x86_64
Definition: Arch.h:173
zypp::Arch::baseArch
static Arch baseArch(const Arch &targetArch_r)
Definition: Arch.h:101
zypp::Arch::Arch_armv6hl
const Arch Arch_armv6hl
Definition: Arch.h:242
zypp::IdString
Access to the sat-pools string space.
Definition: IdString.h:43
zypp::IdString::IdType
sat::detail::IdType IdType
Definition: IdString.h:45
zypp::IdString::id
IdType id() const
Expert backdoor.
Definition: IdString.h:122
std
Definition: Arch.h:348
str
String related utilities and Regular expression matching.
zypp::str::join
std::string join(TIterator begin, TIterator end, const C_Str &sep_r=" ")
Join strings using separator sep_r (defaults to BLANK).
Definition: String.h:772
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
zypp::Arch_armv7nhl
const Arch Arch_armv7nhl
Definition: Arch.h:238
zypp::ArchCompatibleWith
Functor finding compatible architectures.
Definition: Arch.h:330
zypp::ArchCompatibleWith::_targetArch
Arch _targetArch
The target architecture.
Definition: Arch.h:332
zypp::ArchCompatibleWith::ArchCompatibleWith
ArchCompatibleWith(const Arch &targetArch_r)
Ctor taking the target architecture.
Definition: Arch.h:334
zypp::ArchCompatibleWith::operator()
bool operator()(const Arch &rhs) const
Call Arch::compatibleWith ( _targetArch ) on rhs.
Definition: Arch.h:338
zypp::Arch::CompatEntry
Holds an architecture ID and it's compatible relation.
Definition: Arch.cc:39