Skip to content

Commit

Permalink
PINK: add StringMap serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
voltya authored and sev- committed Jun 28, 2018
1 parent ed3f9dc commit 147904f
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions engines/pink/utils.h
Expand Up @@ -30,7 +30,7 @@ namespace Pink {
template <typename T>
class Array : public Common::Array<T>, public Object {
public:
virtual void deserialize(Archive &archive) {
void deserialize(Archive &archive) {
uint size = archive.readCount();
this->resize(size);
for (uint i = 0; i < size; ++i) {
Expand All @@ -41,7 +41,7 @@ class Array : public Common::Array<T>, public Object {

class StringArray : public Common::StringArray {
public:
inline void deserialize(Archive &archive) {
void deserialize(Archive &archive) {
uint32 size = archive.readCount();
this->resize(size);
for (uint i = 0; i < size; ++i) {
Expand All @@ -50,6 +50,26 @@ class StringArray : public Common::StringArray {
}
};

class StringMap : public Common::StringMap {
public:
void serialize(Archive &archive) {
archive.writeWORD(size());
for (Common::StringMap::const_iterator it = begin(); it != end(); ++it) {
archive.writeString(it->_key);
archive.writeString(it->_value);
}
}

void deserialize(Archive &archive) {
uint size = archive.readWORD();
for (uint i = 0; i < size; ++i) {
Common::String key = archive.readString();
Common::String val = archive.readString();
setVal(key, val);
}
}
};

} // End of namespace Pink

#endif

0 comments on commit 147904f

Please sign in to comment.