42 #ifndef QVERSIONNUMBER_H
43 #define QVERSIONNUMBER_H
45 #include <QtCore/qlist.h>
46 #include <QtCore/qmetatype.h>
47 #include <QtCore/qnamespace.h>
48 #include <QtCore/qstring.h>
49 #include <QtCore/qtypeinfo.h>
57 #ifndef QT_NO_DATASTREAM
74 InlineSegmentMarker = Q_BYTE_ORDER ==
Q_LITTLE_ENDIAN ? 0 :
sizeof(
void *) - 1,
75 InlineSegmentStartIdx = !InlineSegmentMarker,
76 InlineSegmentCount =
sizeof(
void *) - 1
78 static_assert(InlineSegmentCount >= 3);
87 qint8 inline_segments[
sizeof(
void *)];
92 SegmentStorage() noexcept :
dummy(1) {}
96 if (dataFitsInline(seg.
data(), seg.
size()))
97 setInlineData(seg.
data(), seg.
size());
102 SegmentStorage(
const SegmentStorage &
other)
104 if (
other.isUsingPointer())
110 SegmentStorage &operator=(
const SegmentStorage &
other)
112 if (isUsingPointer() &&
other.isUsingPointer()) {
113 *pointer_segments = *
other.pointer_segments;
114 }
else if (
other.isUsingPointer()) {
117 if (isUsingPointer())
118 delete pointer_segments;
124 SegmentStorage(SegmentStorage &&
other) noexcept
132 void swap(SegmentStorage &
other) noexcept
139 if (dataFitsInline(std::as_const(seg).
data(), seg.
size()))
140 setInlineData(std::as_const(seg).
data(), seg.
size());
142 pointer_segments =
new QList<int>(std::move(seg));
144 SegmentStorage(std::initializer_list<int>
args)
153 ~SegmentStorage() {
if (isUsingPointer())
delete pointer_segments; }
155 bool isUsingPointer()
const noexcept
156 {
return (inline_segments[InlineSegmentMarker] & 1) == 0; }
158 int size()
const noexcept
159 {
return isUsingPointer() ? pointer_segments->size() : (inline_segments[InlineSegmentMarker] >> 1); }
161 void setInlineSize(
int len)
162 { inline_segments[InlineSegmentMarker] =
qint8(1 + 2 *
len); }
166 if (isUsingPointer())
167 pointer_segments->resize(
len);
174 return isUsingPointer() ?
175 pointer_segments->at(
index) :
176 inline_segments[InlineSegmentStartIdx +
index];
179 void setSegments(
int len,
int maj,
int min = 0,
int mic = 0)
182 int data[] = { maj, min, mic };
185 setVector(
len, maj, min, mic);
190 static bool dataFitsInline(
const int *
data,
int len)
192 if (
len > InlineSegmentCount)
194 for (
int i = 0;
i <
len; ++
i)
199 void setInlineData(
const int *
data,
int len)
202 #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
203 for (
int i = 0;
i <
len; ++
i)
205 #elif Q_BYTE_ORDER == Q_BIG_ENDIAN
206 for (
int i = 0;
i <
len; ++
i)
211 for (
int i = 0;
i <
len; ++
i)
212 inline_segments[InlineSegmentStartIdx +
i] =
data[
i] & 0xFF;
216 Q_CORE_EXPORT
void setVector(
int len,
int maj,
int min,
int mic);
234 { m_segments.setSegments(1, maj); }
237 { m_segments.setSegments(2, maj, min); }
240 { m_segments.setSegments(3, maj, min, mic); }
262 {
return (m_segments.size() >
index) ? m_segments.at(
index) : 0; }
265 {
return m_segments.size(); }
274 #if QT_STRINGVIEW_LEVEL < 2
300 #ifndef QT_NO_DATASTREAM
308 #ifndef QT_NO_DEBUG_STREAM
315 #ifndef QT_NO_DATASTREAM
323 template<
typename Integer>
327 template<
typename Integer>
330 && (
sizeof(Integer) >
sizeof(
quint16)
331 || (
sizeof(Integer) ==
sizeof(
quint16)
334 template<
typename Integer, if_val
id_segment_type<Integer> = true>
339 && ((std::numeric_limits<Integer>::max)() < Integer(SegmentUnknown)
340 ||
segment < Integer(SegmentUnknown));
343 template<
typename Major,
typename Minor,
344 if_valid_segment_type<Major> =
true,
345 if_valid_segment_type<Minor> =
true>
353 template<
typename Major, if_val
id_segment_type<Major> = true>
360 template<
typename Minor, if_val
id_segment_type<Minor> = true>
367 template<
typename Integer, if_val
id_value_type<Integer> = true>
386 template<
typename Integer, if_val
id_value_type<Integer> = true>
389 return Integer(m_majorVersion << 8) | Integer(m_minorVersion);
406 ?
rhs.majorVersion() != 0
415 ?
rhs.minorVersion() != 0
425 return lhs !=
rhs && !(lhs <
rhs);
430 return lhs ==
rhs || lhs <
rhs;
435 return lhs ==
rhs || !(lhs <
rhs);
439 enum { SegmentUnknown = 0xff };
441 #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
443 : m_minorVersion(minor), m_majorVersion(major) {}
445 quint8 m_minorVersion = SegmentUnknown;
446 quint8 m_majorVersion = SegmentUnknown;
449 : m_majorVersion(major), m_minorVersion(minor) {}
451 quint8 m_majorVersion = SegmentUnknown;
452 quint8 m_minorVersion = SegmentUnknown;
459 #ifndef QT_NO_DEBUG_STREAM
small capitals from c petite p scientific i
[1]
The QDataStream class provides serialization of binary data to a QIODevice.
operator>>(QDataStream &ds, qfloat16 &f)
operator<<(QDataStream &ds, qfloat16 f)
The QDebug class provides an output stream for debugging information.
template< typename Enum > size_t qHash(QFlags< Enum > flags, size_t seed=0) noexcept
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
qsizetype size() const noexcept
The QString class provides a Unicode character string.
The QStringView class provides a unified view on UTF-16 strings with a read-only subset of the QStrin...
The QTypeRevision class contains a lightweight representation of a version number with two 8-bit segm...
constexpr friend bool operator>(QTypeRevision lhs, QTypeRevision rhs)
static constexpr bool isValidSegment(Integer segment)
constexpr friend bool operator>=(QTypeRevision lhs, QTypeRevision rhs)
static constexpr QTypeRevision fromVersion(Major majorVersion, Minor minorVersion)
constexpr friend bool operator!=(QTypeRevision lhs, QTypeRevision rhs)
static constexpr QTypeRevision fromEncodedVersion(Integer value)
constexpr bool hasMinorVersion() const
constexpr friend bool operator<=(QTypeRevision lhs, QTypeRevision rhs)
static constexpr QTypeRevision zero()
typename std::enable_if< std::is_integral< Integer >::value &&(sizeof(Integer) > sizeof(quint16)||(sizeof(Integer)==sizeof(quint16) &&!std::is_signed< Integer >::value)), bool >::type if_valid_value_type
typename std::enable_if< std::is_integral< Integer >::value, bool >::type if_valid_segment_type
static constexpr QTypeRevision fromMinorVersion(Minor minorVersion)
constexpr friend bool operator==(QTypeRevision lhs, QTypeRevision rhs)
constexpr bool hasMajorVersion() const
constexpr Integer toEncodedVersion() const
constexpr quint8 minorVersion() const
static constexpr QTypeRevision fromMajorVersion(Major majorVersion)
constexpr bool isValid() const
constexpr friend bool operator<(QTypeRevision lhs, QTypeRevision rhs)
constexpr quint8 majorVersion() const
constexpr QTypeRevision()=default
The QVersionNumber class contains a version number with an arbitrary number of segments.
QVersionNumber(std::initializer_list< int > args)
Q_CORE_EXPORT bool isPrefixOf(const QVersionNumber &other) const noexcept
friend bool operator<=(const QVersionNumber &lhs, const QVersionNumber &rhs) noexcept
friend bool operator<(const QVersionNumber &lhs, const QVersionNumber &rhs) noexcept
friend Q_CORE_EXPORT QDataStream & operator>>(QDataStream &in, QVersionNumber &version)
bool isNull() const noexcept
int minorVersion() const noexcept
static Q_CORE_EXPORT QVersionNumber commonPrefix(const QVersionNumber &v1, const QVersionNumber &v2)
int majorVersion() const noexcept
QVersionNumber(const QList< int > &seg)
QVersionNumber() noexcept
friend bool operator>(const QVersionNumber &lhs, const QVersionNumber &rhs) noexcept
Q_CORE_EXPORT QList< int > segments() const
friend bool operator==(const QVersionNumber &lhs, const QVersionNumber &rhs) noexcept
friend bool operator!=(const QVersionNumber &lhs, const QVersionNumber &rhs) noexcept
bool isNormalized() const noexcept
static Q_CORE_EXPORT QVersionNumber fromString(const QString &string, int *suffixIndex=nullptr)
Q_CORE_EXPORT QString toString() const
int segmentCount() const noexcept
Q_CORE_EXPORT QVersionNumber normalized() const
int segmentAt(int index) const noexcept
QVersionNumber(int maj, int min, int mic)
QVersionNumber(int maj, int min)
friend Q_CORE_EXPORT size_t qHash(const QVersionNumber &key, size_t seed)
int microVersion() const noexcept
friend bool operator>=(const QVersionNumber &lhs, const QVersionNumber &rhs) noexcept
static Q_CORE_EXPORT int compare(const QVersionNumber &v1, const QVersionNumber &v2) noexcept
QVersionNumber(QList< int > &&seg)
auto it unsigned count const
void swap(SimpleVector< T > &v1, SimpleVector< T > &v2)
EGLOutputLayerEXT EGLint EGLAttrib value
QT_BEGIN_NAMESPACE typedef signed char qint8
#define QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(Class)
GLint GLfloat GLfloat GLfloat v2
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
Q_DECLARE_TYPEINFO(QVersionNumber, Q_RELOCATABLE_TYPE)
QTextStream out(stdout)
[7]
QThreadStorage< int * > dummy[8]