-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcpp_redis_response.hpp
79 lines (66 loc) · 1.41 KB
/
cpp_redis_response.hpp
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef cpp_redis_response_h__
#define cpp_redis_response_h__
#include "cpp_define.h"
namespace cpp_redis {
class cpp_redis_response {
public:
cpp_redis_response() = default;
~cpp_redis_response() = default;
void reset()
{
err_.clear();
status_.clear();
results_.clear();
int_results_.clear();
result_code_ = status::unconnected_;
}
void set_result_code(int result_code)
{
result_code_ = result_code;
}
int get_result_code()const
{
return result_code_;
}
void set_error(std::string &&error)
{
err_ = std::move(error);
}
std::string get_error()
{
return std::move(err_);
}
void set_int_results(int value)
{
int_results_.emplace_back(value);
}
std::vector<int> get_int_results()
{
return std::move(int_results_);
}
void set_results(std::string &&value)
{
std::string copy_value = std::move(value);
results_.push_back(std::move(copy_value));
}
std::vector<std::string> get_results()
{
return std::move(results_);
}
void set_status(std::string&& status)
{
status_ = std::move(status);
}
std::string get_status()
{
return std::move(status_);
}
private:
int result_code_{status::unconnected_}; //-1: unconnected, 0: results_; 2: int ; 4: err_; 8: status_
std::string err_;
std::string status_;
std::vector<int> int_results_;
std::vector<std::string> results_;
};
}
#endif // cpp_redis_response_h__