--- a/src/linetypes/object.cpp Fri Sep 17 22:43:22 2021 +0300 +++ b/src/linetypes/object.cpp Tue Sep 21 16:00:15 2021 +0300 @@ -74,6 +74,27 @@ throw BadPointIndex{}; } +/** + * @brief Serializes the object into a stream of bytes for internal storage. + * @param stream Data stream to serialize into + */ +QDataStream& ldraw::Object::serialize(QDataStream &stream) const +{ + return stream << static_cast<int>(this->typeIdentifier()); +} + +/** + * @brief Deserializes the object from a stream of bytes coming from internal storage. + * @param stream Data stream to serialize from. + * @note @c ldraw::Object::serialize will insert a type enumerator. Before calling this function, + * this enumerator is assumed to have been handled as the object class needs to be initialized based + * on the value of this enumerator. + */ +QDataStream& ldraw::Object::deserialize(QDataStream &stream) +{ + return stream; +} + ldraw::ColoredObject::ColoredObject(const Color color_index) : colorIndex{color_index} { @@ -101,7 +122,32 @@ Object::setProperty(result, pair); } +/** + * @brief @overload @c ldraw::Object::serialize + * @param stream + * @return stream + */ +QDataStream& ldraw::ColoredObject::serialize(QDataStream& stream) const +{ + return Object::serialize(stream) << this->colorIndex; +} + +/** + * @brief @overload @c ldraw::Object::deserialize + * @param stream + * @return stream + */ +QDataStream& ldraw::ColoredObject::deserialize(QDataStream& stream) +{ + return Object::serialize(stream) >> this->colorIndex; +} + QString ldraw::Empty::textRepresentation() const { return ""; } + +ldraw::Object::Type ldraw::Empty::typeIdentifier() const +{ + return Type::Empty; +}