Add remaining serialize methods

Wed, 22 Sep 2021 00:25:13 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Wed, 22 Sep 2021 00:25:13 +0300
changeset 134
f77d2230e87c
parent 132
488d0ba6070b
child 135
d384df40c8e7

Add remaining serialize methods

src/linetypes/comment.cpp file | annotate | diff | comparison | revisions
src/linetypes/errorline.cpp file | annotate | diff | comparison | revisions
src/linetypes/errorline.h file | annotate | diff | comparison | revisions
src/linetypes/metacommand.cpp file | annotate | diff | comparison | revisions
src/linetypes/metacommand.h file | annotate | diff | comparison | revisions
src/linetypes/object.cpp file | annotate | diff | comparison | revisions
src/linetypes/polygonobject.h file | annotate | diff | comparison | revisions
src/linetypes/subfilereference.cpp file | annotate | diff | comparison | revisions
src/main.h file | annotate | diff | comparison | revisions
--- 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;
 }
+
--- 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;
+}
--- 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:
--- 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;
+}
+
--- 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;
 };
--- 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
--- 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<glm::vec3, N> points;
 };
--- 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;
 }
--- 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<int X, int Y, typename T, glm::qualifier Q, typename Fn>
+template<int X, int Y, typename T, glm::qualifier Q>
 QDataStream& operator<<(QDataStream& stream, const glm::mat<X, Y, T, Q>& mat)
 {
 	iter_matrix(mat, [&stream](int, int, float x)
@@ -252,7 +252,7 @@
 	return stream;
 }
 
-template<int X, int Y, typename T, glm::qualifier Q, typename Fn>
+template<int X, int Y, typename T, glm::qualifier Q>
 QDataStream& operator>>(QDataStream& stream, glm::mat<X, Y, T, Q>& mat)
 {
 	iter_matrix(mat, [&stream](int, int, float x)

mercurial