summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/AddonVersion.h
diff options
context:
space:
mode:
Diffstat (limited to 'xbmc/addons/AddonVersion.h')
-rw-r--r--xbmc/addons/AddonVersion.h72
1 files changed, 72 insertions, 0 deletions
diff --git a/xbmc/addons/AddonVersion.h b/xbmc/addons/AddonVersion.h
new file mode 100644
index 0000000..3c23370
--- /dev/null
+++ b/xbmc/addons/AddonVersion.h
@@ -0,0 +1,72 @@
1/*
2 * Copyright (C) 2005-2013 Team XBMC
3 * http://xbmc.org
4 *
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
8 * any later version.
9 *
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
18 *
19 */
20
21#include <string>
22#include <boost/operators.hpp>
23
24namespace ADDON
25{
26 /* \brief Addon versioning using the debian versioning scheme
27
28 AddonVersion uses debian versioning, which means in the each section of the period
29 separated version string, numbers are compared numerically rather than lexicographically,
30 thus any preceding zeros are ignored.
31
32 i.e. 1.00 is considered the same as 1.0, and 1.01 is considered the same as 1.1.
33
34 Further, 1.0 < 1.0.0
35
36 See here for more info: http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Version
37 */
38 class AddonVersion : public boost::totally_ordered<AddonVersion> {
39 public:
40 AddonVersion(const AddonVersion& other) { *this = other; }
41 explicit AddonVersion(const std::string& version);
42 virtual ~AddonVersion() {};
43
44 int Epoch() const { return mEpoch; }
45 const std::string &Upstream() const { return mUpstream; }
46 const std::string &Revision() const { return mRevision; }
47
48 AddonVersion& operator=(const AddonVersion& other);
49 bool operator<(const AddonVersion& other) const;
50 bool operator==(const AddonVersion& other) const;
51 std::string asString() const;
52 bool empty() const;
53
54 static bool SplitFileName(std::string& ID, std::string& version,
55 const std::string& filename);
56
57 protected:
58 int mEpoch;
59 std::string mUpstream;
60 std::string mRevision;
61
62 static int CompareComponent(const char *a, const char *b);
63 };
64
65 inline AddonVersion& AddonVersion::operator=(const AddonVersion& other)
66 {
67 mEpoch = other.mEpoch;
68 mUpstream = other.mUpstream;
69 mRevision = other.mRevision;
70 return *this;
71 }
72}