]> git.proxmox.com Git - ceph.git/blame - ceph/src/include/encoding_btree.h
update sources to v12.1.1
[ceph.git] / ceph / src / include / encoding_btree.h
CommitLineData
7c673cae
FG
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3
4#ifndef CEPH_INCLUDE_ENCODING_BTREE_H
5#define CEPH_INCLUDE_ENCODING_BTREE_H
6
7#include "include/cpp-btree/btree_map.h"
8
9template<class T, class U>
10inline void encode(const btree::btree_map<T,U>& m, bufferlist& bl)
11{
12 __u32 n = (__u32)(m.size());
13 encode(n, bl);
14 for (typename btree::btree_map<T,U>::const_iterator p = m.begin(); p != m.end(); ++p) {
15 encode(p->first, bl);
16 encode(p->second, bl);
17 }
18}
19template<class T, class U>
20inline void encode(const btree::btree_map<T,U>& m, bufferlist& bl, uint64_t features)
21{
22 __u32 n = (__u32)(m.size());
23 encode(n, bl);
24 for (typename btree::btree_map<T,U>::const_iterator p = m.begin(); p != m.end(); ++p) {
25 encode(p->first, bl, features);
26 encode(p->second, bl, features);
27 }
28}
29template<class T, class U>
30inline void decode(btree::btree_map<T,U>& m, bufferlist::iterator& p)
31{
32 __u32 n;
33 decode(n, p);
34 m.clear();
35 while (n--) {
36 T k;
37 decode(k, p);
38 decode(m[k], p);
39 }
40}
41template<class T, class U>
42inline void encode_nohead(const btree::btree_map<T,U>& m, bufferlist& bl)
43{
44 for (typename btree::btree_map<T,U>::const_iterator p = m.begin(); p != m.end(); ++p) {
45 encode(p->first, bl);
46 encode(p->second, bl);
47 }
48}
49template<class T, class U>
50inline void decode_nohead(int n, btree::btree_map<T,U>& m, bufferlist::iterator& p)
51{
52 m.clear();
53 while (n--) {
54 T k;
55 decode(k, p);
56 decode(m[k], p);
57 }
58}
59
60#endif