From 147904f53a99a974eacadfec94efc8f7e7b6a3b9 Mon Sep 17 00:00:00 2001 From: whiterandrek Date: Fri, 25 May 2018 17:41:45 +0300 Subject: PINK: add StringMap serialization --- engines/pink/utils.h | 24 ++++++++++++++++++++++-- 1 file 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 class Array : public Common::Array, 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 -- cgit v1.2.3