itom
Loading...
Searching...
No Matches
semVerVersion.h
1/* ********************************************************************
2 itom software
3 URL: http://www.uni-stuttgart.de/ito
4 Copyright (C) 2020, Institut für Technische Optik (ITO),
5 Universität Stuttgart, Germany
6
7 This file is part of itom and its software development toolkit (SDK).
8
9 itom is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Library General Public Licence as published by
11 the Free Software Foundation; either version 2 of the Licence, or (at
12 your option) any later version.
13
14 In addition, as a special exception, the Institut für Technische
15 Optik (ITO) gives you certain additional rights.
16 These rights are described in the ITO LGPL Exception version 1.0,
17 which can be found in the file LGPL_EXCEPTION.txt in this package.
18
19 itom is distributed in the hope that it will be useful, but
20 WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
22 General Public Licence for more details.
23
24 You should have received a copy of the GNU Library General Public License
25 along with itom. If not, see <http://www.gnu.org/licenses/>.
26*********************************************************************** */
27
28#ifndef SEMVERVERSION_H
29#define SEMVERVERSION_H
30
31/* includes */
32
33#include "commonGlobal.h"
34#include "typeDefs.h"
35#include <qstring.h>
36
37
38#if !defined(Q_MOC_RUN) || defined(ITOMCOMMONQT_MOC) //only moc this file in itomCommonQtLib but not in other libraries or executables linking against this itomCommonQtLib
39
40namespace ito
41{
42 class ITOMCOMMONQT_EXPORT SemVerVersion
43 {
44 public:
45 SemVerVersion(int major, int minor, int patch = 0);
46 SemVerVersion(); //constructs an empty version (major = minor = patch = 0)
47
48 QString toString() const;
49 int toInt() const; //returns the major, minor and patch in the form 0xAABBCC (AA: major, BB: minor, CC: patch)
50
51 static SemVerVersion fromString(const QString &versionString, bool *ok = NULL);
52 static SemVerVersion fromInt(int versionNumber); //the integer must be 0xAABBCC where AA is the major, BB is the minor, CC is the patch
53
54 bool operator==(const SemVerVersion &other) const; //returns true if this and other are exactly the same
55 bool isCompatible(const SemVerVersion &other) const; //returns true if this and other have the same major and if the minor of other is <= this.minor.
56 bool isValid() const; //returns false if major=minor==patch==0
57 bool operator>=(const SemVerVersion &other) const;
58 bool operator>(const SemVerVersion &other) const;
59 bool operator<=(const SemVerVersion &other) const;
60 bool operator<(const SemVerVersion &other) const;
61
62 int svMajor() const;
63 int svMinor() const;
64 int svPatch() const;
65
66 private:
67 int m_major;
68 int m_minor;
69 int m_patch;
70 };
71
72}; // end namespace ito
73
74#endif //#if !defined(Q_MOC_RUN) || defined(ITOMCOMMONQT_MOC)
75
76#endif
provides version string parsing and comparison based on semantic versioning
Definition semVerVersion.h:43
Definition apiFunctionsGraph.cpp:40
bool operator==(const ByteArray &a1, const char *a2)
comparison operator that returns true if the content of a1 is equal to the given zero-terminated stri...
Definition byteArray.h:198