diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
commit | 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch) | |
tree | e5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/include/btree_map.h | |
parent | Initial commit. (diff) | |
download | ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.zip |
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/include/btree_map.h')
-rw-r--r-- | src/include/btree_map.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/include/btree_map.h b/src/include/btree_map.h new file mode 100644 index 00000000..1f42ea41 --- /dev/null +++ b/src/include/btree_map.h @@ -0,0 +1,63 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#ifndef CEPH_INCLUDE_BTREE_MAP_H +#define CEPH_INCLUDE_BTREE_MAP_H + +#include "include/cpp-btree/btree.h" +#include "include/cpp-btree/btree_map.h" +#include "include/ceph_assert.h" // cpp-btree uses system assert, blech +#include "include/encoding.h" + +template<class T, class U> +inline void encode(const btree::btree_map<T,U>& m, bufferlist& bl) +{ + __u32 n = (__u32)(m.size()); + encode(n, bl); + for (typename btree::btree_map<T,U>::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 btree::btree_map<T,U>& m, bufferlist& bl, uint64_t features) +{ + __u32 n = (__u32)(m.size()); + encode(n, bl); + for (typename btree::btree_map<T,U>::const_iterator p = m.begin(); p != m.end(); ++p) { + encode(p->first, bl, features); + encode(p->second, bl, features); + } +} +template<class T, class U> +inline void decode(btree::btree_map<T,U>& m, bufferlist::const_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 encode_nohead(const btree::btree_map<T,U>& m, bufferlist& bl) +{ + for (typename btree::btree_map<T,U>::const_iterator p = m.begin(); p != m.end(); ++p) { + encode(p->first, bl); + encode(p->second, bl); + } +} +template<class T, class U> +inline void decode_nohead(int n, btree::btree_map<T,U>& m, bufferlist::const_iterator& p) +{ + m.clear(); + while (n--) { + T k; + decode(k, p); + decode(m[k], p); + } +} + +#endif |