xsversion.h
Go to the documentation of this file.
1 
2 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification,
6 // are permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice,
9 // this list of conditions, and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice,
12 // this list of conditions, and the following disclaimer in the documentation
13 // and/or other materials provided with the distribution.
14 //
15 // 3. Neither the names of the copyright holders nor the names of their contributors
16 // may be used to endorse or promote products derived from this software without
17 // specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
24 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
26 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
28 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
29 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
30 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
31 //
32 
33 
34 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
35 // All rights reserved.
36 //
37 // Redistribution and use in source and binary forms, with or without modification,
38 // are permitted provided that the following conditions are met:
39 //
40 // 1. Redistributions of source code must retain the above copyright notice,
41 // this list of conditions, and the following disclaimer.
42 //
43 // 2. Redistributions in binary form must reproduce the above copyright notice,
44 // this list of conditions, and the following disclaimer in the documentation
45 // and/or other materials provided with the distribution.
46 //
47 // 3. Neither the names of the copyright holders nor the names of their contributors
48 // may be used to endorse or promote products derived from this software without
49 // specific prior written permission.
50 //
51 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
52 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
53 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
54 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
56 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
58 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
59 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
60 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
61 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
62 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
63 //
64 
65 #ifndef XSVERSION_H
66 #define XSVERSION_H
67 
68 #include "xstypesconfig.h"
69 #include "xssimpleversion.h"
70 #include "xsstring.h"
71 
72 #undef minor
73 #undef major
74 
75 #ifdef __cplusplus
76 struct XsVersion;
77 extern "C" {
78 #endif
79 #ifndef __cplusplus
80 typedef struct XsVersion XsVersion;
81 #define XSVERSION_INITIALIZER { 0, 0, 0, 0, 0, XsString_INITIALIZER }
82 #endif
83 
84 XSTYPES_DLL_API int XsVersion_empty(const XsVersion* thisPtr);
85 XSTYPES_DLL_API void XsVersion_toString(const XsVersion* thisPtr, XsString* version);
86 XSTYPES_DLL_API void XsVersion_fromString(XsVersion* thisPtr, const XsString* version);
87 XSTYPES_DLL_API void XsVersion_fromSimpleVersion(XsVersion* thisPtr, const XsSimpleVersion* simpleVersion);
88 XSTYPES_DLL_API void XsVersion_toSimpleVersion(const XsVersion* thisPtr, XsSimpleVersion* simpleVersion);
89 XSTYPES_DLL_API void XsVersion_toSimpleString(const XsVersion* thisPtr, XsString* version);
90 
91 #ifdef __cplusplus
92 } // extern "C"
93 #endif
94 
95 struct XsVersion
96 {
97 #ifdef __cplusplus
98  explicit XsVersion(int maj, int min, int rev, int build, const XsString& extra)
100  : m_major(maj)
101  , m_minor(min)
102  , m_revision(rev)
103  , m_build(build)
104  , m_reposVersion(0)
105  , m_extra(extra)
106  {}
107 
109  explicit XsVersion(int maj = 0, int min = 0, int rev = 0, int build = 0, int reposVersion = 0, const XsString& extra = XsString())
110  : m_major(maj)
111  , m_minor(min)
112  , m_revision(rev)
113  , m_build(build)
114  , m_reposVersion(reposVersion)
115  , m_extra(extra)
116  {}
117 
119  explicit XsVersion(const XsString& vString)
120  {
121  XsVersion_fromString(this, &vString);
122  }
123 
125  XsVersion(const XsSimpleVersion& simpleVersion)
126  {
127  XsVersion_fromSimpleVersion(this, &simpleVersion);
128  }
129 
131  XsVersion(const XsVersion& other)
132  : m_major(other.m_major)
133  , m_minor(other.m_minor)
134  , m_revision(other.m_revision)
135  , m_build(other.m_build)
137  , m_extra(other.m_extra)
138  {}
139 
141  XsVersion& operator = (const XsVersion& other)
142  {
143  m_major = other.m_major;
144  m_minor = other.m_minor;
145  m_revision = other.m_revision;
146  m_build = other.m_build;
148  m_extra = other.m_extra;
149  return *this;
150  }
151 
153  inline bool isEqual(const XsVersion& other) const
154  {
155  return (*this == other) && (m_build == other.m_build) && (m_extra == other.m_extra) && (m_reposVersion == other.m_reposVersion);
156  }
157 
159  inline bool operator == (const XsVersion& other) const
160  {
161  return m_major == other.m_major && m_minor == other.m_minor && m_revision == other.m_revision;
162  }
163 
165  inline bool operator != (const XsVersion& other) const
166  {
167  return m_major != other.m_major || m_minor != other.m_minor || m_revision != other.m_revision;
168  }
169 
171  inline bool operator < (const XsVersion& other) const
172  {
173  if (m_major < other.m_major)
174  return true;
175  else if (m_major > other.m_major)
176  return false;
177 
178  if (m_minor < other.m_minor)
179  return true;
180  else if (m_minor > other.m_minor)
181  return false;
182 
183  if (m_revision < other.m_revision)
184  return true;
185  else
186  return false;
187  }
188 
190  inline bool operator <= (const XsVersion& other) const
191  {
192  if (m_major < other.m_major)
193  return true;
194  else if (m_major > other.m_major)
195  return false;
196 
197  if (m_minor < other.m_minor)
198  return true;
199  else if (m_minor > other.m_minor)
200  return false;
201 
202  if (m_revision < other.m_revision)
203  return true;
204  else
205  return m_revision == other.m_revision;
206  }
207 
209  inline bool operator > (const XsVersion& other) const
210  {
211  return !(*this <= other);
212  }
213 
215  inline bool operator >= (const XsVersion& other) const
216  {
217  return !(*this < other);
218  }
219 
221  inline bool empty() const
222  {
223  return 0 != XsVersion_empty(this);
224  }
225 
227  inline XsString toString() const
228  {
229  XsString tmp;
230  XsVersion_toString(this, &tmp);
231  return tmp;
232  }
233 
235  inline XsString toSimpleString() const
236  {
237  XsString tmp;
238  XsVersion_toSimpleString(this, &tmp);
239  return tmp;
240  }
241 
243  inline XsSimpleVersion toSimpleVersion() const
244  {
245  XsSimpleVersion result;
246  XsVersion_toSimpleVersion(this, &result);
247  return result;
248  }
249 
251  inline int major() const
252  {
253  return m_major;
254  }
256  inline int minor() const
257  {
258  return m_minor;
259  }
261  inline int revision() const
262  {
263  return m_revision;
264  }
266  inline int build() const
267  {
268  return m_build;
269  }
271  inline int reposVersion() const
272  {
273  return m_reposVersion;
274  }
276  inline const XsString& extra() const
277  {
278  return m_extra;
279  }
280 
282  inline void setMajor(int major)
283  {
284  m_major = major;
285  }
287  inline void setMinor(int minor)
288  {
289  m_minor = minor;
290  }
292  inline void setRevision(int revision)
293  {
294  m_revision = revision;
295  }
297  inline void setBuild(int build)
298  {
299  m_build = build;
300  }
302  inline void setReposVersion(int reposVersion)
303  {
304  m_reposVersion = reposVersion;
305  }
307  inline void setExtra(const XsString& extra)
308  {
309  m_extra = extra;
310  }
311 
312 private:
313 #endif
314 
315  int m_major;
316  int m_minor;
318  int m_build;
321 };
322 
323 #endif
XsString
struct XsString XsString
Definition: xsstring.h:87
XsVersion::m_revision
int m_revision
The revision number of the version.
Definition: xsversion.h:317
xsstring.h
XsVersion::m_extra
XsString m_extra
Storage for some extra information about the version.
Definition: xsversion.h:320
XsVersion::XsVersion_toString
void XsVersion_toString(const XsVersion *thisPtr, XsString *version)
Get a string with the version expressed in a readable format.
Definition: xsversion.c:84
XsVersion::m_build
int m_build
The build number for this build.
Definition: xsversion.h:318
XsVersion
struct XsVersion XsVersion
Definition: xsversion.h:80
XsVersion::XsVersion_toSimpleVersion
void XsVersion_toSimpleVersion(const XsVersion *thisPtr, XsSimpleVersion *simpleVersion)
Create a XsSimpleVersion (version) from a XsVersion.
Definition: xsversion.c:173
xssimpleversion.h
XsSimpleVersion
A class to store version information.
Definition: xssimpleversion.h:91
XsVersion::XsVersion_empty
int XsVersion_empty(const XsVersion *thisPtr)
Test if this is a null-version.
Definition: xsversion.c:78
operator==
bool operator==(const XsFilterProfile &lhs, const XsFilterProfile &rhs)
Returns true if lhs has the same type as rhs.
Definition: scenariomatchpred.h:81
XsVersion::XsVersion_toSimpleString
void XsVersion_toSimpleString(const XsVersion *thisPtr, XsString *version)
Get a string with the version expressed in a readable format.
Definition: xsversion.c:107
XsVersion::XsVersion_fromSimpleVersion
void XsVersion_fromSimpleVersion(XsVersion *thisPtr, const XsSimpleVersion *simpleVersion)
Create a XsVersion a XsSimpleVersion, simpleVersion.
Definition: xsversion.c:160
XsVersion::m_minor
int m_minor
The minor part of the version number.
Definition: xsversion.h:316
XsVersion
A class to store version information.
Definition: xsversion.h:95
XsVersion::XsVersion_fromString
void XsVersion_fromString(XsVersion *thisPtr, const XsString *version)
Set the version to the values in the string.
Definition: xsversion.c:118
xstypesconfig.h
XSTYPES_DLL_API
#define XSTYPES_DLL_API
Definition: xstypesconfig.h:65
XsVersion::m_major
int m_major
The major part of the version number.
Definition: xsversion.h:315
XsString
A 0-terminated managed string of characters.
XsVersion::m_reposVersion
int m_reposVersion
The source revision used for this build.
Definition: xsversion.h:319


xsens_mti_driver
Author(s):
autogenerated on Sun Sep 3 2023 02:43:20