]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
include/encoding: handle set<> with comparator
authorSage Weil <sage@redhat.com>
Wed, 22 Jul 2015 15:33:19 +0000 (11:33 -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 1abdcf194d2334174d73c466cc0e74c5fdeae757..a4b5d03d33e3fb53a6ea6b08f99aaa7e668a6ec9 100644 (file)
@@ -453,6 +453,27 @@ inline void decode(std::set<T>& s, bufferlist::iterator& p)
   }
 }
 
+template<class T, class C>
+inline void encode(const std::set<T, C>& s, bufferlist& bl)
+{
+  __u32 n = (__u32)(s.size());
+  encode(n, bl);
+  for (typename std::set<T, C>::const_iterator p = s.begin(); p != s.end(); ++p)
+    encode(*p, bl);
+}
+template<class T, class C>
+inline void decode(std::set<T, C>& s, bufferlist::iterator& p)
+{
+  __u32 n;
+  decode(n, p);
+  s.clear();
+  while (n--) {
+    T v;
+    decode(v, p);
+    s.insert(v);
+  }
+}
+
 template<class T>
 inline void encode_nohead(const std::set<T>& s, bufferlist& bl)
 {