diff --git a/inc/finalmq/Qt/qt.h b/inc/finalmq/Qt/qt.h index 93a26afe..23650121 100644 --- a/inc/finalmq/Qt/qt.h +++ b/inc/finalmq/Qt/qt.h @@ -220,10 +220,10 @@ class QtTypeHelper m_typesToField.emplace("QBitArray", MetaField{MetaTypeId::TYPE_ARRAY_BOOL, "", "", "", 0, {}}); m_typesToField.emplace("QDate", MetaField{MetaTypeId::TYPE_INT64, "", "", "", 0, {}}); m_typesToField.emplace("QTime", MetaField{MetaTypeId::TYPE_UINT32, "", "", "", 0, {}}); - // m_typesToField.emplace("QDateTime", MetaField{ MetaTypeId::TYPE_STRUCT, "", "", "", 0, {} }); m_typesToField.emplace("QUrl", MetaField{MetaTypeId::TYPE_BYTES, "", "", "", 0, {"qttype:QUrl,qtcode:bytes"}}); m_typesToField.emplace("QLocale", MetaField{MetaTypeId::TYPE_STRING, "", "", "", 0, {}}); m_typesToField.emplace("QPixmap", MetaField{ MetaTypeId::TYPE_BYTES, "", "", "", 0, {"png:true"} }); + m_typesToField.emplace("QSizePolicy", MetaField{ MetaTypeId::TYPE_UINT32, "", "", "", 0, {} }); static const std::string KEY_QTTYPE = "qttype"; diff --git a/inc/finalmq/Qt/qtdata.fmq b/inc/finalmq/Qt/qtdata.fmq index 65378271..b7daa299 100644 --- a/inc/finalmq/Qt/qtdata.fmq +++ b/inc/finalmq/Qt/qtdata.fmq @@ -79,8 +79,63 @@ {"type":"FmqQIconState","attrs":[],"desc":"","entries":[ {"name":"On", "id":0, "desc":""}, {"name":"Off", "id":1, "desc":""} + ]}, + {"type":"FmqQtWindowModality","attrs":["qttype:Qt::WindowModality"],"desc":"","entries":[ + {"name":"NonModal", "id":0, "desc":""}, + {"name":"WindowModal", "id":1, "desc":""}, + {"name":"ApplicationModal", "id":2, "desc":""} + ]}, + {"type":"FmqQFontStyleHint","attrs":["enumbits:8"],"desc":"","entries":[ + {"name":"Helvetica", "id":0, "desc":""}, + {"name":"Times", "id":1, "desc":""}, + {"name":"Courier", "id":2, "desc":""}, + {"name":"OldEnglish", "id":3, "desc":""}, + {"name":"System", "id":4, "desc":""}, + {"name":"AnyStyle", "id":5, "desc":""}, + {"name":"Cursive", "id":6, "desc":""}, + {"name":"Monospace", "id":7, "desc":""}, + {"name":"Fantasy", "id":8, "desc":""} + ]}, + {"type":"FmqQFontStyleStrategy","attrs":["enumbits:16"],"desc":"","entries":[ + {"name":"None", "id":0, "desc":""}, + {"name":"PreferDefault", "id":1, "desc":""}, + {"name":"PreferBitmap", "id":2, "desc":""}, + {"name":"PreferDevice", "id":4, "desc":""}, + {"name":"PreferOutline", "id":8, "desc":""}, + {"name":"ForceOutline", "id":16, "desc":""}, + {"name":"PreferMatch", "id":32, "desc":""}, + {"name":"PreferQuality", "id":64, "desc":""}, + {"name":"PreferAntialias", "id":128, "desc":""}, + {"name":"NoAntialias", "id":256, "desc":""}, + {"name":"OpenGLCompatible", "id":512, "desc":""}, + {"name":"ForceIntegerMetrics", "id":1024, "desc":""}, + {"name":"NoSubpixelAntialias", "id":2048, "desc":""}, + {"name":"PreferNoShaping", "id":4096, "desc":""}, + {"name":"NoFontMerging", "id":32768, "desc":""} + ]}, + {"type":"FmqQFontFontBits","attrs":["enumbits:8"],"desc":"","entries":[ + {"name":"None", "id":0, "desc":""}, + {"name":"Style", "id":1, "desc":""}, + {"name":"Underline", "id":2, "desc":""}, + {"name":"Overline", "id":64, "desc":""}, + {"name":"StrikeOut", "id":4, "desc":""}, + {"name":"FixedPitch", "id":8, "desc":""}, + {"name":"Kerning", "id":16, "desc":""}, + {"name":"StyleOblique", "id":128, "desc":""} + ]}, + {"type":"FmqQFontExtendedFontBits","attrs":["enumbits:8"],"desc":"","entries":[ + {"name":"None", "id":0, "desc":""}, + {"name":"IgnorePitch", "id":1, "desc":""}, + {"name":"LetterSpacingIsAbsolute", "id":2, "desc":""} + ]}, + {"type":"FmqQFontHintingPreference","attrs":["enumbits:8"],"desc":"","entries":[ + {"name":"PreferDefaultHinting", "id":0, "desc":""}, + {"name":"PreferNoHinting", "id":1, "desc":""}, + {"name":"PreferVerticalHinting", "id":2, "desc":""}, + {"name":"PreferFullHinting", "id":3, "desc":""} ]} + ], "structs":[ @@ -317,8 +372,32 @@ {"tid":"string", "name":"iconEngineKey", "attrs":["indexmode:mapping,:0,QPixmapIconEngine:1"], "desc":"","flags":["METAFLAG_INDEX"]}, {"tid":"int8[]", "name":"valueNone", "desc":"desc","attrs":["fixedarray:0"],"flags":[]}, {"tid":"struct[]", "type":"FmqQPixmapIconEngine", "name":"qPixmapIconEngine", "desc":"","flags":[]} - ]} + ]}, + {"type":"FmqQRegion","attrs":["qttype:QRegion"],"desc":"","fields":[ + {"tid":"int32", "name":"sizeBytes", "attrs":["structabort:0"], "desc":"When you change FmqQRegion, you always have to set this value to [8+16*rects.size()} or to 0, if rects.size() is 0.","flags":[]}, + {"tid":"int32", "name":"command", "desc":"When you change FmqQRegion, you have to set this value to 10","flags":[]}, + {"tid":"struct[]", "type":"FmqQRect", "name":"rects", "desc":"","flags":[]} + ]}, + + {"type":"FmqQFont","attrs":["qttype:QFont"],"desc":"","fields":[ + {"tid":"string", "name":"family", "desc":"","flags":[]}, + {"tid":"string", "name":"style", "desc":"","flags":[]}, + {"tid":"double", "name":"pointSize", "desc":"","flags":[]}, + {"tid":"int32", "name":"pixelSize", "desc":"","flags":[]}, + {"tid":"enum", "type":"FmqQFontStyleHint", "name":"styleHint", "desc":"","flags":[]}, + {"tid":"uint16", "name":"styleStrategy", "desc":"","flags":[]}, + {"tid":"uint8", "name":"dummy", "desc":"","flags":[]}, + {"tid":"uint8", "name":"weight", "desc":"","flags":[]}, + {"tid":"uint8", "name":"fontBits", "desc":"","flags":[]}, + {"tid":"uint16", "name":"stretch", "desc":"","flags":[]}, + {"tid":"uint8", "name":"extendedFontBits", "desc":"","flags":[]}, + {"tid":"int32", "name":"letterSpacing", "desc":"","flags":[]}, + {"tid":"int32", "name":"wordSpacing", "desc":"","flags":[]}, + {"tid":"enum", "type":"FmqQFontHintingPreference", "name":"hintingPreference", "desc":"","flags":[]}, + {"tid":"uint8", "name":"capital", "desc":"","flags":[]}, + {"tid":"string[]", "name":"families", "desc":"","flags":[]} + ]} ] diff --git a/inc/finalmq/serialize/ParserAbortAndIndex.h b/inc/finalmq/serialize/ParserAbortAndIndex.h index e3c6d3e2..39e5730a 100644 --- a/inc/finalmq/serialize/ParserAbortAndIndex.h +++ b/inc/finalmq/serialize/ParserAbortAndIndex.h @@ -101,11 +101,6 @@ class SYMBOLEXP ParserAbortAndIndex : public IParserVisitor virtual void enterArrayEnumMove(const MetaField& field, std::vector&& value) override; virtual void enterArrayEnum(const MetaField& field, const std::vector& value) override; - void checkIndex(const MetaField& field, std::int64_t value); - void checkIndex(const MetaField& field, const std::string& value); - - IParserVisitor* m_visitor; - enum IndexStatus { INDEX_NOT_AVAILABLE = -1, @@ -125,6 +120,13 @@ class SYMBOLEXP ParserAbortAndIndex : public IParserVisitor std::int64_t index{ INDEX_NOT_AVAILABLE }; }; + void checkIndex(const MetaField& field, std::int64_t value); + void checkIndex(const MetaField& field, const std::string& value); + void checkAbortAndIndex(const MetaField& field, const std::string& value, LevelState& levelState); + void checkAbortAndIndex(const MetaField& field, std::int64_t value, LevelState& levelState); + + IParserVisitor* m_visitor; + std::deque m_levelState{}; }; diff --git a/inc/finalmq/serializeqt/ParserQt.h b/inc/finalmq/serializeqt/ParserQt.h index f600e655..57ee4b4f 100644 --- a/inc/finalmq/serializeqt/ParserQt.h +++ b/inc/finalmq/serializeqt/ParserQt.h @@ -75,6 +75,8 @@ namespace finalmq { bool parseQVariantHeader(const MetaField& field); void checkIndex(const MetaField& field, std::int64_t value, std::int64_t& index, std::int64_t& indexOffset); void checkIndex(const MetaField& field, const std::string& value, std::int64_t& index, std::int64_t& indexOffset); + void checkAbortAndIndex(const MetaField& field, const std::string& value, std::int64_t& index, std::int64_t& indexOffset, bool& abortStruct); + void checkAbortAndIndex(const MetaField& field, std::int64_t value, std::int64_t& index, std::int64_t& indexOffset, bool& abortStruct); bool getPngSize(std::uint32_t& size); bool parseSize(const MetaField& field, std::uint32_t& value); diff --git a/src/serialize/ParserAbortAndIndex.cpp b/src/serialize/ParserAbortAndIndex.cpp index 1310c774..2778acab 100644 --- a/src/serialize/ParserAbortAndIndex.cpp +++ b/src/serialize/ParserAbortAndIndex.cpp @@ -191,7 +191,7 @@ void ParserAbortAndIndex::enterInt8(const MetaField& field, std::int8_t value) } m_visitor->enterInt8(field, value); - checkIndex(field, value); + checkAbortAndIndex(field, value, levelState); } void ParserAbortAndIndex::enterUInt8(const MetaField& field, std::uint8_t value) { @@ -202,7 +202,7 @@ void ParserAbortAndIndex::enterUInt8(const MetaField& field, std::uint8_t value) return; } m_visitor->enterUInt8(field, value); - checkIndex(field, value); + checkAbortAndIndex(field, value, levelState); } void ParserAbortAndIndex::enterInt16(const MetaField& field, std::int16_t value) { @@ -214,7 +214,7 @@ void ParserAbortAndIndex::enterInt16(const MetaField& field, std::int16_t value) } m_visitor->enterInt16(field, value); - checkIndex(field, value); + checkAbortAndIndex(field, value, levelState); } void ParserAbortAndIndex::enterUInt16(const MetaField& field, std::uint16_t value) { @@ -226,7 +226,7 @@ void ParserAbortAndIndex::enterUInt16(const MetaField& field, std::uint16_t valu } m_visitor->enterUInt16(field, value); - checkIndex(field, value); + checkAbortAndIndex(field, value, levelState); } void ParserAbortAndIndex::enterInt32(const MetaField& field, std::int32_t value) { @@ -238,7 +238,7 @@ void ParserAbortAndIndex::enterInt32(const MetaField& field, std::int32_t value) } m_visitor->enterInt32(field, value); - checkIndex(field, value); + checkAbortAndIndex(field, value, levelState); } void ParserAbortAndIndex::enterUInt32(const MetaField& field, std::uint32_t value) { @@ -250,7 +250,7 @@ void ParserAbortAndIndex::enterUInt32(const MetaField& field, std::uint32_t valu } m_visitor->enterUInt32(field, value); - checkIndex(field, value); + checkAbortAndIndex(field, value, levelState); } void ParserAbortAndIndex::enterInt64(const MetaField& field, std::int64_t value) { @@ -262,7 +262,7 @@ void ParserAbortAndIndex::enterInt64(const MetaField& field, std::int64_t value) } m_visitor->enterInt64(field, value); - checkIndex(field, value); + checkAbortAndIndex(field, value, levelState); } void ParserAbortAndIndex::enterUInt64(const MetaField& field, std::uint64_t value) { @@ -274,7 +274,7 @@ void ParserAbortAndIndex::enterUInt64(const MetaField& field, std::uint64_t valu } m_visitor->enterUInt64(field, value); - checkIndex(field, value); + checkAbortAndIndex(field, value, levelState); } void ParserAbortAndIndex::enterFloat(const MetaField& field, float value) { @@ -319,20 +319,7 @@ void ParserAbortAndIndex::enterString(const MetaField& field, const char* value, { strValue = std::string(value, &value[size]); } - const std::string& valueAbort = field.getProperty(ABORTSTRUCT); - if (!valueAbort.empty()) - { - std::vector valuesAbort; - Utils::split(valueAbort, 0, valueAbort.size(), '|', valuesAbort); - if (std::find(valuesAbort.begin(), valuesAbort.end(), strValue) != valuesAbort.end()) - { - levelState.abortStruct = ABORT_FIELD; - } - } - else - { - checkIndex(field, strValue); - } + checkAbortAndIndex(field, strValue, levelState); } void ParserAbortAndIndex::enterBytes(const MetaField& field, Bytes&& value) { @@ -851,6 +838,45 @@ void ParserAbortAndIndex::checkIndex(const MetaField& field, const std::string& } } +void ParserAbortAndIndex::checkAbortAndIndex(const MetaField& field, const std::string& value, LevelState& levelState) +{ + // check abort + const std::string& valueAbort = field.getProperty(ABORTSTRUCT); + if (!valueAbort.empty()) + { + std::vector valuesAbort; + Utils::split(valueAbort, 0, valueAbort.size(), '|', valuesAbort); + if (std::find(valuesAbort.begin(), valuesAbort.end(), value) != valuesAbort.end()) + { + levelState.abortStruct = ABORT_FIELD; + } + } + else + { + checkIndex(field, value); + } +} + +void ParserAbortAndIndex::checkAbortAndIndex(const MetaField& field, std::int64_t value, LevelState& levelState) +{ + // check abort + std::string strValue; + const std::string& valueAbort = field.getProperty(ABORTSTRUCT); + if (!valueAbort.empty()) + { + const std::string strValue = std::to_string(value); + std::vector valuesAbort; + Utils::split(valueAbort, 0, valueAbort.size(), '|', valuesAbort); + if (std::find(valuesAbort.begin(), valuesAbort.end(), strValue) != valuesAbort.end()) + { + levelState.abortStruct = ABORT_FIELD; + } + } + else + { + checkIndex(field, value); + } +} } // namespace finalmq diff --git a/src/serializeqt/ParserQt.cpp b/src/serializeqt/ParserQt.cpp index 61ab4c5e..cf3cb213 100644 --- a/src/serializeqt/ParserQt.cpp +++ b/src/serializeqt/ParserQt.cpp @@ -170,7 +170,7 @@ bool ParserQt::parseStructIntern(const MetaStruct& stru, bool wrappedByQVariant) if (ok) { m_visitor.enterInt8(*field, value); - checkIndex(*field, value, index, indexOffset); + checkAbortAndIndex(*field, value, index, indexOffset, abortStruct); } } break; @@ -186,7 +186,7 @@ bool ParserQt::parseStructIntern(const MetaStruct& stru, bool wrappedByQVariant) if (ok) { m_visitor.enterUInt8(*field, value); - checkIndex(*field, value, index, indexOffset); + checkAbortAndIndex(*field, value, index, indexOffset, abortStruct); } } break; @@ -202,7 +202,7 @@ bool ParserQt::parseStructIntern(const MetaStruct& stru, bool wrappedByQVariant) if (ok) { m_visitor.enterInt16(*field, value); - checkIndex(*field, value, index, indexOffset); + checkAbortAndIndex(*field, value, index, indexOffset, abortStruct); } } break; @@ -218,7 +218,7 @@ bool ParserQt::parseStructIntern(const MetaStruct& stru, bool wrappedByQVariant) if (ok) { m_visitor.enterUInt16(*field, value); - checkIndex(*field, value, index, indexOffset); + checkAbortAndIndex(*field, value, index, indexOffset, abortStruct); } } break; @@ -234,7 +234,7 @@ bool ParserQt::parseStructIntern(const MetaStruct& stru, bool wrappedByQVariant) if (ok) { m_visitor.enterInt32(*field, value); - checkIndex(*field, value, index, indexOffset); + checkAbortAndIndex(*field, value, index, indexOffset, abortStruct); } } break; @@ -250,7 +250,7 @@ bool ParserQt::parseStructIntern(const MetaStruct& stru, bool wrappedByQVariant) if (ok) { m_visitor.enterUInt32(*field, value); - checkIndex(*field, value, index, indexOffset); + checkAbortAndIndex(*field, value, index, indexOffset, abortStruct); } } break; @@ -266,7 +266,7 @@ bool ParserQt::parseStructIntern(const MetaStruct& stru, bool wrappedByQVariant) if (ok) { m_visitor.enterInt64(*field, value); - checkIndex(*field, value, index, indexOffset); + checkAbortAndIndex(*field, value, index, indexOffset, abortStruct); } } break; @@ -282,7 +282,7 @@ bool ParserQt::parseStructIntern(const MetaStruct& stru, bool wrappedByQVariant) if (ok) { m_visitor.enterUInt64(*field, value); - checkIndex(*field, value, index, indexOffset); + checkAbortAndIndex(*field, value, index, indexOffset, abortStruct); } } break; @@ -349,17 +349,7 @@ bool ParserQt::parseStructIntern(const MetaStruct& stru, bool wrappedByQVariant) { value = std::string(buffer, &buffer[size]); } - const std::string& valueAbort = field->getProperty(ABORTSTRUCT); - if (!valueAbort.empty()) - { - std::vector valuesAbort; - Utils::split(valueAbort, 0, valueAbort.size(), '|', valuesAbort); - abortStruct = (std::find(valuesAbort.begin(), valuesAbort.end(), value) != valuesAbort.end()); - } - else - { - checkIndex(*field, value, index, indexOffset); - } + checkAbortAndIndex(*field, value, index, indexOffset, abortStruct); } break; case MetaTypeId::TYPE_BYTES: @@ -1325,6 +1315,40 @@ void ParserQt::checkIndex(const MetaField& field, const std::string& value, std: } } +void ParserQt::checkAbortAndIndex(const MetaField& field, const std::string& value, std::int64_t& index, std::int64_t& indexOffset, bool& abortStruct) +{ + // check abort + const std::string& valueAbort = field.getProperty(ABORTSTRUCT); + if (!valueAbort.empty()) + { + std::vector valuesAbort; + Utils::split(valueAbort, 0, valueAbort.size(), '|', valuesAbort); + abortStruct = (std::find(valuesAbort.begin(), valuesAbort.end(), value) != valuesAbort.end()); + } + else + { + checkIndex(field, value, index, indexOffset); + } +} + +void ParserQt::checkAbortAndIndex(const MetaField& field, std::int64_t value, std::int64_t& index, std::int64_t& indexOffset, bool& abortStruct) +{ + // check abort + const std::string& valueAbort = field.getProperty(ABORTSTRUCT); + if (!valueAbort.empty()) + { + std::string strValue = std::to_string(value); + std::vector valuesAbort; + Utils::split(valueAbort, 0, valueAbort.size(), '|', valuesAbort); + abortStruct = (std::find(valuesAbort.begin(), valuesAbort.end(), strValue) != valuesAbort.end()); + } + else + { + checkIndex(field, value, index, indexOffset); + } +} + + bool ParserQt::getPngSize(std::uint32_t& size) { static const std::uint8_t PNG_PREFIX[] = { 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A };