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