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
28namespace ept {
29namespace apt {
30
41{
42protected:
43 std::string m_name;
44 std::string m_version;
45
46public:
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
Lightweight Version class that represent a package with a version, with very cheap value copy operati...
Definition version.h:41
bool operator==(const Version &pkg) const
Comparison operators.
Definition version.h:82
Version(const std::string &name, const std::string &version)
Create a Version from strings.
Definition version.h:55
std::string upstreamVersion() const
Return the upstream part of the version.
Definition version.cc:32
std::string m_name
Definition version.h:43
std::string name() const
Return the package name.
Definition version.h:61
bool operator>=(const Version &pkg) const
Definition version.cc:67
bool isValid() const
Return true if this package contains a valid value.
Definition version.h:77
bool operator<=(const Version &pkg) const
Definition version.cc:51
std::string m_version
Definition version.h:44
Version()
Create an invalid Version.
Definition version.h:50
bool operator>(const Version &pkg) const
Definition version.cc:75
bool operator!=(const Version &pkg) const
Definition version.h:83
std::string version() const
Return the package version, or the empty string if this is a versionless package.
Definition version.h:67
bool operator<(const Version &pkg) const
Definition version.cc:59
String functions.
Definition apt.cc:40