libzypp: zypp/Edition.h Source File

libzypp 17.38.6

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
18#include <zypp/IdStringType.h>
19#include <zypp/RelCompare.h>
20#include <zypp/Range.h>
21
23namespace zypp
24{
25
27 //
28 // CLASS NAME : Edition
29 //
59 class ZYPP_API Edition : public IdStringType<Edition>
60 {
61 public:
63 using epoch_t = unsigned int;
64
66 static const epoch_t noepoch = 0;
67
72 static const Edition noedition;
73
74 public:
76 Edition() {}
77
79 explicit Edition( IdString::IdType id_r ) : _str( id_r ) {}
80 explicit Edition( const IdString & idstr_r ) : _str( idstr_r ) {}
81 explicit Edition( const std::string & str_r ) : _str( str_r ) {}
82 explicit Edition( const char * cstr_r ) : _str( cstr_r ) {}
83
85 Edition( const std::string & version_r,
86 const std::string & release_r,
87 epoch_t epoch_r = noepoch );
89 Edition( const char * version_r,
90 const char * release_r,
91 epoch_t epoch_r = noepoch );
92
94 Edition( const std::string & version_r,
95 const std::string & release_r,
96 const std::string & epoch_r );
98 Edition( const char * version_r,
99 const char * release_r,
100 const char * epoch_r );
101
102 public:
104 epoch_t epoch() const;
105
107 std::string version() const;
108
110 std::string release() const;
111
112 public:
116 using Compare = zypp::Compare<Edition>;
117
121 using CompareRange = Range<Edition>;
122
123 public:
129 static int match( const Edition & lhs, const Edition & rhs ) { return match( lhs.idStr(), rhs.idStr() ); }
130 static int match( const Edition & lhs, const IdString & rhs ) { return match( lhs.idStr(), rhs ); }
131 static int match( const Edition & lhs, const std::string & rhs ) { return _doMatch( lhs.c_str(), rhs.c_str() ); }
132 static int match( const Edition & lhs, const char * rhs ) { return _doMatch( lhs.c_str(), rhs );}
133
134 static int match( const IdString & lhs, const Edition & rhs ) { return match( lhs, rhs.idStr() ); }
135 static int match( const IdString & lhs, const IdString & rhs ) { return lhs.compareEQ( rhs ) ? 0 :
136 _doMatch( lhs.c_str(), rhs.c_str() ); }
137 static int match( const IdString & lhs, const std::string & rhs ) { return _doMatch( lhs.c_str(), rhs.c_str() ); }
138 static int match( const IdString & lhs, const char * rhs ) { return _doMatch( lhs.c_str(), rhs ); }
139
140 static int match( const std::string & lhs, const Edition & rhs ) { return _doMatch( lhs.c_str(), rhs.c_str() );}
141 static int match( const std::string & lhs, const IdString & rhs ) { return _doMatch( lhs.c_str(), rhs.c_str() ); }
142 static int match( const std::string & lhs, const std::string & rhs ) { return _doMatch( lhs.c_str(), rhs.c_str() ); }
143 static int match( const std::string & lhs, const char * rhs ) { return _doMatch( lhs.c_str(), rhs ); }
144
145 static int match( const char * lhs, const Edition & rhs ) { return _doMatch( lhs, rhs.c_str() );}
146 static int match( const char * lhs, const IdString & rhs ) { return _doMatch( lhs, rhs.c_str() ); }
147 static int match( const char * lhs, const std::string & rhs ) { return _doMatch( lhs, rhs.c_str() ); }
148 static int match( const char * lhs, const char * rhs ) { return _doMatch( lhs, rhs ); }
149
150 int match( const Edition & rhs ) const { return match( idStr(), rhs.idStr() ); }
151 int match( const IdString & rhs ) const { return match( idStr(), rhs ); }
152 int match( const std::string & rhs ) const { return _doMatch( c_str(), rhs.c_str() ); }
153 int match( const char * rhs ) const { return _doMatch( c_str(), rhs ); }
155
159 struct Match
160 {
161 int operator()( const Edition & lhs, const Edition & rhs ) const
162 { return Edition::match( lhs, rhs ); }
163 };
164
168 using MatchRange = Range<Edition, Match>;
169
170 private:
171 static int _doCompare( const char * lhs, const char * rhs ) ZYPP_API;
172 static int _doMatch( const char * lhs, const char * rhs );
173
174 private:
175 friend class IdStringType<Edition>;
176 IdString _str;
177 };
178
179
181 inline std::ostream & dumpAsXmlOn( std::ostream & str, const Edition & obj )
182 { return str << "<edition"
183 << " epoch=\"" << obj.epoch() << "\""
184 << " version=\"" << obj.version() << "\""
185 << " release=\"" << obj.release() << "\""
186 << "/>";
187 }
188
190} // namespace zypp
192#endif // ZYPP_EDITION_H
IdStringType.h
Range.h
RelCompare.h
zypp::Edition
Edition represents [epoch:]version[-release].
Definition Edition.h:60
zypp::Edition::match
static int match(const IdString &lhs, const IdString &rhs)
Definition Edition.h:135
zypp::Edition::match
static int match(const Edition &lhs, const Edition &rhs)
Definition Edition.h:129
zypp::Edition::MatchRange
Range< Edition, Match > MatchRange
Edition Range based on Match.
Definition Edition.h:168
zypp::Edition::match
int match(const std::string &rhs) const
Definition Edition.h:152
zypp::Edition::_str
IdString _str
Definition Edition.h:176
zypp::Edition::version
std::string version() const
Version.
Definition Edition.cc:96
zypp::Edition::match
static int match(const std::string &lhs, const Edition &rhs)
Definition Edition.h:140
zypp::Edition::Compare
zypp::Compare< Edition > Compare
compare functor.
Definition Edition.h:116
zypp::Edition::match
static int match(const char *lhs, const Edition &rhs)
Definition Edition.h:145
zypp::Edition::noepoch
static const epoch_t noepoch
Value representing noepoch.
Definition Edition.h:66
zypp::Edition::match
int match(const char *rhs) const
Definition Edition.h:153
zypp::Edition::Edition
Edition()
Default ctor: noedition.
Definition Edition.h:76
zypp::Edition::match
int match(const IdString &rhs) const
Definition Edition.h:151
zypp::Edition::match
static int match(const Edition &lhs, const char *rhs)
Definition Edition.h:132
zypp::Edition::Edition
Edition(const char *cstr_r)
Definition Edition.h:82
zypp::Edition::match
static int match(const std::string &lhs, const std::string &rhs)
Definition Edition.h:142
zypp::Edition::match
int match(const Edition &rhs) const
Definition Edition.h:150
zypp::Edition::match
static int match(const std::string &lhs, const char *rhs)
Definition Edition.h:143
zypp::Edition::epoch_t
unsigned int epoch_t
Type of an epoch.
Definition Edition.h:63
zypp::Edition::release
std::string release() const
Release.
Definition Edition.cc:112
zypp::Edition::Edition
Edition(const IdString &idstr_r)
Definition Edition.h:80
zypp::Edition::match
static int match(const IdString &lhs, const char *rhs)
Definition Edition.h:138
zypp::Edition::match
static int match(const Edition &lhs, const std::string &rhs)
Definition Edition.h:131
zypp::Edition::match
static int match(const char *lhs, const std::string &rhs)
Definition Edition.h:147
zypp::Edition::match
static int match(const char *lhs, const char *rhs)
Definition Edition.h:148
zypp::Edition::Edition
Edition(IdString::IdType id_r)
Ctor taking edition as string.
Definition Edition.h:79
zypp::Edition::_doMatch
static int _doMatch(const char *lhs, const char *rhs)
Definition Edition.cc:129
zypp::Edition::epoch
epoch_t epoch() const
Epoch.
Definition Edition.cc:84
zypp::Edition::_doCompare
static int _doCompare(const char *lhs, const char *rhs) ZYPP_API
Definition Edition.cc:122
zypp::Edition::CompareRange
Range< Edition > CompareRange
Edition Range based on Compare.
Definition Edition.h:121
zypp::Edition::match
static int match(const IdString &lhs, const std::string &rhs)
Definition Edition.h:137
zypp::Edition::match
static int match(const Edition &lhs, const IdString &rhs)
Definition Edition.h:130
zypp::Edition::match
static int match(const char *lhs, const IdString &rhs)
Definition Edition.h:146
zypp::Edition::Edition
Edition(const std::string &str_r)
Definition Edition.h:81
zypp::Edition::noedition
static const Edition noedition
Value representing noedition ("") This is in fact a valid Edition.
Definition Edition.h:72
zypp::Edition::match
static int match(const std::string &lhs, const IdString &rhs)
Definition Edition.h:141
zypp::Edition::match
static int match(const IdString &lhs, const Edition &rhs)
Definition Edition.h:134
zypp::IdString
Access to the sat-pools string space.
Definition IdString.h:55
zypp::IdString::c_str
const char * c_str() const
Conversion to const char *.
Definition IdString.cc:51
zypp::IdString::IdType
sat::detail::IdType IdType
Definition IdString.h:57
zypp::IdString::compareEQ
bool compareEQ(const IdString &rhs) const
Fast compare equal.
Definition IdString.h:129
zyppng::IdStringType::idStr
IdString idStr() const
Definition IdStringType.h:111
zypp::IdStringType< Edition >::IdStringType
IdStringType()=default
zyppng::IdStringType::c_str
const char * c_str() const
Definition IdStringType.h:115
str
String related utilities and Regular expression matching.
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::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::Compare
General compare functor returning -1, 0, 1.
Definition RelCompare.h:85
zypp::Edition::Match
match functor.
Definition Edition.h:160
zypp::Edition::Match::operator()
int operator()(const Edition &lhs, const Edition &rhs) const
Definition Edition.h:161
zypp::Range
Definition Range.h:35