]> git.proxmox.com Git - ceph.git/blob - ceph/src/include/btree_map.h
update sources to v12.2.5
[ceph.git] / ceph / src / include / btree_map.h
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_BTREE_MAP_H
5 #define CEPH_INCLUDE_BTREE_MAP_H
6
7 #include "include/cpp-btree/btree.h"
8 #include "include/cpp-btree/btree_map.h"
9 #include "include/assert.h" // cpp-btree uses system assert, blech
10 #include "include/encoding.h"
11
12 template<class T, class U>
13 inline void encode(const btree::btree_map<T,U>& m, bufferlist& bl)
14 {
15 __u32 n = (__u32)(m.size());
16 encode(n, bl);
17 for (typename btree::btree_map<T,U>::const_iterator p = m.begin(); p != m.end(); ++p) {
18 encode(p->first, bl);
19 encode(p->second, bl);
20 }
21 }
22 template<class T, class U>
23 inline void encode(const btree::btree_map<T,U>& m, bufferlist& bl, uint64_t features)
24 {
25 __u32 n = (__u32)(m.size());
26 encode(n, bl);
27 for (typename btree::btree_map<T,U>::const_iterator p = m.begin(); p != m.end(); ++p) {
28 encode(p->first, bl, features);
29 encode(p->second, bl, features);
30 }
31 }
32 template<class T, class U>
33 inline void decode(btree::btree_map<T,U>& m, bufferlist::iterator& p)
34 {
35 __u32 n;
36 decode(n, p);
37 m.clear();
38 while (n--) {
39 T k;
40 decode(k, p);
41 decode(m[k], p);
42 }
43 }
44 template<class T, class U>
45 inline void encode_nohead(const btree::btree_map<T,U>& m, bufferlist& bl)
46 {
47 for (typename btree::btree_map<T,U>::const_iterator p = m.begin(); p != m.end(); ++p) {
48 encode(p->first, bl);
49 encode(p->second, bl);
50 }
51 }
52 template<class T, class U>
53 inline void decode_nohead(int n, btree::btree_map<T,U>& m, bufferlist::iterator& p)
54 {
55 m.clear();
56 while (n--) {
57 T k;
58 decode(k, p);
59 decode(m[k], p);
60 }
61 }
62
63 #endif