72 { |
72 { |
73 Q_UNUSED(index); |
73 Q_UNUSED(index); |
74 throw BadPointIndex{}; |
74 throw BadPointIndex{}; |
75 } |
75 } |
76 |
76 |
|
77 /** |
|
78 * @brief Serializes the object into a stream of bytes for internal storage. |
|
79 * @param stream Data stream to serialize into |
|
80 */ |
|
81 QDataStream& ldraw::Object::serialize(QDataStream &stream) const |
|
82 { |
|
83 return stream << static_cast<int>(this->typeIdentifier()); |
|
84 } |
|
85 |
|
86 /** |
|
87 * @brief Deserializes the object from a stream of bytes coming from internal storage. |
|
88 * @param stream Data stream to serialize from. |
|
89 * @note @c ldraw::Object::serialize will insert a type enumerator. Before calling this function, |
|
90 * this enumerator is assumed to have been handled as the object class needs to be initialized based |
|
91 * on the value of this enumerator. |
|
92 */ |
|
93 QDataStream& ldraw::Object::deserialize(QDataStream &stream) |
|
94 { |
|
95 return stream; |
|
96 } |
|
97 |
77 ldraw::ColoredObject::ColoredObject(const Color color_index) : |
98 ldraw::ColoredObject::ColoredObject(const Color color_index) : |
78 colorIndex{color_index} |
99 colorIndex{color_index} |
79 { |
100 { |
80 } |
101 } |
81 |
102 |
99 { |
120 { |
100 LDRAW_OBJECT_HANDLE_SET_PROPERTY(Color, {colorIndex = value;}); |
121 LDRAW_OBJECT_HANDLE_SET_PROPERTY(Color, {colorIndex = value;}); |
101 Object::setProperty(result, pair); |
122 Object::setProperty(result, pair); |
102 } |
123 } |
103 |
124 |
|
125 /** |
|
126 * @brief @overload @c ldraw::Object::serialize |
|
127 * @param stream |
|
128 * @return stream |
|
129 */ |
|
130 QDataStream& ldraw::ColoredObject::serialize(QDataStream& stream) const |
|
131 { |
|
132 return Object::serialize(stream) << this->colorIndex; |
|
133 } |
|
134 |
|
135 /** |
|
136 * @brief @overload @c ldraw::Object::deserialize |
|
137 * @param stream |
|
138 * @return stream |
|
139 */ |
|
140 QDataStream& ldraw::ColoredObject::deserialize(QDataStream& stream) |
|
141 { |
|
142 return Object::serialize(stream) >> this->colorIndex; |
|
143 } |
|
144 |
104 QString ldraw::Empty::textRepresentation() const |
145 QString ldraw::Empty::textRepresentation() const |
105 { |
146 { |
106 return ""; |
147 return ""; |
107 } |
148 } |
|
149 |
|
150 ldraw::Object::Type ldraw::Empty::typeIdentifier() const |
|
151 { |
|
152 return Type::Empty; |
|
153 } |