libzypp 17.37.10

Edition.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_EDITION_H
13#define ZYPP_EDITION_H
14
15#include <iosfwd>
16#include <string>
17#include <functional>
18
19#include <zypp/IdStringType.h>
20#include <zypp/RelCompare.h>
21#include <zypp/Range.h>
22
24 namespace zypp
25{
26
28 //
29 // CLASS NAME : Edition
30 //
60 class ZYPP_API Edition : public IdStringType<Edition>
61 {
62 public:
64 using epoch_t = unsigned int;
65
67 static const epoch_t noepoch = 0;
68
73 static const Edition noedition;
74
75 public:
77 Edition() {}
78
80 explicit Edition( IdString::IdType id_r ) : _str( id_r ) {}
81 explicit Edition( const IdString & idstr_r ) : _str( idstr_r ) {}
82 explicit Edition( const std::string & str_r ) : _str( str_r ) {}
83 explicit Edition( const char * cstr_r ) : _str( cstr_r ) {}
84
86 Edition( const std::string & version_r,
87 const std::string & release_r,
88 epoch_t epoch_r = noepoch );
90 Edition( const char * version_r,
91 const char * release_r,
92 epoch_t epoch_r = noepoch );
93
95 Edition( const std::string & version_r,
96 const std::string & release_r,
97 const std::string & epoch_r );
99 Edition( const char * version_r,
100 const char * release_r,
101 const char * epoch_r );
102
103 public:
105 epoch_t epoch() const;
106
108 std::string version() const;
109
111 std::string release() const;
112
113 public:
117 using Compare = zypp::Compare<Edition>;
118
122 using CompareRange = Range<Edition>;
123
124 public:
130 static int match( const Edition & lhs, const Edition & rhs ) { return match( lhs.idStr(), rhs.idStr() ); }
131 static int match( const Edition & lhs, const IdString & rhs ) { return match( lhs.idStr(), rhs ); }
132 static int match( const Edition & lhs, const std::string & rhs ) { return _doMatch( lhs.c_str(), rhs.c_str() ); }
133 static int match( const Edition & lhs, const char * rhs ) { return _doMatch( lhs.c_str(), rhs );}
134
135 static int match( const IdString & lhs, const Edition & rhs ) { return match( lhs, rhs.idStr() ); }
136 static int match( const IdString & lhs, const IdString & rhs ) { return lhs.compareEQ( rhs ) ? 0 :
137 _doMatch( lhs.c_str(), rhs.c_str() ); }
138 static int match( const IdString & lhs, const std::string & rhs ) { return _doMatch( lhs.c_str(), rhs.c_str() ); }
139 static int match( const IdString & lhs, const char * rhs ) { return _doMatch( lhs.c_str(), rhs ); }
140
141 static int match( const std::string & lhs, const Edition & rhs ) { return _doMatch( lhs.c_str(), rhs.c_str() );}
142 static int match( const std::string & lhs, const IdString & rhs ) { return _doMatch( lhs.c_str(), rhs.c_str() ); }
143 static int match( const std::string & lhs, const std::string & rhs ) { return _doMatch( lhs.c_str(), rhs.c_str() ); }
144 static int match( const std::string & lhs, const char * rhs ) { return _doMatch( lhs.c_str(), rhs ); }
145
146 static int match( const char * lhs, const Edition & rhs ) { return _doMatch( lhs, rhs.c_str() );}
147 static int match( const char * lhs, const IdString & rhs ) { return _doMatch( lhs, rhs.c_str() ); }
148 static int match( const char * lhs, const std::string & rhs ) { return _doMatch( lhs, rhs.c_str() ); }
149 static int match( const char * lhs, const char * rhs ) { return _doMatch( lhs, rhs ); }
150
151 int match( const Edition & rhs ) const { return match( idStr(), rhs.idStr() ); }
152 int match( const IdString & rhs ) const { return match( idStr(), rhs ); }
153 int match( const std::string & rhs ) const { return _doMatch( c_str(), rhs.c_str() ); }
154 int match( const char * rhs ) const { return _doMatch( c_str(), rhs ); }
156
160 struct Match
161 {
162 int operator()( const Edition & lhs, const Edition & rhs ) const
163 { return Edition::match( lhs, rhs ); }
164 };
165
169 using MatchRange = Range<Edition, Match>;
170
171 private:
172 static int _doCompare( const char * lhs, const char * rhs ) ZYPP_API;
173 static int _doMatch( const char * lhs, const char * rhs );
174
175 private:
176 friend class IdStringType<Edition>;
177 IdString _str;
178 };
179
180
182 inline std::ostream & dumpAsXmlOn( std::ostream & str, const Edition & obj )
183 { return str << "<edition"
184 << " epoch=\"" << obj.epoch() << "\""
185 << " version=\"" << obj.version() << "\""
186 << " release=\"" << obj.release() << "\""
187 << "/>";
188 }
189
191} // namespace zypp
193#endif // ZYPP_EDITION_H
IdStringType.h
Range.h
RelCompare.h
zypp::Edition
Edition represents [epoch:]version[-release]
Definition Edition.h:61
zypp::Edition::match
static int match(const IdString &lhs, const IdString &rhs)
Definition Edition.h:136
zypp::Edition::match
static int match(const Edition &lhs, const Edition &rhs)
Definition Edition.h:130
zypp::Edition::MatchRange
Range< Edition, Match > MatchRange
Edition Range based on Match.
Definition Edition.h:169
zypp::Edition::match
int match(const std::string &rhs) const
Definition Edition.h:153
zypp::Edition::_str
IdString _str
Definition Edition.h:177
zypp::Edition::version
std::string version() const
Version.
Definition Edition.cc:94
zypp::Edition::match
static int match(const std::string &lhs, const Edition &rhs)
Definition Edition.h:141
zypp::Edition::Compare
zypp::Compare< Edition > Compare
compare functor.
Definition Edition.h:117
zypp::Edition::match
static int match(const char *lhs, const Edition &rhs)
Definition Edition.h:146
zypp::Edition::dumpAsXmlOn
std::ostream & dumpAsXmlOn(std::ostream &str, const Edition &obj)
XML output.
Definition Edition.h:182
zypp::Edition::noepoch
static const epoch_t noepoch
Value representing noepoch.
Definition Edition.h:67
zypp::Edition::match
int match(const char *rhs) const
Definition Edition.h:154
zypp::Edition::Edition
Edition()
Default ctor: noedition.
Definition Edition.h:77
zypp::Edition::match
int match(const IdString &rhs) const
Definition Edition.h:152
zypp::Edition::match
static int match(const Edition &lhs, const char *rhs)
Definition Edition.h:133
zypp::Edition::Edition
Edition(const char *cstr_r)
Definition Edition.h:83
zypp::Edition::match
static int match(const std::string &lhs, const std::string &rhs)
Definition Edition.h:143
zypp::Edition::match
int match(const Edition &rhs) const
Definition Edition.h:151
zypp::Edition::match
static int match(const std::string &lhs, const char *rhs)
Definition Edition.h:144
zypp::Edition::epoch_t
unsigned int epoch_t
Type of an epoch.
Definition Edition.h:64
zypp::Edition::release
std::string release() const
Release.
Definition Edition.cc:110
zypp::Edition::Edition
Edition(const IdString &idstr_r)
Definition Edition.h:81
zypp::Edition::match
static int match(const IdString &lhs, const char *rhs)
Definition Edition.h:139
zypp::Edition::match
static int match(const Edition &lhs, const std::string &rhs)
Definition Edition.h:132
zypp::Edition::match
static int match(const char *lhs, const std::string &rhs)
Definition Edition.h:148
zypp::Edition::match
static int match(const char *lhs, const char *rhs)
Definition Edition.h:149
zypp::Edition::Edition
Edition(IdString::IdType id_r)
Ctor taking edition as string.
Definition Edition.h:80
zypp::Edition::_doMatch
static int _doMatch(const char *lhs, const char *rhs)
Definition Edition.cc:127
zypp::Edition::epoch
epoch_t epoch() const
Epoch.
Definition Edition.cc:82
zypp::Edition::_doCompare
static int _doCompare(const char *lhs, const char *rhs) ZYPP_API
Definition Edition.cc:120
zypp::Edition::CompareRange
Range< Edition > CompareRange
Edition Range based on Compare.
Definition Edition.h:122
zypp::Edition::match
static int match(const IdString &lhs, const std::string &rhs)
Definition Edition.h:138
zypp::Edition::match
static int match(const Edition &lhs, const IdString &rhs)
Definition Edition.h:131
zypp::Edition::match
static int match(const char *lhs, const IdString &rhs)
Definition Edition.h:147
zypp::Edition::Edition
Edition(const std::string &str_r)
Definition Edition.h:82
zypp::Edition::noedition
static const Edition noedition
Value representing noedition ("") This is in fact a valid Edition.
Definition Edition.h:73
zypp::Edition::match
static int match(const std::string &lhs, const IdString &rhs)
Definition Edition.h:142
zypp::Edition::match
static int match(const IdString &lhs, const Edition &rhs)
Definition Edition.h:135
zypp::IdStringType::idStr
IdString idStr() const
Definition IdStringType.h:103
zypp::IdStringType< Edition >::IdStringType
IdStringType()=default
zypp::IdStringType::c_str
const char * c_str() const
Definition IdStringType.h:107
zypp::IdString
Access to the sat-pools string space.
Definition IdString.h:44
zypp::IdString::c_str
const char * c_str() const
Conversion to const char *
Definition IdString.cc:50
zypp::IdString::IdType
sat::detail::IdType IdType
Definition IdString.h:46
zypp::IdString::compareEQ
bool compareEQ(const IdString &rhs) const
Fast compare equal.
Definition IdString.h:118
str
String related utilities and Regular expression matching.
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
zypp::ZYPP_API
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition Arch.h:247
zypp::Compare
General compare functor returning -1, 0, 1.
Definition RelCompare.h:87
zypp::Edition::Match
match functor.
Definition Edition.h:161
zypp::Edition::Match::operator()
int operator()(const Edition &lhs, const Edition &rhs) const
Definition Edition.h:162
zypp::Range
Definition Range.h:35