~ubuntu-branches/ubuntu/vivid/virtualbox/vivid

« back to all changes in this revision

Viewing changes to src/VBox/Frontends/VirtualBox/src/globals/VBoxVersion.h

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2011-12-29 12:29:25 UTC
  • mfrom: (3.1.8 sid)
  • Revision ID: package-import@ubuntu.com-20111229122925-8ota2o33fuk0bkf8
Tags: 4.1.8-dfsg-1
* New upstream release.
* Move all transitional packages to section oldlibs and priority extra.
* Refresh 16-no-update.patch.
* Drop 36-kernel-3.2.patch, applied upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/** @file
 
2
 *
 
3
 * VBox frontends: Qt GUI ("VirtualBox"):
 
4
 * VBoxVersion class declaration
 
5
 */
 
6
 
 
7
/*
 
8
 * Copyright (C) 2006-2011 Oracle Corporation
 
9
 *
 
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.
 
17
 */
 
18
 
 
19
#ifndef ___VBoxVersion_h___
 
20
#define ___VBoxVersion_h___
 
21
 
 
22
/* Global includes: */
 
23
#include <QStringList>
 
24
 
 
25
/**
 
26
 *  Represents VirtualBox version wrapper
 
27
 */
 
28
class VBoxVersion
 
29
{
 
30
public:
 
31
 
 
32
    VBoxVersion() : m_x(-1), m_y(-1), m_z(-1) {}
 
33
 
 
34
    VBoxVersion(const QString &strVersion)
 
35
        : m_x(-1), m_y(-1), m_z(-1)
 
36
    {
 
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();
 
44
    }
 
45
 
 
46
    VBoxVersion& operator=(const VBoxVersion &other) { m_x = other.x(); m_y = other.y(); m_z = other.z(); return *this; }
 
47
 
 
48
    bool isValid() const { return m_x != -1 && m_y != -1 && m_z != -1; }
 
49
 
 
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); }
 
53
 
 
54
    bool operator<(const VBoxVersion &other) const
 
55
    {
 
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);
 
59
    }
 
60
    bool operator>(const VBoxVersion &other) const
 
61
    {
 
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);
 
65
    }
 
66
 
 
67
    QString toString() const
 
68
    {
 
69
        return QString("%1.%2.%3").arg(m_x).arg(m_y).arg(m_z);
 
70
    }
 
71
 
 
72
    int x() const { return m_x; }
 
73
    int y() const { return m_y; }
 
74
    int z() const { return m_z; }
 
75
 
 
76
private:
 
77
 
 
78
    int m_x;
 
79
    int m_y;
 
80
    int m_z;
 
81
};
 
82
 
 
83
#endif // !___VBoxVersion_h___
 
84