diff options
Diffstat (limited to 'src/serializer.cpp')
-rw-r--r-- | src/serializer.cpp | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/src/serializer.cpp b/src/serializer.cpp index 5982a26..d41cc64 100644 --- a/src/serializer.cpp +++ b/src/serializer.cpp | |||
@@ -1,5 +1,6 @@ | |||
1 | #include "serializer.h" | 1 | #include "serializer.h" |
2 | #include "serializable.h" | 2 | #include "serializable.h" |
3 | #include <list> | ||
3 | 4 | ||
4 | Serializer::Serializer(bool bLoading): | 5 | Serializer::Serializer(bool bLoading): |
5 | bLoading(bLoading) | 6 | bLoading(bLoading) |
@@ -159,16 +160,16 @@ Serializer::Serializer &operator&(long double &p) | |||
159 | }*/ | 160 | }*/ |
160 | 161 | ||
161 | 162 | ||
162 | Serializer &Serializer::operator<<(Serializable &p) | 163 | Serializer &operator<<(Serializer &s, Serializable &p) |
163 | { | 164 | { |
164 | p.serialize(*this); | 165 | p.serialize( s ); |
165 | return *this; | 166 | return s; |
166 | } | 167 | } |
167 | 168 | ||
168 | Serializer &Serializer::operator>>(Serializable &p) | 169 | Serializer &operator>>(Serializer &s, Serializable &p) |
169 | { | 170 | { |
170 | p.serialize(*this); | 171 | p.serialize( s ); |
171 | return *this; | 172 | return s; |
172 | } | 173 | } |
173 | 174 | ||
174 | /*Serializer::Serializer &operator&(Serializable &p) | 175 | /*Serializer::Serializer &operator&(Serializable &p) |
@@ -183,3 +184,20 @@ Serializer &Serializer::operator>>(Serializable &p) | |||
183 | } | 184 | } |
184 | }*/ | 185 | }*/ |
185 | 186 | ||
187 | Serializer &operator<<( Serializer &ar, std::string &s ) | ||
188 | { | ||
189 | ar << s.length(); | ||
190 | ar.write( s.c_str(), s.length() ); | ||
191 | } | ||
192 | |||
193 | Serializer &operator>>( Serializer &ar, std::string &s ) | ||
194 | { | ||
195 | int l; | ||
196 | ar >> l; | ||
197 | char *tmp = new char[l+1]; | ||
198 | tmp[l] = '\0'; | ||
199 | ar.read( tmp, l ); | ||
200 | s = tmp; | ||
201 | delete tmp; | ||
202 | } | ||
203 | |||