LibPkg
version.h
Go to the documentation of this file.
1 // This file is part of LibPkg.
2 // Copyright © 2003-2005 Graham Shaw.
3 // Distribution and use are subject to the GNU Lesser General Public License,
4 // a copy of which may be found in the file !LibPkg.Copyright.
5 
6 #ifndef LIBPKG_VERSION
7 #define LIBPKG_VERSION
8 
9 #include <exception>
10 #include <stdexcept>
11 #include <string>
12 
13 namespace pkg {
14 
15 using std::string;
16 
21 class version
22 {
23 public:
24  class parse_error;
25 private:
27  string _epoch;
28 
30  string _upstream_version;
31 
33  string _package_version;
34 public:
39  version();
40 
48  version(const string& epoch,const string& upstream_version,
49  const string& package_version);
50 
57  version(string::const_iterator first,string::const_iterator last);
58 
64  version(const string& verstr);
65 
74  operator string() const;
75 
79  string epoch() const
80  { return _epoch; }
81 
85  string upstream_version() const
86  { return _upstream_version; }
87 
91  string package_version() const
92  { return _package_version; }
93 private:
98  void parse(string::const_iterator first,string::const_iterator last);
99 
104  void validate() const;
105 };
106 
112 bool operator==(const version& lhs,const version& rhs);
113 
119 bool operator!=(const version& lhs,const version& rhs);
120 
126 bool operator<(const version& lhs,const version& rhs);
127 
133 bool operator>=(const version& lhs,const version& rhs);
134 
140 bool operator<=(const version& lhs,const version& rhs);
141 
147 bool operator>(const version& lhs,const version& rhs);
148 
151  public std::runtime_error
152 {
153 public:
157  parse_error(const char* message);
158 };
159 
160 }; /* namespace pkg */
161 
162 #endif
version()
Construct version with default value.
Definition: libpkg/version.cc:182
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:119
string upstream_version() const
Get upstream version.
Definition: version.h:85
string package_version() const
Get package version.
Definition: version.h:91
bool operator<=(const version &lhs, const version &rhs)
Test whether one version is less than or equal to another.
Definition: libpkg/version.cc:307
bool operator>=(const version &lhs, const version &rhs)
Test whether one version is greater than or equal to another.
Definition: libpkg/version.cc:302
An exception class for reporting parse errors.
Definition: version.h:150
parse_error(const char *message)
Construct parse error.
Definition: libpkg/version.cc:317
bool operator>(const version &lhs, const version &rhs)
Test whether one version is greater than another.
Definition: libpkg/version.cc:312
A class to represent a package version.
Definition: version.h:21
bool operator!=(const status &lhs, const status &rhs)
Test whether two status records are unequal.
Definition: status.cc:101
bool operator==(const status &lhs, const status &rhs)
Test whether two status records are equal.
Definition: status.cc:94
string epoch() const
Get epoch.
Definition: version.h:79

Reference Manual LibPkg Version 0.6.1 (28 Jan 2015)