libept
version.h
Go to the documentation of this file.
1 #ifndef EPT_APT_VERSION_H
2 #define EPT_APT_VERSION_H
3 
8 /*
9  * Copyright (C) 2007 Enrico Zini <enrico@enricozini.org>
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with this library; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24  */
25 
26 #include <string>
27 
28 namespace ept {
29 namespace apt {
30 
40 class Version
41 {
42 protected:
43  std::string m_name;
44  std::string m_version;
45 
46 public:
50  Version() {}
51 
55  Version(const std::string& name, const std::string& version)
57 
61  std::string name() const { return m_name; }
62 
67  std::string version() const { return m_version; }
68 
72  std::string upstreamVersion() const;
73 
77  bool isValid() const { return !m_name.empty() && !m_version.empty(); }
78 
82  bool operator==(const Version& pkg) const { return m_name == pkg.m_name && m_version == pkg.m_version; }
83  bool operator!=(const Version& pkg) const { return m_name != pkg.m_name || m_version != pkg.m_version; }
84  bool operator<=(const Version& pkg) const;
85  bool operator<(const Version& pkg) const;
86  bool operator>=(const Version& pkg) const;
87  bool operator>(const Version& pkg) const;
88 };
89 
90 }
91 }
92 
93 // vim:set ts=4 sw=4:
94 #endif
ept::debtags::coll::operators::operator<=
bool operator<=(const T &a, const std::set< T > &b)
Definition: operators.h:177
ept::apt::Version::m_name
std::string m_name
Definition: version.h:43
ept::tests
Definition: tests.cc:23
ept::apt::Version::m_version
std::string m_version
Definition: version.h:44
version.h
Representation of a package with a version.
ept::apt::Version::operator!=
bool operator!=(const Version &pkg) const
Definition: version.h:83
ept::apt::Version::operator==
bool operator==(const Version &pkg) const
Comparison operators.
Definition: version.h:82
ept::apt::Version::name
std::string name() const
Return the package name.
Definition: version.h:61
ept
String functions.
Definition: apt.cc:38
ept::apt::Version::operator<
bool operator<(const Version &pkg) const
Definition: version.cc:59
ept::tests::actual
Actual< A > actual(const A &actual)
Definition: tests.h:320
ept::apt::Version::upstreamVersion
std::string upstreamVersion() const
Return the upstream part of the version.
Definition: version.cc:32
test.h
ept::tests::TestCase
Test case collecting several test methods, and self-registering with the singleton instance of TestRe...
Definition: tests.h:615
ept::apt::Version::isValid
bool isValid() const
Return true if this package contains a valid value.
Definition: version.h:77
ept::apt::Version::operator>
bool operator>(const Version &pkg) const
Definition: version.cc:75
std
Definition: packagerecord-test.cc:4
register_tests
void register_tests() override
Definition: version-test.cc:2
ept::apt::Version::Version
Version()
Create an invalid Version.
Definition: version.h:50
ept::apt
Definition: apt.cc:39
ept::apt::Version::Version
Version(const std::string &name, const std::string &version)
Create a Version from strings.
Definition: version.h:55
wassert_true
#define wassert_true(...)
Shortcut to check that a given expression returns true.
Definition: tests.h:354
wassert
#define wassert(...)
Run the given command, raising TestFailed with the appropriate backtrace information if it threw an e...
Definition: tests.h:343
ept::apt::Version::version
std::string version() const
Return the package version, or the empty string if this is a versionless package.
Definition: version.h:67
ept::apt::Version::operator>=
bool operator>=(const Version &pkg) const
Definition: version.cc:67
ept::apt::Version::operator<=
bool operator<=(const Version &pkg) const
Definition: version.cc:51
ept::apt::Version
Lightweight Version class that represent a package with a version, with very cheap value copy operati...
Definition: version.h:41