redis3m  1.0.0
 All Classes Functions Variables Enumerations Pages
reply.h
1 // Copyright (c) 2014 Luca Marturana. All rights reserved.
2 // Licensed under Apache 2.0, see LICENSE for details
3 
4 #pragma once
5 
6 #include <string>
7 #include <redis3m/utils/exception.h>
8 #include <vector>
9 
10 struct redisReply;
11 
12 namespace redis3m {
13 
14  class connection;
18  class reply
19  {
20  public:
24  enum type_t
25  {
26  STRING = 1,
27  ARRAY = 2,
28  INTEGER = 3,
29  NIL = 4,
30  STATUS = 5,
31  ERROR = 6
32  };
33 
38  inline type_t type() const { return _type; }
43  inline const std::string& str() const { return _str; }
48  inline long long integer() const { return _integer; }
53  inline const std::vector<reply>& elements() const { return _elements; }
54 
55  private:
56  reply(redisReply *reply);
57 
58  type_t _type;
59  std::string _str;
60  long long _integer;
61  std::vector<reply> _elements;
62 
63  friend class connection;
64  };
65 }
const std::string & str() const
Returns string value if present, otherwise an empty string.
Definition: reply.h:43
type_t
Define reply type.
Definition: reply.h:24
long long integer() const
Returns integer value if present, otherwise 0.
Definition: reply.h:48
The connection class, represent a connection to a Redis server.
Definition: connection.h:27
type_t type() const
Type of reply, other field values are dependent of this.
Definition: reply.h:38
const std::vector< reply > & elements() const
Returns a vector of sub-replies if present, otherwise an empty one.
Definition: reply.h:53
Represent a reply received from redis server.
Definition: reply.h:18