]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
include/encoding: map<> encoders when comparator is specified
authorSage Weil <sage@redhat.com>
Wed, 22 Jul 2015 14:35:41 +0000 (10:35 -0400)
committerSage Weil <sage@redhat.com>
Fri, 7 Aug 2015 14:16:03 +0000 (10:16 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
src/include/encoding.h

index aaa843b544da691b6635faef0981c2aca351ff3e..1abdcf194d2334174d73c466cc0e74c5fdeae757 100644 (file)
@@ -611,6 +611,16 @@ inline void encode(const std::map<T,U>& m, bufferlist& bl)
     encode(p->second, bl);
   }
 }
+template<class T, class U, class C>
+inline void encode(const std::map<T,U,C>& m, bufferlist& bl)
+{
+  __u32 n = (__u32)(m.size());
+  encode(n, bl);
+  for (typename std::map<T,U,C>::const_iterator p = m.begin(); p != m.end(); ++p) {
+    encode(p->first, bl);
+    encode(p->second, bl);
+  }
+}
 template<class T, class U>
 inline void encode(const std::map<T,U>& m, bufferlist& bl, uint64_t features)
 {
@@ -633,6 +643,18 @@ inline void decode(std::map<T,U>& m, bufferlist::iterator& p)
     decode(m[k], p);
   }
 }
+template<class T, class U, class C>
+inline void decode(std::map<T,U,C>& m, bufferlist::iterator& p)
+{
+  __u32 n;
+  decode(n, p);
+  m.clear();
+  while (n--) {
+    T k;
+    decode(k, p);
+    decode(m[k], p);
+  }
+}
 template<class T, class U>
 inline void decode_noclear(std::map<T,U>& m, bufferlist::iterator& p)
 {