]> git.proxmox.com Git - ceph.git/blob - ceph/src/tools/ceph-dencoder/str.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / tools / ceph-dencoder / str.h
1 #ifndef TEST_STRING_H
2 #define TEST_STRING_H
3
4 #include "common/Formatter.h"
5
6 // wrapper for std::string that implements the dencoder interface
7 class string_wrapper {
8 std::string s;
9 public:
10 string_wrapper() = default;
11 string_wrapper(string s1)
12 : s(s1)
13 {}
14
15 void encode(ceph::buffer::list& bl) const {
16 using ceph::encode;
17 encode(s, bl);
18 }
19
20 void decode(ceph::buffer::list::const_iterator &bl) {
21 using ceph::decode;
22 decode(s, bl);
23 }
24
25 void dump(Formatter* f) {
26 f->dump_string("s", s);
27 }
28
29 static void generate_test_instances(std::list<string_wrapper*>& ls) {
30 ls.push_back(new string_wrapper());
31 // initialize strings that fit in internal storage
32 std::string s1 = "abcdef";
33 ls.push_back(new string_wrapper(s1));
34 }
35 };
36 WRITE_CLASS_ENCODER(string_wrapper)
37
38 #endif