# HG changeset patch # User Teemu Piippo # Date 1632259513 -10800 # Node ID f77d2230e87c731ba3324d38bf70d49e6bdeb1c6 # Parent 488d0ba6070b6959bcefd7a6671b456cd6f2dee3 Add remaining serialize methods diff -r 488d0ba6070b -r f77d2230e87c src/linetypes/comment.cpp --- a/src/linetypes/comment.cpp Tue Sep 21 16:00:15 2021 +0300 +++ b/src/linetypes/comment.cpp Wed Sep 22 00:25:13 2021 +0300 @@ -12,3 +12,4 @@ { return Type::Comment; } + diff -r 488d0ba6070b -r f77d2230e87c src/linetypes/errorline.cpp --- a/src/linetypes/errorline.cpp Tue Sep 21 16:00:15 2021 +0300 +++ b/src/linetypes/errorline.cpp Wed Sep 22 00:25:13 2021 +0300 @@ -46,3 +46,13 @@ { return Type::ErrorLine; } + +QDataStream &ldraw::ErrorLine::serialize(QDataStream &stream) const +{ + return ldraw::Object::serialize(stream) << this->text; +} + +QDataStream &ldraw::ErrorLine::deserialize(QDataStream &stream) +{ + return ldraw::Object::deserialize(stream) >> this->text; +} diff -r 488d0ba6070b -r f77d2230e87c src/linetypes/errorline.h --- a/src/linetypes/errorline.h Tue Sep 21 16:00:15 2021 +0300 +++ b/src/linetypes/errorline.h Wed Sep 22 00:25:13 2021 +0300 @@ -16,6 +16,8 @@ QBrush textRepresentationForeground() const override; QBrush textRepresentationBackground() const override; Type typeIdentifier() const override; + QDataStream& serialize(QDataStream& stream) const override; + QDataStream& deserialize(QDataStream& stream) override; QString text; QString message; protected: diff -r 488d0ba6070b -r f77d2230e87c src/linetypes/metacommand.cpp --- a/src/linetypes/metacommand.cpp Tue Sep 21 16:00:15 2021 +0300 +++ b/src/linetypes/metacommand.cpp Wed Sep 22 00:25:13 2021 +0300 @@ -31,3 +31,23 @@ return Type::MetaCommand; } +/** + * @brief @overload ldraw::Object::serialize + * @param stream + * @return stream + */ +QDataStream& ldraw::MetaCommand::serialize(QDataStream& stream) const +{ + return ldraw::Object::serialize(stream) << this->storedText; +} + +/** + * @brief @overload ldraw::Object::deserialize + * @param stream + * @return stream + */ +QDataStream& ldraw::MetaCommand::deserialize(QDataStream& stream) +{ + return ldraw::Object::deserialize(stream) >> this->storedText; +} + diff -r 488d0ba6070b -r f77d2230e87c src/linetypes/metacommand.h --- a/src/linetypes/metacommand.h Tue Sep 21 16:00:15 2021 +0300 +++ b/src/linetypes/metacommand.h Wed Sep 22 00:25:13 2021 +0300 @@ -15,6 +15,8 @@ QString textRepresentation() const override; QString storedText = ""; Type typeIdentifier() const override; + QDataStream& serialize(QDataStream& stream) const override; + QDataStream& deserialize(QDataStream& stream) override; protected: void setProperty(SetPropertyResult* result, const PropertyKeyValue& pair) override; }; diff -r 488d0ba6070b -r f77d2230e87c src/linetypes/object.cpp --- a/src/linetypes/object.cpp Tue Sep 21 16:00:15 2021 +0300 +++ b/src/linetypes/object.cpp Wed Sep 22 00:25:13 2021 +0300 @@ -139,7 +139,7 @@ */ QDataStream& ldraw::ColoredObject::deserialize(QDataStream& stream) { - return Object::serialize(stream) >> this->colorIndex; + return Object::deserialize(stream) >> this->colorIndex; } QString ldraw::Empty::textRepresentation() const diff -r 488d0ba6070b -r f77d2230e87c src/linetypes/polygonobject.h --- a/src/linetypes/polygonobject.h Tue Sep 21 16:00:15 2021 +0300 +++ b/src/linetypes/polygonobject.h Wed Sep 22 00:25:13 2021 +0300 @@ -68,6 +68,7 @@ } QDataStream &serialize(QDataStream& stream) const override { + ColoredObject::serialize(stream); for (const glm::vec3& point : this->points) { stream << point; @@ -76,12 +77,12 @@ } QDataStream& deserialize(QDataStream& stream) override { + ColoredObject::deserialize(stream); for (glm::vec3& point : this->points) { stream >> point; } return stream; } -protected: std::array points; }; diff -r 488d0ba6070b -r f77d2230e87c src/linetypes/subfilereference.cpp --- a/src/linetypes/subfilereference.cpp Tue Sep 21 16:00:15 2021 +0300 +++ b/src/linetypes/subfilereference.cpp Wed Sep 22 00:25:13 2021 +0300 @@ -95,10 +95,10 @@ QDataStream& ldraw::SubfileReference::serialize(QDataStream &stream) const { - return stream << this->transformation << this->referenceName << this->isInverted; + return ColoredObject::serialize(stream) << this->transformation << this->referenceName << this->isInverted; } QDataStream& ldraw::SubfileReference::deserialize(QDataStream &stream) { - return stream >> this->transformation >> this->referenceName >> this->isInverted; + return ColoredObject::deserialize(stream) >> this->transformation >> this->referenceName >> this->isInverted; } diff -r 488d0ba6070b -r f77d2230e87c src/main.h --- a/src/main.h Tue Sep 21 16:00:15 2021 +0300 +++ b/src/main.h Wed Sep 22 00:25:13 2021 +0300 @@ -242,7 +242,7 @@ QDataStream& operator<<(QDataStream&, const glm::vec3&); QDataStream& operator>>(QDataStream&, glm::vec3&); -template +template QDataStream& operator<<(QDataStream& stream, const glm::mat& mat) { iter_matrix(mat, [&stream](int, int, float x) @@ -252,7 +252,7 @@ return stream; } -template +template QDataStream& operator>>(QDataStream& stream, glm::mat& mat) { iter_matrix(mat, [&stream](int, int, float x)