libzypp: zypp/Arch.h Source File

libzypp 17.38.11

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-core/base/String.h>
21#include <zypp-core/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 ZYPP_API 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
51 static Arch detectSystemArchitecture();
52
53 public:
59
60 IdString idStr() const;
62 const std::string & asString() const;
64 const char * c_str() const
65 { return asString().c_str(); }
66
68 bool empty() const
69 { return asString().empty(); }
70
72 unsigned size() const
73 { return asString().size(); }
74
76 IdString::IdType id() const
77 { return idStr().id(); }
78
79
80 public:
86 bool isBuiltIn() const;
87
88 public:
97 bool compatibleWith( const Arch & targetArch_r ) const;
98
103 Arch baseArch() const;
104
106 static Arch baseArch( const Arch & targetArch_r )
107 { return targetArch_r.baseArch(); }
108
114 int compare( const Arch & rhs ) const;
115
117 static int compare( const Arch & lhs, const Arch & rhs )
118 { return lhs.compare( rhs ); }
119
120 public:
122 using CompatSet = std::set<Arch, CompareByGT<Arch>>;
123
137 static CompatSet compatSet( const Arch & targetArch_r );
138
140 static std::string asString( const CompatSet & cset )
141 {
142 // Explicitely select the overload we want, clang seems to choke if there is a static overload for the
143 // member function we want to capture in std::mem_fn (fixes GH-478)
144 const std::string & (Arch::*memfn)( ) const = &Arch::asString;
145 return str::join( make_transform_iterator( cset.begin(), std::mem_fn( memfn ) ),
146 make_transform_iterator( cset.end(), std::mem_fn( memfn ) ) );
147 }
148
149 public:
150 struct CompatEntry;
151 private:
152 Arch( const CompatEntry & );
153 const CompatEntry * _entry;
154 };
155
156
164
170 extern const Arch Arch_empty ZYPP_API;
171
173 extern const Arch Arch_noarch ZYPP_API;
174
176 extern const Arch Arch_pentium4 ZYPP_API;
178 extern const Arch Arch_pentium3 ZYPP_API;
179
181 extern const Arch Arch_x86_64_v4 ZYPP_API;
183 extern const Arch Arch_x86_64_v3 ZYPP_API;
185 extern const Arch Arch_x86_64_v2 ZYPP_API;
187 extern const Arch Arch_x86_64 ZYPP_API;
189 extern const Arch Arch_athlon ZYPP_API;
191 extern const Arch Arch_i686 ZYPP_API;
193 extern const Arch Arch_i586 ZYPP_API;
195 extern const Arch Arch_i486 ZYPP_API;
197 extern const Arch Arch_i386 ZYPP_API;
198
200 extern const Arch Arch_s390x ZYPP_API;
202 extern const Arch Arch_s390 ZYPP_API;
203
205 extern const Arch Arch_ppc64le ZYPP_API;
206
208 extern const Arch Arch_ppc64p7 ZYPP_API;
210 extern const Arch Arch_ppc64 ZYPP_API;
212 extern const Arch Arch_ppc ZYPP_API;
213
215 extern const Arch Arch_ia64 ZYPP_API;
216
218 extern const Arch Arch_alphaev67 ZYPP_API;
220 extern const Arch Arch_alphaev6 ZYPP_API;
222 extern const Arch Arch_alphapca56 ZYPP_API;
224 extern const Arch Arch_alphaev56 ZYPP_API;
226 extern const Arch Arch_alphaev5 ZYPP_API;
228 extern const Arch Arch_alpha ZYPP_API;
229
231 extern const Arch Arch_sparc64v ZYPP_API;
233 extern const Arch Arch_sparc64 ZYPP_API;
235 extern const Arch Arch_sparcv9v ZYPP_API;
237 extern const Arch Arch_sparcv9 ZYPP_API;
239 extern const Arch Arch_sparcv8 ZYPP_API;
241 extern const Arch Arch_sparc ZYPP_API;
242
244 extern const Arch Arch_aarch64 ZYPP_API;
245
247 extern const Arch Arch_armv7tnh ZYPP_API; /* exists? */
249 extern const Arch Arch_armv7thl ZYPP_API; /* exists? */
250
252 extern const Arch Arch_armv7hnl ZYPP_API, /* legacy: */Arch_armv7nhl ZYPP_API;
254 extern const Arch Arch_armv7hl ZYPP_API;
256 extern const Arch Arch_armv6hl ZYPP_API;
257
259 extern const Arch Arch_armv8hl ZYPP_API;
261 extern const Arch Arch_armv8l ZYPP_API;
263 extern const Arch Arch_armv7l ZYPP_API;
265 extern const Arch Arch_armv6l ZYPP_API;
267 extern const Arch Arch_armv5tejl ZYPP_API;
269 extern const Arch Arch_armv5tel ZYPP_API;
271 extern const Arch Arch_armv5tl ZYPP_API;
273 extern const Arch Arch_armv5l ZYPP_API;
275 extern const Arch Arch_armv4tl ZYPP_API;
277 extern const Arch Arch_armv4l ZYPP_API;
279 extern const Arch Arch_armv3l ZYPP_API;
280
282 extern const Arch Arch_riscv64 ZYPP_API;
283
285 extern const Arch Arch_sh3 ZYPP_API;
286
288 extern const Arch Arch_sh4 ZYPP_API;
290 extern const Arch Arch_sh4a ZYPP_API;
291
293 extern const Arch Arch_m68k ZYPP_API;
294
296 extern const Arch Arch_mips ZYPP_API;
298 extern const Arch Arch_mipsel ZYPP_API;
300 extern const Arch Arch_mips64 ZYPP_API;
302 extern const Arch Arch_mips64el ZYPP_API;
303
305 extern const Arch Arch_loong64 ZYPP_API;
307
309
311 inline std::ostream & operator<<( std::ostream & str, const Arch & obj )
312 { return str << obj.asString(); }
313
315 inline std::ostream & dumpAsXmlOn( std::ostream & str, const Arch & obj )
316 { return str << "<arch>" << obj << "</arch>"; }
317
320
321 inline bool operator==( const Arch & lhs, const Arch & rhs )
322 { return lhs.asString() == rhs.asString(); }
323
325 inline bool operator==( const Arch & lhs, const std::string & rhs )
326 { return lhs.asString() == rhs; }
327
329 inline bool operator==( const std::string & lhs, const Arch & rhs )
330 { return lhs == rhs.asString(); }
331
333 inline bool operator!=( const Arch & lhs, const Arch & rhs )
334 { return !( lhs == rhs ); }
335
337 inline bool operator!=( const Arch & lhs, const std::string & rhs )
338 { return !( lhs == rhs ); }
339
341 inline bool operator!=( const std::string & lhs, const Arch & rhs )
342 { return !( lhs == rhs ); }
343
344
346
350 struct ArchCompatibleWith
351 {
353 Arch _targetArch;
355 ArchCompatibleWith( const Arch & targetArch_r )
356 : _targetArch( targetArch_r )
357 {}
358
359 bool operator()( const Arch & rhs ) const
360 { return rhs.compatibleWith( _targetArch ); }
361 };
362
364} // namespace zypp
366
368namespace std
369{
371 template<>
372#ifdef __clang__
373constexpr
374#endif
375 inline bool less<zypp::Arch>::operator()( const zypp::Arch & lhs, const zypp::Arch & rhs ) const
376 { return lhs.compare( rhs ) < 0; }
378} // namespace zypp
380#endif // ZYPP_ARCH_H
IdStringType.h
Iterator.h
RelCompare.h
String.h
zypp::Arch
Architecture.
Definition Arch.h:37
zypp::Arch::_entry
const CompatEntry * _entry
Definition Arch.h:153
zypp::Arch::baseArch
Arch baseArch() const
Definition Arch.cc:748
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:64
zypp::Arch::asString
static std::string asString(const CompatSet &cset)
Definition Arch.h:140
zypp::Arch::compare
static int compare(const Arch &lhs, const Arch &rhs)
Arch comparison (static version).
Definition Arch.h:117
zypp::Arch::empty
bool empty() const
Test for an empty Arch (this is Arch_epmty, not Arch_noarch ).
Definition Arch.h:68
zypp::Arch::compare
int compare(const Arch &rhs) const
Arch comparison.
Definition Arch.cc:785
zypp::Arch::Arch
Arch()
Default ctor Arc_noarch.
Definition Arch.cc:681
zypp::Arch::compatSet
static CompatSet compatSet(const Arch &targetArch_r)
Return a set of all Arch's compatibleWith a targetArch_r.
Definition Arch.cc:793
zypp::Arch::size
unsigned size() const
Size of the string representation.
Definition Arch.h:72
zypp::Arch::idStr
IdString idStr() const
String representation of Arch.
Definition Arch.cc:716
zypp::Arch::id
IdString::IdType id() const
Expert backdoor.
Definition Arch.h:76
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:724
zypp::Arch::CompatSet
std::set< Arch, CompareByGT< Arch > > CompatSet
Reversed arch order, best Arch first.
Definition Arch.h:122
zypp::Arch::detectSystemArchitecture
static Arch detectSystemArchitecture()
Determine system architecture evaluating uname and /proc/cpuinfo.
Definition Arch.cc:701
zypp::Arch::compatibleWith
bool compatibleWith(const Arch &targetArch_r) const
Compatibility relation.
Definition Arch.cc:740
zypp::Arch::baseArch
static Arch baseArch(const Arch &targetArch_r)
Definition Arch.h:106
zypp::IdString
Access to the sat-pools string space.
Definition IdString.h:55
zypp::IdString::IdType
sat::detail::IdType IdType
Definition IdString.h:57
std
Definition ansi.h:855
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:846
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2
zypp::dumpAsXmlOn
std::ostream & dumpAsXmlOn(std::ostream &str, const Repository &obj)
relates: Repository XML output
Definition Repository.cc:411
zypp::operator!=
bool operator!=(const Capability &lhs, const Capability &rhs)
relates: Capability
Definition Capability.h:313
zypp::operator==
bool operator==(const Capability &lhs, const Capability &rhs)
relates: Capability
Definition Capability.h:309
zypp::Arch_empty
const Arch Arch_empty(IdString::Empty)
zypp::ZYPP_API
const Arch Arch_empty ZYPP_API
relates: Arch This is an empty Arch represented by an empty string.
Definition Arch.h:173
zypp::asString
std::string asString(const Patch::Category &obj)
relates: Patch::Category string representation.
Definition Patch.cc:122
zypp::operator<<
std::ostream & operator<<(std::ostream &str, const Capabilities &obj)
relates: Capabilities Stream output
Definition Capabilities.cc:65
zypp::ArchCompatibleWith::_targetArch
Arch _targetArch
The target architecture.
Definition Arch.h:353
zypp::ArchCompatibleWith::ArchCompatibleWith
ArchCompatibleWith(const Arch &targetArch_r)
Ctor taking the target architecture.
Definition Arch.h:355
zypp::ArchCompatibleWith::operator()
bool operator()(const Arch &rhs) const
Call Arch::compatibleWith ( _targetArch ) on rhs.
Definition Arch.h:359
zypp::Arch::CompatEntry
Holds an architecture ID and its compatible relation.
Definition Arch.cc:258