Add map type to serializer 37/215737/1
authorSangwan Kwon <sangwan.kwon@samsung.com>
Tue, 15 Oct 2019 06:49:23 +0000 (15:49 +0900)
committerSangwan Kwon <sangwan.kwon@samsung.com>
Tue, 15 Oct 2019 06:49:23 +0000 (15:49 +0900)
Change-Id: I46466b05f5409980a959f5c2a094c14ee2de9030
Signed-off-by: Sangwan Kwon <sangwan.kwon@samsung.com>
include/klay/serialize.h

index 90b54910103de0f1b1db4b66f15b036ac38c2cb0..c1467f63878968378f234764a7834134a6d3dfc5 100644 (file)
 #ifndef __RUNTIME_SERIALIZER_H__
 #define __RUNTIME_SERIALIZER_H__
 
-#include <vector>
+#include <map>
 #include <string>
 #include <utility>
+#include <vector>
 
 #include <klay/klay.h>
 #include <klay/reflection.h>
@@ -90,6 +91,16 @@ private:
                }
        }
 
+       template<typename KeyType, typename ValueType>
+       void visitInternal(const std::map<KeyType, ValueType>& map)
+       {
+               visitInternal(map.size());
+               for (const auto& pair : map) {
+                       visitInternal(pair.first);
+                       visitInternal(pair.second);
+               }
+       }
+
 private:
        StorageType& storage;
 };
@@ -141,6 +152,23 @@ private:
                }
        }
 
+       template<typename KeyType, typename ValueType>
+       void visitInternal(std::map<KeyType, ValueType>& map)
+       {
+               size_t size;
+               visitInternal(size);
+
+               while (size--) {
+                       KeyType key;
+                       ValueType value;
+
+                       visitInternal(key);
+                       visitInternal(value);
+
+                       map[key] = value;
+               }
+       }
+
 private:
        StorageType& storage;
 };