LibPkg
version.h
Go to the documentation of this file.
1 // This file is part of LibPkg.
2 //
3 // Copyright 2003-2020 Graham Shaw
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 
17 #ifndef LIBPKG_VERSION
18 #define LIBPKG_VERSION
19 
20 #include <exception>
21 #include <stdexcept>
22 #include <string>
23 
24 namespace pkg {
25 
26 using std::string;
27 
32 class version
33 {
34 public:
35  class parse_error;
36 private:
38  string _epoch;
39 
41  string _upstream_version;
42 
44  string _package_version;
45 public:
50  version();
51 
59  version(const string& epoch,const string& upstream_version,
60  const string& package_version);
61 
68  version(string::const_iterator first,string::const_iterator last);
69 
75  version(const string& verstr);
76 
85  operator string() const;
86 
90  string epoch() const
91  { return _epoch; }
92 
96  string upstream_version() const
97  { return _upstream_version; }
98 
102  string package_version() const
103  { return _package_version; }
104 private:
109  void parse(string::const_iterator first,string::const_iterator last);
110 
115  void validate() const;
116 };
117 
123 bool operator==(const version& lhs,const version& rhs);
124 
130 bool operator!=(const version& lhs,const version& rhs);
131 
137 bool operator<(const version& lhs,const version& rhs);
138 
144 bool operator>=(const version& lhs,const version& rhs);
145 
151 bool operator<=(const version& lhs,const version& rhs);
152 
158 bool operator>(const version& lhs,const version& rhs);
159 
162  public std::runtime_error
163 {
164 public:
168  parse_error(const char* message);
169 };
170 
171 }; /* namespace pkg */
172 
173 #endif
string epoch() const
Get epoch.
Definition: version.h:90
version()
Construct version with default value.
Definition: libpkg/version.cc:193
The namespace used to hold the package management library.
Definition: auto_dir.cc:23
bool operator<(const binary_control_table::key_type &lhs, const binary_control_table::key_type &rhs)
Compare two binary control table keys.
Definition: binary_control_table.cc:138
string upstream_version() const
Get upstream version.
Definition: version.h:96
bool operator<=(const version &lhs, const version &rhs)
Test whether one version is less than or equal to another.
Definition: libpkg/version.cc:318
bool operator>=(const version &lhs, const version &rhs)
Test whether one version is greater than or equal to another.
Definition: libpkg/version.cc:313
string package_version() const
Get package version.
Definition: version.h:102
An exception class for reporting parse errors.
Definition: version.h:161
bool operator>(const version &lhs, const version &rhs)
Test whether one version is greater than another.
Definition: libpkg/version.cc:323
A class to represent a package version.
Definition: version.h:32
bool operator!=(const status &lhs, const status &rhs)
Test whether two status records are unequal.
Definition: status.cc:119
bool operator==(const status &lhs, const status &rhs)
Test whether two status records are equal.
Definition: status.cc:111

Reference Manual LibPkg Version 0.9.0 (4 Sep 2020)