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)
56  : m_name(name), m_version(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