9#include <QtCore/qassert.h>
10#include <QtCore/qcompare.h>
11#include <QtCore/qcontainertools_impl.h>
12#include <QtCore/qmetatype.h>
13#include <QtCore/qtypeinfo.h>
23Q_CORE_EXPORT size_t qHash(
const QTypeRevision &key, size_t seed = 0);
25#ifndef QT_NO_DATASTREAM
26Q_CORE_EXPORT
QDataStream& operator<<(QDataStream &out,
const QTypeRevision &revision);
27Q_CORE_EXPORT
QDataStream& operator>>(QDataStream &in, QTypeRevision &revision);
33 template<
typename Integer>
34 using if_valid_segment_type =
typename std::enable_if<
35 std::is_integral<Integer>::value,
bool>::type;
44 template<
typename Integer, if_valid_segment_type<Integer> =
true>
49 constexpr auto Max = (
std::numeric_limits<Integer>::max)() + 0;
50 constexpr bool HasSufficientRange = Max >= SegmentUnknown;
51 return segment >= Integer(0)
52 && (!HasSufficientRange || segment < Integer(SegmentUnknown));
55 template<
typename Major,
typename Minor,
56 if_valid_segment_type<Major> =
true,
57 if_valid_segment_type<Minor> =
true>
60 return Q_ASSERT(isValidSegment(majorVersion)),
61 Q_ASSERT(isValidSegment(minorVersion)),
65 template<
typename Major, if_valid_segment_type<Major> =
true>
68 return Q_ASSERT(isValidSegment(majorVersion)),
69 QTypeRevision(quint8(majorVersion), SegmentUnknown);
72 template<
typename Minor, if_valid_segment_type<Minor> =
true>
75 return Q_ASSERT(isValidSegment(minorVersion)),
76 QTypeRevision(SegmentUnknown, quint8(minorVersion));
79 template<
typename Integer, if_valid_value_type<Integer> =
true>
82 return Q_ASSERT((value & ~Integer(0xffff)) == Integer(0)),
83 QTypeRevision((value & Integer(0xff00)) >> 8, value & Integer(0xff));
90 constexpr bool hasMajorVersion()
const {
return m_majorVersion != SegmentUnknown; }
93 constexpr bool hasMinorVersion()
const {
return m_minorVersion != SegmentUnknown; }
96 constexpr bool isValid()
const {
return hasMajorVersion() || hasMinorVersion(); }
98 template<
typename Integer, if_valid_value_type<Integer> =
true>
101 return Integer(m_majorVersion << 8) | Integer(m_minorVersion);
105 friend constexpr bool
107 {
return lhs.toEncodedVersion<quint16>() == rhs.toEncodedVersion<quint16>(); }
113 auto cmpUnspecified = [](quint8 leftVer, quint8 rightVer) {
114 Q_ASSERT(leftVer != rightVer
115 && (leftVer == QTypeRevision::SegmentUnknown
116 || rightVer == QTypeRevision::SegmentUnknown));
117 if (leftVer != QTypeRevision::SegmentUnknown)
118 return leftVer > 0 ? Qt::strong_ordering::greater : Qt::strong_ordering::less;
119 return rightVer > 0 ? Qt::strong_ordering::less : Qt::strong_ordering::greater;
122 if (lhs.hasMajorVersion() != rhs.hasMajorVersion()) {
123 return cmpUnspecified(lhs.majorVersion(), rhs.majorVersion());
125 const auto majorRes = Qt::compareThreeWay(lhs.majorVersion(), rhs.majorVersion());
126 if (is_eq(majorRes)) {
127 if (lhs.hasMinorVersion() != rhs.hasMinorVersion())
128 return cmpUnspecified(lhs.minorVersion(), rhs.minorVersion());
129 return Qt::compareThreeWay(lhs.minorVersion(), rhs.minorVersion());
138#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
139 constexpr QTypeRevision(quint8 major, quint8 minor)
140 : m_minorVersion(minor), m_majorVersion(major) {}
156#ifndef QT_NO_DEBUG_STREAM
157Q_CORE_EXPORT
QDebug operator<<(QDebug,
const QTypeRevision &revision);
162QT_DECL_METATYPE_EXTERN(QTypeRevision, Q_CORE_EXPORT)
166#if !defined(QT_LEAN_HEADERS) || QT_LEAN_HEADERS < 2
168#include <QtCore/qversionnumber.h>
int main(int argc, char *argv[])
[2]
bool testFunctionAttribute(Token tok, FunctionDef *def)
void parseEnumOrFlag(BaseDef *def, QtMocConstants::EnumFlags flags)
void checkSuperClasses(ClassDef *def)
bool parseEnum(EnumDef *def)
void parseProperty(ClassDef *def, PropertyMode mode)
QByteArray lexemUntil(Token)
EncounteredQmlMacro parseClassInfo(BaseDef *def)
QList< QByteArray > includeFiles
bool requireCompleteTypes
QHash< QByteArray, QByteArray > knownQObjectClasses
void createPropertyDef(PropertyDef &def, int propertyIndex, PropertyMode mode)
void parseClassInfo(ClassDef *def)
QByteArrayView strippedFileName() const
bool parseClassHead(ClassDef *def)
void parsePrivateProperty(ClassDef *def, PropertyMode mode)
void parseFlag(BaseDef *def)
void parseSignals(ClassDef *def)
void parseDeclareMetatype()
void parsePropertyAttributes(PropertyDef &propDef)
void parseInterfaces(ClassDef *def)
bool testFunctionRevision(FunctionDef *def)
bool testFunctionAttribute(FunctionDef *def)
void prependNamespaces(BaseDef &def, const QList< NamespaceDef > &namespaceList) const
QHash< QByteArray, QByteArray > knownGadgets
QList< QByteArray > metaTypes
bool parseFunction(FunctionDef *def, bool inMacro=false)
QByteArray parsePropertyAccessor()
QMap< QString, QJsonArray > metaArgs
bool testForFunctionModifiers(FunctionDef *def)
const QByteArray & toFullyQualified(const QByteArray &name) const noexcept
void parseSlots(ClassDef *def, FunctionDef::Access access)
void parseDeclareInterface()
void checkListSizes(const ClassDef &def)
QTypeRevision parseRevision()
QList< QString > parsedPluginMetadataFiles
bool parseMaybeFunction(const ClassDef *cdef, FunctionDef *def)
void checkProperties(ClassDef *cdef)
void parseFunctionArguments(FunctionDef *def)
void parseSlotInPrivate(ClassDef *def, FunctionDef::Access access)
bool inClass(const ClassDef *def) const
void parsePluginData(ClassDef *def)
void generate(FILE *out, FILE *jsonOutput)
QMap< QByteArray, QByteArray > interface2IdMap
bool inNamespace(const NamespaceDef *def) const
QList< ClassDef > classList
void setDebugIncludes(bool value)
void parseDefineArguments(Macro *m)
QHash< QByteArray, QByteArray > nonlocalIncludePathResolutionCache
Symbols preprocessed(const QByteArray &filename, QFile *device)
void substituteUntilNewline(Symbols &substituted)
QList< QByteArray > frameworks
static bool preprocessOnly
static Symbols macroExpandIdentifier(Preprocessor *that, SymbolStack &symbols, int lineNum, QByteArray *macroName)
QByteArray resolveInclude(const QByteArray &filename, const QByteArray &relativeTo)
static Symbols tokenize(const QByteArray &input, int lineNum=1, TokenizeMode mode=TokenizeCpp)
static void macroExpand(Symbols *into, Preprocessor *that, const Symbols &toExpand, qsizetype &index, int lineNum, bool one, const QSet< QByteArray > &excludeSymbols=QSet< QByteArray >())
@ PreparePreprocessorStatement
@ TokenizePreprocessorStatement
The QCommandLineOption class defines a possible command-line option. \inmodule QtCore.
The QCommandLineParser class provides a means for handling the command line options.
\inmodule QtCore\reentrant
constexpr Integer toEncodedVersion() const
Transforms the revision into an integer value, encoding the minor version into the least significant ...
constexpr QTypeRevision()=default
Produces an invalid revision.
constexpr quint8 majorVersion() const
Returns the major version encoded in the revision.
static constexpr QTypeRevision fromMajorVersion(Major majorVersion)
Produces a QTypeRevision from the given majorVersion with an invalid minor version.
static constexpr bool isValidSegment(Integer segment)
Returns true if the given number can be used as either major or minor version in a QTypeRevision.
static constexpr QTypeRevision zero()
Produces a QTypeRevision with major and minor version {0}.
static constexpr QTypeRevision fromEncodedVersion(Integer value)
Produces a QTypeRevision from the given value.
constexpr bool hasMajorVersion() const
Returns true if the major version is known, otherwise false.
static constexpr QTypeRevision fromMinorVersion(Minor minorVersion)
Produces a QTypeRevision from the given minorVersion with an invalid major version.
constexpr bool isValid() const
Returns true if the major version or the minor version is known, otherwise false.
friend constexpr Qt::strong_ordering compareThreeWay(const QTypeRevision &lhs, const QTypeRevision &rhs) noexcept
constexpr quint8 minorVersion() const
Returns the minor version encoded in the revision.
static constexpr QTypeRevision fromVersion(Major majorVersion, Minor minorVersion)
Produces a QTypeRevision from the given majorVersion and minorVersion, both of which need to be a val...
friend constexpr bool comparesEqual(const QTypeRevision &lhs, const QTypeRevision &rhs) noexcept
constexpr bool hasMinorVersion() const
Returns true if the minor version is known, otherwise false.
QByteArray unquotedLexem()
const Symbol & symbol() const
bool dontReplaceSymbol(const QByteArray &name) const
Q_DECLARE_TYPEINFO(EnumDef, Q_RELOCATABLE_TYPE)
QByteArray noRef(const QByteArray &type)
Q_DECLARE_TYPEINFO(PropertyDef, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(NamespaceDef, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(ClassDef, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(ClassInfoDef, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(ClassDef::Interface, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(SuperClass, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(ArgumentDef, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(PrivateQPropertyDef, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(FunctionDef, Q_RELOCATABLE_TYPE)
Combined button and popup list for selecting options.
constexpr PropertyFlags DefaultPropertyFlags
@ PropertyAccessInStaticMetaCall
@ RequiresVariantMetaObject
QHash< MacroName, Macro > Macros
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Q_DECLARE_TYPEINFO(QObjectPrivate::ConnectionList, Q_RELOCATABLE_TYPE)
#define qPrintable(string)
static QByteArray combinePath(const QString &infile, const QString &outfile)
static bool hasNext(const Symbols &symbols, int i)
static const Symbol & next(const Symbols &symbols, int &i)
int runMoc(int argc, char **argv)
static auto openFileForWriting(const QString &name)
void error(const char *msg="Invalid argument")
static QStringList argumentsFromCommandLineAndFile(const QStringList &arguments, bool &hasOptionFiles)
QByteArray composePreprocessorOutput(const Symbols &symbols)
Q_DECLARE_TYPEINFO(QTypeRevision, Q_RELOCATABLE_TYPE)
QByteArray normalizedType
QJsonObject toJson() const
QByteArray typeNameForCast
QMap< QByteArray, QByteArray > flagAliases
QList< ClassInfoDef > classInfoList
QList< EnumDef > enumList
Interface(const QByteArray &_className)
QMap< QString, QJsonArray > metaArgs
QList< QList< Interface > > interfaceList
QList< FunctionDef > publicList
QList< FunctionDef > methodList
QList< PropertyDef > propertyList
QList< FunctionDef > constructorList
QList< SuperClass > superclassList
bool requireCompleteMethodTypes
QList< FunctionDef > slotList
QList< FunctionDef > signalList
QJsonObject toJson() const
QList< QByteArray > nonClassSignalList
QFlags< QtMocConstants::EnumFlags > flags
QByteArray qualifiedType(const ClassDef *cdef) const
QJsonObject toJson(const ClassDef &cdef) const
QList< QByteArray > values
QByteArray normalizedType
QJsonObject toJson(int index) const
static void accessToJson(QJsonObject *obj, Access acs)
QByteArray inPrivateClass
QList< ArgumentDef > arguments
bool returnTypeIsVolatile
Simple structure used by the Doc and DocParser classes.
QByteArray inPrivateClass
QJsonObject toJson() const
bool operator==(const SubArray &other) const
SubArray(const QByteArray &a)
SubArray(const QByteArray &a, qsizetype from, qsizetype len)
FunctionDef::Access access
Symbol(int lineNum, Token token)
operator SubArray() const
bool operator==(const Symbol &o) const
Symbol(int lineNum, Token token, const QByteArray &lexem, qsizetype from, qsizetype len)
QByteArray unquotedLexem() const
Symbol(int lineNum, Token token, const QByteArray &lexem)
size_t qHash(const SubArray &key, size_t seed=0)
Q_DECLARE_TYPEINFO(Symbol, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(SafeSymbols, Q_RELOCATABLE_TYPE)
#define FOR_ALL_TOKENS(F)