From: Sage Weil Date: Wed, 22 Jul 2015 15:33:19 +0000 (-0400) Subject: include/encoding: handle set<> with comparator X-Git-Tag: v9.1.0~346^2~39 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a33895e05a002d9d03e65172097b3b4dfc311061;p=ceph.git include/encoding: handle set<> with comparator Signed-off-by: Sage Weil --- diff --git a/src/include/encoding.h b/src/include/encoding.h index 1abdcf194d2..a4b5d03d33e 100644 --- a/src/include/encoding.h +++ b/src/include/encoding.h @@ -453,6 +453,27 @@ inline void decode(std::set& s, bufferlist::iterator& p) } } +template +inline void encode(const std::set& s, bufferlist& bl) +{ + __u32 n = (__u32)(s.size()); + encode(n, bl); + for (typename std::set::const_iterator p = s.begin(); p != s.end(); ++p) + encode(*p, bl); +} +template +inline void decode(std::set& s, bufferlist::iterator& p) +{ + __u32 n; + decode(n, p); + s.clear(); + while (n--) { + T v; + decode(v, p); + s.insert(v); + } +} + template inline void encode_nohead(const std::set& s, bufferlist& bl) {