itom  4.1.0
semVerVersion.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2020, Institut fuer Technische Optik (ITO),
5  Universitaet 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 fuer 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 
40 namespace 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 
64  int major() const;
65 
68  int minor() const;
69 
72  int patch() const;
73 
74  int svMajor() const;
75  int svMinor() const;
76  int svPatch() const;
77 
78  private:
79  int m_major;
80  int m_minor;
81  int m_patch;
82  };
83 
84 }; // end namespace ito
85 
86 #endif //#if !defined(Q_MOC_RUN) || defined(ITOMCOMMONQT_MOC)
87 
88 #endif
Definition: apiFunctionsGraph.cpp:39
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:185
provides version string parsing and comparison based on semantic versioning
Definition: semVerVersion.h:42