qversionnumber.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/tools/qversionnumber.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Copyright (C) 2016 Intel Corporation.-
5** Copyright (C) 2014 Keith Gardner <kreios4004@gmail.com>-
6** Contact: https://www.qt.io/licensing/-
7**-
8** This file is part of the QtCore module of the Qt Toolkit.-
9**-
10** $QT_BEGIN_LICENSE:LGPL$-
11** Commercial License Usage-
12** Licensees holding valid commercial Qt licenses may use this file in-
13** accordance with the commercial license agreement provided with the-
14** Software or, alternatively, in accordance with the terms contained in-
15** a written agreement between you and The Qt Company. For licensing terms-
16** and conditions see https://www.qt.io/terms-conditions. For further-
17** information use the contact form at https://www.qt.io/contact-us.-
18**-
19** GNU Lesser General Public License Usage-
20** Alternatively, this file may be used under the terms of the GNU Lesser-
21** General Public License version 3 as published by the Free Software-
22** Foundation and appearing in the file LICENSE.LGPL3 included in the-
23** packaging of this file. Please review the following information to-
24** ensure the GNU Lesser General Public License version 3 requirements-
25** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
26**-
27** GNU General Public License Usage-
28** Alternatively, this file may be used under the terms of the GNU-
29** General Public License version 2.0 or (at your option) the GNU General-
30** Public license version 3 or any later version approved by the KDE Free-
31** Qt Foundation. The licenses are as published by the Free Software-
32** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
33** included in the packaging of this file. Please review the following-
34** information to ensure the GNU General Public License requirements will-
35** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
36** https://www.gnu.org/licenses/gpl-3.0.html.-
37**-
38** $QT_END_LICENSE$-
39**-
40****************************************************************************/-
41-
42#include <QtCore/qversionnumber.h>-
43#include <QtCore/qhash.h>-
44#include <QtCore/private/qlocale_tools_p.h>-
45#include <QtCore/qcollator.h>-
46-
47#ifndef QT_NO_DATASTREAM-
48# include <QtCore/qdatastream.h>-
49#endif-
50-
51#ifndef QT_NO_DEBUG_STREAM-
52# include <QtCore/qdebug.h>-
53#endif-
54-
55#include <algorithm>-
56#include <limits>-
57-
58QT_BEGIN_NAMESPACE-
59-
60/*!-
61 \class QVersionNumber-
62 \inmodule QtCore-
63 \since 5.6-
64 \brief The QVersionNumber class contains a version number with an arbitrary-
65 number of segments.-
66-
67 \snippet qversionnumber/main.cpp 0-
68*/-
69-
70/*!-
71 \fn QVersionNumber::QVersionNumber()-
72-
73 Produces a null version.-
74-
75 \sa isNull()-
76*/-
77-
78/*!-
79 \fn QVersionNumber::QVersionNumber(int maj)-
80-
81 Constructs a QVersionNumber consisting of just the major version number \a maj.-
82*/-
83-
84/*!-
85 \fn QVersionNumber::QVersionNumber(int maj, int min)-
86-
87 Constructs a QVersionNumber consisting of the major and minor-
88 version numbers \a maj and \a min, respectively.-
89*/-
90-
91/*!-
92 \fn QVersionNumber::QVersionNumber(int maj, int min, int mic)-
93-
94 Constructs a QVersionNumber consisting of the major, minor, and-
95 micro version numbers \a maj, \a min and \a mic, respectively.-
96*/-
97-
98/*!-
99 \fn QVersionNumber::QVersionNumber(const QVector<int> &seg)-
100-
101 Constructs a version number from the list of numbers contained in \a seg.-
102*/-
103-
104/*!-
105 \fn QVersionNumber::QVersionNumber(QVector<int> &&seg)-
106-
107 Move-constructs a version number from the list of numbers contained in \a seg.-
108-
109 This constructor is only enabled if the compiler supports C++11 move semantics.-
110*/-
111-
112/*!-
113 \fn QVersionNumber::QVersionNumber(std::initializer_list<int> args)-
114-
115 Construct a version number from the std::initializer_list specified by-
116 \a args.-
117-
118 This constructor is only enabled if the compiler supports C++11 initializer-
119 lists.-
120*/-
121-
122/*!-
123 \fn bool QVersionNumber::isNull() const-
124-
125 Returns \c true if there are zero numerical segments, otherwise returns-
126 \c false.-
127-
128 \sa segments()-
129*/-
130-
131/*!-
132 \fn bool QVersionNumber::isNormalized() const-
133-
134 Returns \c true if the version number does not contain any trailing zeros,-
135 otherwise returns \c false.-
136-
137 \sa normalized()-
138*/-
139-
140/*!-
141 \fn int QVersionNumber::majorVersion() const-
142-
143 Returns the major version number, that is, the first segment.-
144 This function is equivalent to segmentAt(0). If this QVersionNumber object-
145 is null, this function returns 0.-
146-
147 \sa isNull(), segmentAt()-
148*/-
149-
150/*!-
151 \fn int QVersionNumber::minorVersion() const-
152-
153 Returns the minor version number, that is, the second segment.-
154 This function is equivalent to segmentAt(1). If this QVersionNumber object-
155 does not contain a minor number, this function returns 0.-
156-
157 \sa isNull(), segmentAt()-
158*/-
159-
160/*!-
161 \fn int QVersionNumber::microVersion() const-
162-
163 Returns the micro version number, that is, the third segment.-
164 This function is equivalent to segmentAt(2). If this QVersionNumber object-
165 does not contain a micro number, this function returns 0.-
166-
167 \sa isNull(), segmentAt()-
168*/-
169-
170/*!-
171 \fn const QVector<int>& QVersionNumber::segments() const-
172-
173 Returns all of the numerical segments.-
174-
175 \sa majorVersion(), minorVersion(), microVersion()-
176*/-
177QVector<int> QVersionNumber::segments() const-
178{-
179 if (m_segments.isUsingPointer())
m_segments.isUsingPointer()Description
TRUEevaluated 135 times by 1 test
Evaluated by:
  • tst_QVersionNumber
FALSEevaluated 311 times by 1 test
Evaluated by:
  • tst_QVersionNumber
135-311
180 return *m_segments.pointer_segments;
executed 135 times by 1 test: return *m_segments.pointer_segments;
Executed by:
  • tst_QVersionNumber
135
181-
182 QVector<int> result;-
183 result.resize(segmentCount());-
184 for (int i = 0; i < segmentCount(); ++i)
i < segmentCount()Description
TRUEevaluated 720 times by 1 test
Evaluated by:
  • tst_QVersionNumber
FALSEevaluated 311 times by 1 test
Evaluated by:
  • tst_QVersionNumber
311-720
185 result[i] = segmentAt(i);
executed 720 times by 1 test: result[i] = segmentAt(i);
Executed by:
  • tst_QVersionNumber
720
186 return result;
executed 311 times by 1 test: return result;
Executed by:
  • tst_QVersionNumber
311
187}-
188-
189/*!-
190 \fn int QVersionNumber::segmentAt(int index) const-
191-
192 Returns the segement value at \a index. If the index does not exist,-
193 returns 0.-
194-
195 \sa segments(), segmentCount()-
196*/-
197-
198/*!-
199 \fn int QVersionNumber::segmentCount() const-
200-
201 Returns the number of integers stored in segments().-
202-
203 \sa segments()-
204*/-
205-
206/*!-
207 \fn QVersionNumber QVersionNumber::normalized() const-
208-
209 Returns an equivalent version number but with all trailing zeros removed.-
210-
211 To check if two numbers are equivalent, use normalized() on both version-
212 numbers before performing the compare.-
213-
214 \snippet qversionnumber/main.cpp 4-
215 */-
216QVersionNumber QVersionNumber::normalized() const-
217{-
218 int i;-
219 for (i = m_segments.size(); i; --i)
iDescription
TRUEevaluated 32 times by 1 test
Evaluated by:
  • tst_QVersionNumber
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QVersionNumber
2-32
220 if (m_segments.at(i - 1) != 0)
m_segments.at(i - 1) != 0Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_QVersionNumber
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_QVersionNumber
16
221 break;
executed 16 times by 1 test: break;
Executed by:
  • tst_QVersionNumber
16
222-
223 QVersionNumber result(*this);-
224 result.m_segments.resize(i);-
225 return result;
executed 18 times by 1 test: return result;
Executed by:
  • tst_QVersionNumber
18
226}-
227-
228/*!-
229 \fn bool QVersionNumber::isPrefixOf(const QVersionNumber &other) const-
230-
231 Returns \c true if the current version number is contained in the \a other-
232 version number, otherwise returns \c false.-
233-
234 \snippet qversionnumber/main.cpp 2-
235-
236 \sa commonPrefix()-
237*/-
238bool QVersionNumber::isPrefixOf(const QVersionNumber &other) const Q_DECL_NOTHROW-
239{-
240 if (segmentCount() > other.segmentCount())
segmentCount()...segmentCount()Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_QVersionNumber
FALSEevaluated 41 times by 1 test
Evaluated by:
  • tst_QVersionNumber
10-41
241 return false;
executed 10 times by 1 test: return false;
Executed by:
  • tst_QVersionNumber
10
242 for (int i = 0; i < segmentCount(); ++i) {
i < segmentCount()Description
TRUEevaluated 123 times by 1 test
Evaluated by:
  • tst_QVersionNumber
FALSEevaluated 17 times by 1 test
Evaluated by:
  • tst_QVersionNumber
17-123
243 if (segmentAt(i) != other.segmentAt(i))
segmentAt(i) !...r.segmentAt(i)Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_QVersionNumber
FALSEevaluated 99 times by 1 test
Evaluated by:
  • tst_QVersionNumber
24-99
244 return false;
executed 24 times by 1 test: return false;
Executed by:
  • tst_QVersionNumber
24
245 }
executed 99 times by 1 test: end of block
Executed by:
  • tst_QVersionNumber
99
246 return true;
executed 17 times by 1 test: return true;
Executed by:
  • tst_QVersionNumber
17
247}-
248-
249/*!-
250 \fn int QVersionNumber::compare(const QVersionNumber &v1,-
251 const QVersionNumber &v2)-
252-
253 Compares \a v1 with \a v2 and returns an integer less than, equal to, or-
254 greater than zero, depending on whether \a v1 is less than, equal to, or-
255 greater than \a v2, respectively.-
256-
257 Comparisons are performed by comparing the segments of \a v1 and \a v2-
258 starting at index 0 and working towards the end of the longer list.-
259-
260 \snippet qversionnumber/main.cpp 1-
261*/-
262int QVersionNumber::compare(const QVersionNumber &v1, const QVersionNumber &v2) Q_DECL_NOTHROW-
263{-
264 int commonlen;-
265-
266 if (Q_LIKELY(!v1.m_segments.isUsingPointer() && !v2.m_segments.isUsingPointer())) {
__builtin_expe...nter()), true)Description
TRUEevaluated 324 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_QVersionNumber
FALSEevaluated 190 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_QVersionNumber
190-324
267 // we can't use memcmp because it interprets the data as unsigned bytes-
268 const qint8 *ptr1 = v1.m_segments.inline_segments + InlineSegmentStartIdx;-
269 const qint8 *ptr2 = v2.m_segments.inline_segments + InlineSegmentStartIdx;-
270 commonlen = qMin(v1.m_segments.size(),-
271 v2.m_segments.size());-
272 for (int i = 0; i < commonlen; ++i)
i < commonlenDescription
TRUEevaluated 498 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_QVersionNumber
FALSEevaluated 237 times by 1 test
Evaluated by:
  • tst_QVersionNumber
237-498
273 if (int x = ptr1[i] - ptr2[i])
int x = ptr1[i] - ptr2[i]Description
TRUEevaluated 87 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_QVersionNumber
FALSEevaluated 411 times by 1 test
Evaluated by:
  • tst_QVersionNumber
87-411
274 return x;
executed 87 times by 2 tests: return x;
Executed by:
  • tst_QOpenGlConfig
  • tst_QVersionNumber
87
275 } else {
executed 237 times by 1 test: end of block
Executed by:
  • tst_QVersionNumber
237
276 commonlen = qMin(v1.segmentCount(), v2.segmentCount());-
277 for (int i = 0; i < commonlen; ++i) {
i < commonlenDescription
TRUEevaluated 997 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_QVersionNumber
FALSEevaluated 104 times by 1 test
Evaluated by:
  • tst_QVersionNumber
104-997
278 if (v1.segmentAt(i) != v2.segmentAt(i))
v1.segmentAt(i...2.segmentAt(i)Description
TRUEevaluated 86 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_QVersionNumber
FALSEevaluated 911 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_QVersionNumber
86-911
279 return v1.segmentAt(i) - v2.segmentAt(i);
executed 86 times by 2 tests: return v1.segmentAt(i) - v2.segmentAt(i);
Executed by:
  • tst_QOpenGlConfig
  • tst_QVersionNumber
86
280 }
executed 911 times by 2 tests: end of block
Executed by:
  • tst_QOpenGlConfig
  • tst_QVersionNumber
911
281 }
executed 104 times by 1 test: end of block
Executed by:
  • tst_QVersionNumber
104
282-
283 // ran out of segments in v1 and/or v2 and need to check the first trailing-
284 // segment to finish the compare-
285 if (v1.segmentCount() > commonlen) {
v1.segmentCount() > commonlenDescription
TRUEevaluated 70 times by 1 test
Evaluated by:
  • tst_QVersionNumber
FALSEevaluated 271 times by 1 test
Evaluated by:
  • tst_QVersionNumber
70-271
286 // v1 is longer-
287 if (v1.segmentAt(commonlen) != 0)
v1.segmentAt(commonlen) != 0Description
TRUEevaluated 56 times by 1 test
Evaluated by:
  • tst_QVersionNumber
FALSEevaluated 14 times by 1 test
Evaluated by:
  • tst_QVersionNumber
14-56
288 return v1.segmentAt(commonlen);
executed 56 times by 1 test: return v1.segmentAt(commonlen);
Executed by:
  • tst_QVersionNumber
56
289 else-
290 return 1;
executed 14 times by 1 test: return 1;
Executed by:
  • tst_QVersionNumber
14
291 } else if (v2.segmentCount() > commonlen) {
v2.segmentCount() > commonlenDescription
TRUEevaluated 70 times by 1 test
Evaluated by:
  • tst_QVersionNumber
FALSEevaluated 201 times by 1 test
Evaluated by:
  • tst_QVersionNumber
70-201
292 // v2 is longer-
293 if (v2.segmentAt(commonlen) != 0)
v2.segmentAt(commonlen) != 0Description
TRUEevaluated 56 times by 1 test
Evaluated by:
  • tst_QVersionNumber
FALSEevaluated 14 times by 1 test
Evaluated by:
  • tst_QVersionNumber
14-56
294 return -v2.segmentAt(commonlen);
executed 56 times by 1 test: return -v2.segmentAt(commonlen);
Executed by:
  • tst_QVersionNumber
56
295 else-
296 return -1;
executed 14 times by 1 test: return -1;
Executed by:
  • tst_QVersionNumber
14
297 }-
298-
299 // the two version numbers are the same-
300 return 0;
executed 201 times by 1 test: return 0;
Executed by:
  • tst_QVersionNumber
201
301}-
302-
303/*!-
304 QVersionNumber QVersionNumber::commonPrefix(const QVersionNumber &v1,-
305 const QVersionNumber &v2)-
306-
307 Returns a version number that is a parent version of both \a v1 and \a v2.-
308-
309 \sa isPrefixOf()-
310*/-
311QVersionNumber QVersionNumber::commonPrefix(const QVersionNumber &v1,-
312 const QVersionNumber &v2)-
313{-
314 int commonlen = qMin(v1.segmentCount(), v2.segmentCount());-
315 int i;-
316 for (i = 0; i < commonlen; ++i) {
i < commonlenDescription
TRUEevaluated 150 times by 1 test
Evaluated by:
  • tst_QVersionNumber
FALSEevaluated 27 times by 1 test
Evaluated by:
  • tst_QVersionNumber
27-150
317 if (v1.segmentAt(i) != v2.segmentAt(i))
v1.segmentAt(i...2.segmentAt(i)Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_QVersionNumber
FALSEevaluated 126 times by 1 test
Evaluated by:
  • tst_QVersionNumber
24-126
318 break;
executed 24 times by 1 test: break;
Executed by:
  • tst_QVersionNumber
24
319 }
executed 126 times by 1 test: end of block
Executed by:
  • tst_QVersionNumber
126
320-
321 if (i == 0)
i == 0Description
TRUEevaluated 15 times by 1 test
Evaluated by:
  • tst_QVersionNumber
FALSEevaluated 36 times by 1 test
Evaluated by:
  • tst_QVersionNumber
15-36
322 return QVersionNumber();
executed 15 times by 1 test: return QVersionNumber();
Executed by:
  • tst_QVersionNumber
15
323-
324 // try to use the one with inline segments, if there's one-
325 QVersionNumber result(!v1.m_segments.isUsingPointer() ? v1 : v2);-
326 result.m_segments.resize(i);-
327 return result;
executed 36 times by 1 test: return result;
Executed by:
  • tst_QVersionNumber
36
328}-
329-
330/*!-
331 \fn bool operator<(const QVersionNumber &lhs, const QVersionNumber &rhs)-
332 \relates QVersionNumber-
333-
334 Returns \c true if \a lhs is less than \a rhs; otherwise returns \c false.-
335-
336 \sa QVersionNumber::compare()-
337*/-
338-
339/*!-
340 \fn bool operator<=(const QVersionNumber &lhs, const QVersionNumber &rhs)-
341 \relates QVersionNumber-
342-
343 Returns \c true if \a lhs is less than or equal to \a rhs; otherwise-
344 returns \c false.-
345-
346 \sa QVersionNumber::compare()-
347*/-
348-
349/*!-
350 \fn bool operator>(const QVersionNumber &lhs, const QVersionNumber &rhs)-
351 \relates QVersionNumber-
352-
353 Returns \c true if \a lhs is greater than \a rhs; otherwise returns \c-
354 false.-
355-
356 \sa QVersionNumber::compare()-
357*/-
358-
359/*!-
360 \fn bool operator>=(const QVersionNumber &lhs, const QVersionNumber &rhs)-
361 \relates QVersionNumber-
362-
363 Returns \c true if \a lhs is greater than or equal to \a rhs; otherwise-
364 returns \c false.-
365-
366 \sa QVersionNumber::compare()-
367*/-
368-
369/*!-
370 \fn bool operator==(const QVersionNumber &lhs, const QVersionNumber &rhs)-
371 \relates QVersionNumber-
372-
373 Returns \c true if \a lhs is equal to \a rhs; otherwise returns \c false.-
374-
375 \sa QVersionNumber::compare()-
376*/-
377-
378/*!-
379 \fn bool operator!=(const QVersionNumber &lhs, const QVersionNumber &rhs)-
380 \relates QVersionNumber-
381-
382 Returns \c true if \a lhs is not equal to \a rhs; otherwise returns-
383 \c false.-
384-
385 \sa QVersionNumber::compare()-
386*/-
387-
388/*!-
389 \fn QString QVersionNumber::toString() const-
390-
391 Returns a string with all of the segments delimited by a '.'.-
392-
393 \sa majorVersion(), minorVersion(), microVersion(), segments()-
394*/-
395QString QVersionNumber::toString() const-
396{-
397 QString version;-
398 version.reserve(qMax(segmentCount() * 2 - 1, 0));-
399 bool first = true;-
400 for (int i = 0; i < segmentCount(); ++i) {
i < segmentCount()Description
TRUEevaluated 140 times by 1 test
Evaluated by:
  • tst_QVersionNumber
FALSEevaluated 40 times by 1 test
Evaluated by:
  • tst_QVersionNumber
40-140
401 if (!first)
!firstDescription
TRUEevaluated 105 times by 1 test
Evaluated by:
  • tst_QVersionNumber
FALSEevaluated 35 times by 1 test
Evaluated by:
  • tst_QVersionNumber
35-105
402 version += QLatin1Char('.');
executed 105 times by 1 test: version += QLatin1Char('.');
Executed by:
  • tst_QVersionNumber
105
403 version += QString::number(segmentAt(i));-
404 first = false;-
405 }
executed 140 times by 1 test: end of block
Executed by:
  • tst_QVersionNumber
140
406 return version;
executed 40 times by 1 test: return version;
Executed by:
  • tst_QVersionNumber
40
407}-
408-
409/*!-
410 \fn QVersionNumber QVersionNumber::fromString(const QString &string,-
411 int *suffixIndex)-
412-
413 Constructs a QVersionNumber from a specially formatted \a string of-
414 non-negative decimal numbers delimited by '.'.-
415-
416 Once the numerical segments have been parsed, the remainder of the string-
417 is considered to be the suffix string. The start index of that string will be-
418 stored in \a suffixIndex if it is not null.-
419-
420 \snippet qversionnumber/main.cpp 3-
421-
422 \sa isNull()-
423*/-
424QVersionNumber QVersionNumber::fromString(const QString &string, int *suffixIndex)-
425{-
426 QVector<int> seg;-
427-
428 const QByteArray cString(string.toLatin1());-
429-
430 const char *start = cString.constData();-
431 const char *end = start;-
432 const char *lastGoodEnd = start;-
433 const char *endOfString = cString.constData() + cString.size();-
434-
435 do {-
436 bool ok = false;-
437 const qulonglong value = qstrtoull(start, &end, 10, &ok);-
438 if (!ok || value > qulonglong(std::numeric_limits<int>::max()))
!okDescription
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_QVersionNumber
FALSEevaluated 296 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_QVersionNumber
value > qulong...s<int>::max())Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QVersionNumber
FALSEevaluated 292 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_QVersionNumber
4-296
439 break;
executed 28 times by 1 test: break;
Executed by:
  • tst_QVersionNumber
28
440 seg.append(int(value));-
441 start = end + 1;-
442 lastGoodEnd = end;-
443 } while (start < endOfString && (end < endOfString && *end == '.'));
executed 292 times by 2 tests: end of block
Executed by:
  • tst_QOpenGlConfig
  • tst_QVersionNumber
start < endOfStringDescription
TRUEevaluated 267 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_QVersionNumber
FALSEevaluated 25 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_QVersionNumber
end < endOfStringDescription
TRUEevaluated 267 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_QVersionNumber
FALSEnever evaluated
*end == '.'Description
TRUEevaluated 231 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_QVersionNumber
FALSEevaluated 36 times by 1 test
Evaluated by:
  • tst_QVersionNumber
0-292
444-
445 if (suffixIndex)
suffixIndexDescription
TRUEevaluated 41 times by 1 test
Evaluated by:
  • tst_QVersionNumber
FALSEevaluated 48 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_QVersionNumber
41-48
446 *suffixIndex = int(lastGoodEnd - cString.constData());
executed 41 times by 1 test: *suffixIndex = int(lastGoodEnd - cString.constData());
Executed by:
  • tst_QVersionNumber
41
447-
448 return QVersionNumber(qMove(seg));
executed 89 times by 2 tests: return QVersionNumber(std::move(seg));
Executed by:
  • tst_QOpenGlConfig
  • tst_QVersionNumber
89
449}-
450-
451void QVersionNumber::SegmentStorage::setVector(int len, int maj, int min, int mic)-
452{-
453 pointer_segments = new QVector<int>;-
454 pointer_segments->resize(len);-
455 pointer_segments->data()[0] = maj;-
456 if (len > 1) {
len > 1Description
TRUEevaluated 171 times by 1 test
Evaluated by:
  • tst_QVersionNumber
FALSEevaluated 36 times by 1 test
Evaluated by:
  • tst_QVersionNumber
36-171
457 pointer_segments->data()[1] = min;-
458 if (len > 2) {
len > 2Description
TRUEevaluated 81 times by 1 test
Evaluated by:
  • tst_QVersionNumber
FALSEevaluated 90 times by 1 test
Evaluated by:
  • tst_QVersionNumber
81-90
459 pointer_segments->data()[2] = mic;-
460 }
executed 81 times by 1 test: end of block
Executed by:
  • tst_QVersionNumber
81
461 }
executed 171 times by 1 test: end of block
Executed by:
  • tst_QVersionNumber
171
462}
executed 207 times by 1 test: end of block
Executed by:
  • tst_QVersionNumber
207
463-
464#ifndef QT_NO_DATASTREAM-
465/*!-
466 \fn QDataStream& operator<<(QDataStream &out,-
467 const QVersionNumber &version)-
468 \relates QVersionNumber-
469-
470 Writes the version number \a version to stream \a out.-
471-
472 Note that this has nothing to do with QDataStream::version().-
473 */-
474QDataStream& operator<<(QDataStream &out, const QVersionNumber &version)-
475{-
476 out << version.segments();-
477 return out;
executed 37 times by 1 test: return out;
Executed by:
  • tst_QVersionNumber
37
478}-
479-
480/*!-
481 \fn QDataStream& operator>>(QDataStream &in, QVersionNumber &version)-
482 \relates QVersionNumber-
483-
484 Reads a version number from stream \a in and stores it in \a version.-
485-
486 Note that this has nothing to do with QDataStream::version().-
487 */-
488QDataStream& operator>>(QDataStream &in, QVersionNumber &version)-
489{-
490 if (!version.m_segments.isUsingPointer())
!version.m_seg...UsingPointer()Description
TRUEevaluated 37 times by 1 test
Evaluated by:
  • tst_QVersionNumber
FALSEnever evaluated
0-37
491 version.m_segments.pointer_segments = new QVector<int>;
executed 37 times by 1 test: version.m_segments.pointer_segments = new QVector<int>;
Executed by:
  • tst_QVersionNumber
37
492 in >> *version.m_segments.pointer_segments;-
493 return in;
executed 37 times by 1 test: return in;
Executed by:
  • tst_QVersionNumber
37
494}-
495#endif-
496-
497#ifndef QT_NO_DEBUG_STREAM-
498QDebug operator<<(QDebug debug, const QVersionNumber &version)-
499{-
500 QDebugStateSaver saver(debug);-
501 debug.noquote() << version.toString();-
502 return debug;
never executed: return debug;
0
503}-
504#endif-
505-
506/*!-
507 \fn uint qHash(const QVersionNumber &key, uint seed)-
508 \relates QHash-
509 \since 5.6-
510-
511 Returns the hash value for the \a key, using \a seed to seed the-
512 calculation.-
513*/-
514uint qHash(const QVersionNumber &key, uint seed)-
515{-
516 QtPrivate::QHashCombine hash;-
517 for (int i = 0; i < key.segmentCount(); ++i)
i < key.segmentCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
518 seed = hash(seed, key.segmentAt(i));
never executed: seed = hash(seed, key.segmentAt(i));
0
519 return seed;
never executed: return seed;
0
520}-
521-
522QT_END_NAMESPACE-
523-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9