From: Sage Weil Date: Wed, 22 Jul 2015 14:35:41 +0000 (-0400) Subject: include/encoding: map<> encoders when comparator is specified X-Git-Tag: v9.1.0~346^2~42 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=29e140d8155d64af664eb85e2c4b82da6702e966;p=ceph.git include/encoding: map<> encoders when comparator is specified Signed-off-by: Sage Weil --- diff --git a/src/include/encoding.h b/src/include/encoding.h index aaa843b544da..1abdcf194d23 100644 --- a/src/include/encoding.h +++ b/src/include/encoding.h @@ -611,6 +611,16 @@ inline void encode(const std::map& m, bufferlist& bl) encode(p->second, bl); } } +template +inline void encode(const std::map& m, bufferlist& bl) +{ + __u32 n = (__u32)(m.size()); + encode(n, bl); + for (typename std::map::const_iterator p = m.begin(); p != m.end(); ++p) { + encode(p->first, bl); + encode(p->second, bl); + } +} template inline void encode(const std::map& m, bufferlist& bl, uint64_t features) { @@ -633,6 +643,18 @@ inline void decode(std::map& m, bufferlist::iterator& p) decode(m[k], p); } } +template +inline void decode(std::map& m, bufferlist::iterator& p) +{ + __u32 n; + decode(n, p); + m.clear(); + while (n--) { + T k; + decode(k, p); + decode(m[k], p); + } +} template inline void decode_noclear(std::map& m, bufferlist::iterator& p) {