From: Sage Weil Date: Wed, 30 Dec 2015 20:04:28 +0000 (-0500) Subject: include/encoding: featureful encoder for list of shared_ptrs X-Git-Tag: v10.1.0~241^2~24 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7b961ff1295c95f549103a442018b896eb45374a;p=ceph.git include/encoding: featureful encoder for list of shared_ptrs Signed-off-by: Sage Weil --- diff --git a/src/include/encoding.h b/src/include/encoding.h index a5a93a0996b7..7de74544b2cc 100644 --- a/src/include/encoding.h +++ b/src/include/encoding.h @@ -423,6 +423,28 @@ inline void encode(const std::list >& ls, bufferlist& bl) } } template +inline void encode(const std::list >& ls, bufferlist& bl, uint64_t features) +{ + // should i pre- or post- count? + if (!ls.empty()) { + unsigned pos = bl.length(); + unsigned n = 0; + encode(n, bl); + for (typename std::list >::const_iterator p = ls.begin(); p != ls.end(); ++p) { + n++; + encode(**p, bl, features); + } + ceph_le32 en; + en = n; + bl.copy_in(pos, sizeof(en), (char*)&en); + } else { + __u32 n = (__u32)(ls.size()); // FIXME: this is slow on a list. + encode(n, bl); + for (typename std::list >::const_iterator p = ls.begin(); p != ls.end(); ++p) + encode(**p, bl, features); + } +} +template inline void decode(std::list >& ls, bufferlist::iterator& p) { __u32 n;