File indexing completed on 2025-01-18 10:07:33
0001
0002
0003
0004 #include <QtCore/qglobal.h>
0005 #include <QtCore/qversionnumber.h>
0006
0007 #ifndef QOPERATINGSYSTEMVERSION_H
0008 #define QOPERATINGSYSTEMVERSION_H
0009
0010 QT_BEGIN_NAMESPACE
0011
0012 #if 0
0013 # pragma qt_class(QOperatingSystemVersionBase)
0014 # pragma qt_class(QOperatingSystemVersion)
0015 # pragma qt_sync_stop_processing
0016 #endif
0017
0018 class QString;
0019
0020 class QOperatingSystemVersionBase
0021 {
0022 public:
0023
0024
0025 enum OSType {
0026 Unknown = 0,
0027 Windows,
0028 MacOS,
0029 IOS,
0030 TvOS,
0031 WatchOS,
0032 Android
0033 };
0034
0035 constexpr QOperatingSystemVersionBase(OSType osType,
0036 int vmajor, int vminor = -1, int vmicro = -1)
0037 : m_os(osType),
0038 m_major(vmajor),
0039 m_minor(vminor),
0040 m_micro(vmicro)
0041 { }
0042
0043 static Q_CORE_EXPORT QOperatingSystemVersionBase current();
0044 static Q_CORE_EXPORT QString name(QOperatingSystemVersionBase osversion);
0045 static Q_CORE_EXPORT bool isAnyOfType(std::initializer_list<OSType> types, OSType type);
0046
0047 static constexpr OSType currentType()
0048 {
0049 #if defined(Q_OS_WIN)
0050 return Windows;
0051 #elif defined(Q_OS_MACOS)
0052 return MacOS;
0053 #elif defined(Q_OS_IOS)
0054 return IOS;
0055 #elif defined(Q_OS_TVOS)
0056 return TvOS;
0057 #elif defined(Q_OS_WATCHOS)
0058 return WatchOS;
0059 #elif defined(Q_OS_ANDROID)
0060 return Android;
0061 #else
0062 return Unknown;
0063 #endif
0064 }
0065
0066 inline QVersionNumber version() const { return QVersionNumber(m_major, m_minor, m_micro); }
0067
0068 constexpr int majorVersion() const { return m_major; }
0069 constexpr int minorVersion() const { return m_minor; }
0070 constexpr int microVersion() const { return m_micro; }
0071
0072 constexpr int segmentCount() const
0073 { return m_micro >= 0 ? 3 : m_minor >= 0 ? 2 : m_major >= 0 ? 1 : 0; }
0074
0075 inline bool isAnyOfType(std::initializer_list<OSType> types) const
0076 {
0077 return QOperatingSystemVersionBase::isAnyOfType(types, type());
0078 }
0079 constexpr OSType type() const { return m_os; }
0080 inline QString name() const { return name(*this); }
0081
0082 friend bool operator>(QOperatingSystemVersionBase lhs, QOperatingSystemVersionBase rhs)
0083 { return lhs.type() == rhs.type() && QOperatingSystemVersionBase::compare(lhs, rhs) > 0; }
0084
0085 friend bool operator>=(QOperatingSystemVersionBase lhs, QOperatingSystemVersionBase rhs)
0086 { return lhs.type() == rhs.type() && QOperatingSystemVersionBase::compare(lhs, rhs) >= 0; }
0087
0088 friend bool operator<(QOperatingSystemVersionBase lhs, QOperatingSystemVersionBase rhs)
0089 { return lhs.type() == rhs.type() && QOperatingSystemVersionBase::compare(lhs, rhs) < 0; }
0090
0091 friend bool operator<=(QOperatingSystemVersionBase lhs, QOperatingSystemVersionBase rhs)
0092 { return lhs.type() == rhs.type() && QOperatingSystemVersionBase::compare(lhs, rhs) <= 0; }
0093
0094
0095 protected:
0096 static Q_CORE_EXPORT int compare(QOperatingSystemVersionBase v1,
0097 QOperatingSystemVersionBase v2);
0098
0099 QOperatingSystemVersionBase() = default;
0100 private:
0101 static QOperatingSystemVersionBase current_impl();
0102
0103 OSType m_os;
0104 int m_major;
0105 int m_minor;
0106 int m_micro;
0107 };
0108
0109 #if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) && !defined(QT_BOOTSTRAPPED) && !defined(Q_QDOC)
0110 class QOperatingSystemVersionUnexported : public QOperatingSystemVersionBase
0111 {
0112 public:
0113 using QOperatingSystemVersionBase::QOperatingSystemVersionBase;
0114 constexpr QOperatingSystemVersionUnexported(QOperatingSystemVersionBase other) noexcept
0115 : QOperatingSystemVersionBase(other) {}
0116 #else
0117 class QOperatingSystemVersion : public QOperatingSystemVersionBase
0118 {
0119 using QOperatingSystemVersionUnexported = QOperatingSystemVersionBase;
0120 #endif
0121
0122
0123 static constexpr QOperatingSystemVersionBase MacOSSonoma { QOperatingSystemVersionBase::MacOS, 14, 0 };
0124 static constexpr QOperatingSystemVersionBase Android14 { QOperatingSystemVersionBase::Android, 14, 0 };
0125 static constexpr QOperatingSystemVersionBase Windows11_23H2 { QOperatingSystemVersionBase::Windows, 10, 0, 22631 };
0126
0127 #if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) && !defined(QT_BOOTSTRAPPED) && !defined(Q_QDOC)
0128 };
0129
0130 class Q_CORE_EXPORT QOperatingSystemVersion : public QOperatingSystemVersionUnexported
0131 {
0132 #endif
0133 public:
0134
0135 #if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) && !defined(QT_BOOTSTRAPPED)
0136 enum OSType {
0137 Unknown = 0,
0138 Windows,
0139 MacOS,
0140 IOS,
0141 TvOS,
0142 WatchOS,
0143 Android
0144 };
0145 #endif
0146
0147
0148
0149
0150 #if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) && !defined(QT_BOOTSTRAPPED)
0151 static const QOperatingSystemVersion Windows7;
0152 static const QOperatingSystemVersion Windows8;
0153 static const QOperatingSystemVersion Windows8_1;
0154 static const QOperatingSystemVersion Windows10;
0155
0156 static const QOperatingSystemVersion OSXMavericks;
0157 static const QOperatingSystemVersion OSXYosemite;
0158 static const QOperatingSystemVersion OSXElCapitan;
0159 static const QOperatingSystemVersion MacOSSierra;
0160 static const QOperatingSystemVersion MacOSHighSierra;
0161 static const QOperatingSystemVersion MacOSMojave;
0162 static const QOperatingSystemVersion MacOSCatalina;
0163 static const QOperatingSystemVersion MacOSBigSur;
0164 static const QOperatingSystemVersion MacOSMonterey;
0165
0166 static const QOperatingSystemVersion AndroidJellyBean;
0167 static const QOperatingSystemVersion AndroidJellyBean_MR1;
0168 static const QOperatingSystemVersion AndroidJellyBean_MR2;
0169 static const QOperatingSystemVersion AndroidKitKat;
0170 static const QOperatingSystemVersion AndroidLollipop;
0171 static const QOperatingSystemVersion AndroidLollipop_MR1;
0172 static const QOperatingSystemVersion AndroidMarshmallow;
0173 static const QOperatingSystemVersion AndroidNougat;
0174 static const QOperatingSystemVersion AndroidNougat_MR1;
0175 static const QOperatingSystemVersion AndroidOreo;
0176 static const QOperatingSystemVersion AndroidOreo_MR1;
0177 static const QOperatingSystemVersion AndroidPie;
0178 static const QOperatingSystemVersion Android10;
0179 static const QOperatingSystemVersion Android11;
0180 #else
0181 static constexpr QOperatingSystemVersionBase Windows7 { QOperatingSystemVersionBase::Windows, 6, 1 };
0182 static constexpr QOperatingSystemVersionBase Windows8 { QOperatingSystemVersionBase::Windows, 6, 2 };
0183 static constexpr QOperatingSystemVersionBase Windows8_1 { QOperatingSystemVersionBase::Windows, 6, 3 };
0184 static constexpr QOperatingSystemVersionBase Windows10 { QOperatingSystemVersionBase::Windows, 10 };
0185
0186 static constexpr QOperatingSystemVersionBase OSXMavericks { QOperatingSystemVersionBase::MacOS, 10, 9 };
0187 static constexpr QOperatingSystemVersionBase OSXYosemite { QOperatingSystemVersionBase::MacOS, 10, 10 };
0188 static constexpr QOperatingSystemVersionBase OSXElCapitan { QOperatingSystemVersionBase::MacOS, 10, 11 };
0189 static constexpr QOperatingSystemVersionBase MacOSSierra { QOperatingSystemVersionBase::MacOS, 10, 12 };
0190 static constexpr QOperatingSystemVersionBase MacOSHighSierra { QOperatingSystemVersionBase::MacOS, 10, 13 };
0191 static constexpr QOperatingSystemVersionBase MacOSMojave { QOperatingSystemVersionBase::MacOS, 10, 14 };
0192 static constexpr QOperatingSystemVersionBase MacOSCatalina { QOperatingSystemVersionBase::MacOS, 10, 15 };
0193 static constexpr QOperatingSystemVersionBase MacOSBigSur = { QOperatingSystemVersionBase::MacOS, 11, 0 };
0194 static constexpr QOperatingSystemVersionBase MacOSMonterey = { QOperatingSystemVersionBase::MacOS, 12, 0 };
0195
0196 static constexpr QOperatingSystemVersionBase AndroidJellyBean { QOperatingSystemVersionBase::Android, 4, 1 };
0197 static constexpr QOperatingSystemVersionBase AndroidJellyBean_MR1 { QOperatingSystemVersionBase::Android, 4, 2 };
0198 static constexpr QOperatingSystemVersionBase AndroidJellyBean_MR2 { QOperatingSystemVersionBase::Android, 4, 3 };
0199 static constexpr QOperatingSystemVersionBase AndroidKitKat { QOperatingSystemVersionBase::Android, 4, 4 };
0200 static constexpr QOperatingSystemVersionBase AndroidLollipop { QOperatingSystemVersionBase::Android, 5, 0 };
0201 static constexpr QOperatingSystemVersionBase AndroidLollipop_MR1 { QOperatingSystemVersionBase::Android, 5, 1 };
0202 static constexpr QOperatingSystemVersionBase AndroidMarshmallow { QOperatingSystemVersionBase::Android, 6, 0 };
0203 static constexpr QOperatingSystemVersionBase AndroidNougat { QOperatingSystemVersionBase::Android, 7, 0 };
0204 static constexpr QOperatingSystemVersionBase AndroidNougat_MR1 { QOperatingSystemVersionBase::Android, 7, 1 };
0205 static constexpr QOperatingSystemVersionBase AndroidOreo { QOperatingSystemVersionBase::Android, 8, 0 };
0206 static constexpr QOperatingSystemVersionBase AndroidOreo_MR1 { QOperatingSystemVersionBase::Android, 8, 1 };
0207 static constexpr QOperatingSystemVersionBase AndroidPie { QOperatingSystemVersionBase::Android, 9, 0 };
0208 static constexpr QOperatingSystemVersionBase Android10 { QOperatingSystemVersionBase::Android, 10, 0 };
0209 static constexpr QOperatingSystemVersionBase Android11 { QOperatingSystemVersionBase::Android, 11, 0 };
0210 #endif
0211
0212 static constexpr QOperatingSystemVersionBase Windows10_1809 { QOperatingSystemVersionBase::Windows, 10, 0, 17763 };
0213 static constexpr QOperatingSystemVersionBase Windows10_1903 { QOperatingSystemVersionBase::Windows, 10, 0, 18362 };
0214 static constexpr QOperatingSystemVersionBase Windows10_1909 { QOperatingSystemVersionBase::Windows, 10, 0, 18363 };
0215 static constexpr QOperatingSystemVersionBase Windows10_2004 { QOperatingSystemVersionBase::Windows, 10, 0, 19041 };
0216 static constexpr QOperatingSystemVersionBase Windows10_20H2 { QOperatingSystemVersionBase::Windows, 10, 0, 19042 };
0217 static constexpr QOperatingSystemVersionBase Windows10_21H1 { QOperatingSystemVersionBase::Windows, 10, 0, 19043 };
0218 static constexpr QOperatingSystemVersionBase Windows10_21H2 { QOperatingSystemVersionBase::Windows, 10, 0, 19044 };
0219 static constexpr QOperatingSystemVersionBase Windows10_22H2 { QOperatingSystemVersionBase::Windows, 10, 0, 19045 };
0220 static constexpr QOperatingSystemVersionBase Windows11 { QOperatingSystemVersionBase::Windows, 10, 0, 22000 };
0221 static constexpr QOperatingSystemVersionBase Windows11_21H2 = Windows11;
0222 static constexpr QOperatingSystemVersionBase Windows11_22H2 { QOperatingSystemVersionBase::Windows, 10, 0, 22621 };
0223
0224 static constexpr QOperatingSystemVersionBase Android12 { QOperatingSystemVersionBase::Android, 12, 0 };
0225 static constexpr QOperatingSystemVersionBase Android12L { QOperatingSystemVersionBase::Android, 12, 0 };
0226 static constexpr QOperatingSystemVersionBase Android13 { QOperatingSystemVersionBase::Android, 13, 0 };
0227
0228 static constexpr QOperatingSystemVersionBase MacOSVentura { QOperatingSystemVersionBase::MacOS, 13, 0 };
0229
0230 constexpr QOperatingSystemVersion(const QOperatingSystemVersionBase &osversion)
0231 : QOperatingSystemVersionUnexported(osversion) {}
0232
0233 constexpr QOperatingSystemVersion(OSType osType, int vmajor, int vminor = -1, int vmicro = -1)
0234 : QOperatingSystemVersionUnexported(QOperatingSystemVersionBase::OSType(osType), vmajor, vminor,
0235 vmicro)
0236 {
0237 }
0238
0239 #if QT_CORE_REMOVED_SINCE(6, 3) || defined(Q_QDOC)
0240 static QOperatingSystemVersion current();
0241 #endif
0242
0243 static constexpr OSType currentType()
0244 {
0245 return OSType(QOperatingSystemVersionBase::currentType());
0246 }
0247
0248 #if QT_CORE_REMOVED_SINCE(6, 3) || defined(Q_QDOC)
0249 QVersionNumber version() const { return QOperatingSystemVersionBase::version(); }
0250
0251 constexpr int majorVersion() const { return QOperatingSystemVersionBase::majorVersion(); }
0252 constexpr int minorVersion() const { return QOperatingSystemVersionBase::minorVersion(); }
0253 constexpr int microVersion() const { return QOperatingSystemVersionBase::microVersion(); }
0254
0255 constexpr int segmentCount() const
0256 { return QOperatingSystemVersionBase::segmentCount(); }
0257 #endif
0258
0259 constexpr OSType type() const { return OSType(QOperatingSystemVersionBase::type()); }
0260 QT7_ONLY(Q_CORE_EXPORT) bool isAnyOfType(std::initializer_list<OSType> types) const;
0261 #if QT_CORE_REMOVED_SINCE(6, 3) || defined(Q_QDOC)
0262 QString name() const;
0263 #endif
0264
0265 private:
0266 QOperatingSystemVersion() = default;
0267
0268 #if QT_CORE_REMOVED_SINCE(6, 3)
0269
0270 [[maybe_unused]] static int compare(const QOperatingSystemVersion &v1,
0271 const QOperatingSystemVersion &v2);
0272 #endif
0273 };
0274 Q_DECLARE_TYPEINFO(QOperatingSystemVersion, Q_PRIMITIVE_TYPE);
0275
0276 #ifndef QT_NO_DEBUG_STREAM
0277 class QDebug;
0278 Q_CORE_EXPORT QDebug operator<<(QDebug debug, const QOperatingSystemVersion &ov);
0279 #endif
0280
0281 QT_END_NAMESPACE
0282
0283 #endif