libzypp 17.37.17
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 //
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:
54
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(); }
73
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 using CompatSet = std::set<Arch, CompareByGT<Arch>>;
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 };
150
151
159
166
168 extern const Arch Arch_noarch ZYPP_API;
169
171 extern const Arch Arch_pentium4 ZYPP_API;
173 extern const Arch Arch_pentium3 ZYPP_API;
174
176 extern const Arch Arch_x86_64_v4 ZYPP_API;
178 extern const Arch Arch_x86_64_v3 ZYPP_API;
180 extern const Arch Arch_x86_64_v2 ZYPP_API;
182 extern const Arch Arch_x86_64 ZYPP_API;
184 extern const Arch Arch_athlon ZYPP_API;
186 extern const Arch Arch_i686 ZYPP_API;
188 extern const Arch Arch_i586 ZYPP_API;
190 extern const Arch Arch_i486 ZYPP_API;
192 extern const Arch Arch_i386 ZYPP_API;
193
195 extern const Arch Arch_s390x ZYPP_API;
197 extern const Arch Arch_s390 ZYPP_API;
198
200 extern const Arch Arch_ppc64le ZYPP_API;
201
203 extern const Arch Arch_ppc64p7 ZYPP_API;
205 extern const Arch Arch_ppc64 ZYPP_API;
207 extern const Arch Arch_ppc ZYPP_API;
208
210 extern const Arch Arch_ia64 ZYPP_API;
211
213 extern const Arch Arch_alphaev67 ZYPP_API;
215 extern const Arch Arch_alphaev6 ZYPP_API;
217 extern const Arch Arch_alphapca56 ZYPP_API;
219 extern const Arch Arch_alphaev56 ZYPP_API;
221 extern const Arch Arch_alphaev5 ZYPP_API;
223 extern const Arch Arch_alpha ZYPP_API;
224
226 extern const Arch Arch_sparc64v ZYPP_API;
228 extern const Arch Arch_sparc64 ZYPP_API;
230 extern const Arch Arch_sparcv9v ZYPP_API;
232 extern const Arch Arch_sparcv9 ZYPP_API;
234 extern const Arch Arch_sparcv8 ZYPP_API;
236 extern const Arch Arch_sparc ZYPP_API;
237
239 extern const Arch Arch_aarch64 ZYPP_API;
240
242 extern const Arch Arch_armv7tnh ZYPP_API; /* exists? */
244 extern const Arch Arch_armv7thl ZYPP_API; /* exists? */
245
247 extern const Arch Arch_armv7hnl ZYPP_API, /* legacy: */Arch_armv7nhl ZYPP_API;
249 extern const Arch Arch_armv7hl ZYPP_API;
251 extern const Arch Arch_armv6hl ZYPP_API;
252
254 extern const Arch Arch_armv8hl ZYPP_API;
256 extern const Arch Arch_armv8l ZYPP_API;
258 extern const Arch Arch_armv7l ZYPP_API;
260 extern const Arch Arch_armv6l ZYPP_API;
262 extern const Arch Arch_armv5tejl ZYPP_API;
264 extern const Arch Arch_armv5tel ZYPP_API;
266 extern const Arch Arch_armv5tl ZYPP_API;
268 extern const Arch Arch_armv5l ZYPP_API;
270 extern const Arch Arch_armv4tl ZYPP_API;
272 extern const Arch Arch_armv4l ZYPP_API;
274 extern const Arch Arch_armv3l ZYPP_API;
275
277 extern const Arch Arch_riscv64 ZYPP_API;
278
280 extern const Arch Arch_sh3 ZYPP_API;
281
283 extern const Arch Arch_sh4 ZYPP_API;
285 extern const Arch Arch_sh4a ZYPP_API;
286
288 extern const Arch Arch_m68k ZYPP_API;
289
291 extern const Arch Arch_mips ZYPP_API;
293 extern const Arch Arch_mipsel ZYPP_API;
295 extern const Arch Arch_mips64 ZYPP_API;
297 extern const Arch Arch_mips64el ZYPP_API;
298
300 extern const Arch Arch_loong64 ZYPP_API;
302
304
306 inline std::ostream & operator<<( std::ostream & str, const Arch & obj )
307 { return str << obj.asString(); }
308
310 inline std::ostream & dumpAsXmlOn( std::ostream & str, const Arch & obj )
311 { return str << "<arch>" << obj << "</arch>"; }
312
315
316 inline bool operator==( const Arch & lhs, const Arch & rhs )
317 { return lhs.asString() == rhs.asString(); }
318
320 inline bool operator==( const Arch & lhs, const std::string & rhs )
321 { return lhs.asString() == rhs; }
322
324 inline bool operator==( const std::string & lhs, const Arch & rhs )
325 { return lhs == rhs.asString(); }
326
328 inline bool operator!=( const Arch & lhs, const Arch & rhs )
329 { return !( lhs == rhs ); }
330
332 inline bool operator!=( const Arch & lhs, const std::string & rhs )
333 { return !( lhs == rhs ); }
334
336 inline bool operator!=( const std::string & lhs, const Arch & rhs )
337 { return !( lhs == rhs ); }
338
339
341
346 {
350 ArchCompatibleWith( const Arch & targetArch_r )
351 : _targetArch( targetArch_r )
352 {}
353
354 bool operator()( const Arch & rhs ) const
355 { return rhs.compatibleWith( _targetArch ); }
356 };
357
359} // namespace zypp
361
363namespace std
364{
366 template<>
367#ifdef __clang__
368constexpr
369#endif
370 inline bool less<zypp::Arch>::operator()( const zypp::Arch & lhs, const zypp::Arch & rhs ) const
371 { return lhs.compare( rhs ) < 0; }
372
373} // namespace zypp
374
375#endif // ZYPP_ARCH_H
Architecture.
Definition Arch.h:37
bool operator!=(const Arch &lhs, const std::string &rhs)
Definition Arch.h:332
std::ostream & dumpAsXmlOn(std::ostream &str, const Arch &obj)
XML output.
Definition Arch.h:310
bool operator!=(const std::string &lhs, const Arch &rhs)
Definition Arch.h:336
bool operator==(const std::string &lhs, const Arch &rhs)
Definition Arch.h:324
const CompatEntry * _entry
Definition Arch.h:148
Arch baseArch() const
Definition Arch.cc:523
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
static std::string asString(const CompatSet &cset)
Definition Arch.h:135
static int compare(const Arch &lhs, const Arch &rhs)
Arch comparison (static version).
Definition Arch.h:112
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:328
int compare(const Arch &rhs) const
Arch comparison.
Definition Arch.cc:560
Arch()
Default ctor Arc_noarch.
Definition Arch.cc:462
bool operator==(const Arch &lhs, const std::string &rhs)
Definition Arch.h:320
static CompatSet compatSet(const Arch &targetArch_r)
Return a set of all Arch's compatibleWith a targetArch_r.
Definition Arch.cc:568
unsigned size() const
Size of the string representation.
Definition Arch.h:67
IdString idStr() const
String representation of Arch.
Definition Arch.cc:491
IdString::IdType id() const
Expert backdoor.
Definition Arch.h:71
bool operator==(const Arch &lhs, const Arch &rhs)
Definition Arch.h:316
std::ostream & operator<<(std::ostream &str, const Arch &obj)
stream output.
Definition Arch.h:306
const std::string & asString() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition Arch.cc:499
const Arch Arch_empty ZYPP_API
This is an empty Arch represented by an empty string.
Definition Arch.h:165
std::set< Arch, CompareByGT< Arch > > CompatSet
Reversed arch order, best Arch first.
Definition Arch.h:117
bool compatibleWith(const Arch &targetArch_r) const
Compatibility relation.
Definition Arch.cc:515
static Arch baseArch(const Arch &targetArch_r)
Definition Arch.h:101
Access to the sat-pools string space.
Definition IdString.h:44
sat::detail::IdType IdType
Definition IdString.h:46
Definition Arch.h:364
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:846
Easy-to use interface to the ZYPP dependency resolver.
const Arch Arch_empty(IdString::Empty)
std::string asString(const Patch::Category &obj)
Definition Patch.cc:122
Arch _targetArch
The target architecture.
Definition Arch.h:348
ArchCompatibleWith(const Arch &targetArch_r)
Ctor taking the target architecture.
Definition Arch.h:350
bool operator()(const Arch &rhs) const
Call Arch::compatibleWith ( _targetArch ) on rhs.
Definition Arch.h:354
Holds an architecture ID and its compatible relation.
Definition Arch.cc:39