3
* VBox frontends: Qt GUI ("VirtualBox"):
4
* VBoxVersion class declaration
8
* Copyright (C) 2006-2011 Oracle Corporation
10
* This file is part of VirtualBox Open Source Edition (OSE), as
11
* available from http://www.virtualbox.org. This file is free software;
12
* you can redistribute it and/or modify it under the terms of the GNU
13
* General Public License (GPL) as published by the Free Software
14
* Foundation, in version 2 as it comes in the "COPYING" file of the
15
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
19
#ifndef ___VBoxVersion_h___
20
#define ___VBoxVersion_h___
22
/* Global includes: */
23
#include <QStringList>
26
* Represents VirtualBox version wrapper
32
VBoxVersion() : m_x(-1), m_y(-1), m_z(-1) {}
34
VBoxVersion(const QString &strVersion)
35
: m_x(-1), m_y(-1), m_z(-1)
37
QStringList versionStack = strVersion.split('.');
38
if (versionStack.size() > 0)
39
m_x = versionStack[0].toInt();
40
if (versionStack.size() > 1)
41
m_y = versionStack[1].toInt();
42
if (versionStack.size() > 2)
43
m_z = versionStack[2].toInt();
46
VBoxVersion& operator=(const VBoxVersion &other) { m_x = other.x(); m_y = other.y(); m_z = other.z(); return *this; }
48
bool isValid() const { return m_x != -1 && m_y != -1 && m_z != -1; }
50
bool equal(const VBoxVersion &other) const { return (m_x == other.m_x) && (m_y == other.m_y) && (m_z == other.m_z); }
51
bool operator==(const VBoxVersion &other) const { return equal(other); }
52
bool operator!=(const VBoxVersion &other) const { return !equal(other); }
54
bool operator<(const VBoxVersion &other) const
56
return (m_x < other.m_x) ||
57
(m_x == other.m_x && m_y < other.m_y) ||
58
(m_x == other.m_x && m_y == other.m_y && m_z < other.m_z);
60
bool operator>(const VBoxVersion &other) const
62
return (m_x > other.m_x) ||
63
(m_x == other.m_x && m_y > other.m_y) ||
64
(m_x == other.m_x && m_y == other.m_y && m_z > other.m_z);
67
QString toString() const
69
return QString("%1.%2.%3").arg(m_x).arg(m_y).arg(m_z);
72
int x() const { return m_x; }
73
int y() const { return m_y; }
74
int z() const { return m_z; }
83
#endif // !___VBoxVersion_h___