diff options
author | whiterandrek | 2018-05-25 17:41:45 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2018-06-28 23:51:32 +0200 |
commit | 147904f53a99a974eacadfec94efc8f7e7b6a3b9 (patch) | |
tree | ab6dc4dbbd4de4713e695dccc249763549b04103 | |
parent | ed3f9dcaa849f52395466d3d2660476a3579c1cb (diff) | |
download | scummvm-rg350-147904f53a99a974eacadfec94efc8f7e7b6a3b9.tar.gz scummvm-rg350-147904f53a99a974eacadfec94efc8f7e7b6a3b9.tar.bz2 scummvm-rg350-147904f53a99a974eacadfec94efc8f7e7b6a3b9.zip |
PINK: add StringMap serialization
-rw-r--r-- | engines/pink/utils.h | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/engines/pink/utils.h b/engines/pink/utils.h index d5ef9a4c77..2a01ba9325 100644 --- a/engines/pink/utils.h +++ b/engines/pink/utils.h @@ -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) { @@ -41,7 +41,7 @@ public: 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) { @@ -50,6 +50,26 @@ public: } }; +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 |