cpp_redis  4.0.0
cpp_redis is a C++11 Asynchronous Multi-Platform Lightweight Redis Client, with support for synchronous operations and pipelining.
Public Types | Public Member Functions | List of all members
cpp_redis::reply Class Reference

#include <reply.hpp>

Public Types

enum  type {
  error = __CPP_REDIS_REPLY_ERR, bulk_string = __CPP_REDIS_REPLY_BULK, simple_string = __CPP_REDIS_REPLY_SIMPLE, null = __CPP_REDIS_REPLY_NULL,
  integer = __CPP_REDIS_REPLY_INT, array = __CPP_REDIS_REPLY_ARRAY
}
 
enum  string_type { error = __CPP_REDIS_REPLY_ERR, bulk_string = __CPP_REDIS_REPLY_BULK, simple_string = __CPP_REDIS_REPLY_SIMPLE }
 

Public Member Functions

 reply (void)
 
 reply (const std::string &value, string_type reply_type)
 
 reply (int64_t value)
 
 reply (const std::vector< reply > &rows)
 
 ~reply (void)=default
 dtor
 
 reply (const reply &)=default
 copy ctor
 
replyoperator= (const reply &)=default
 assignment operator
 
bool is_array (void) const
 
bool is_string (void) const
 
bool is_simple_string (void) const
 
bool is_bulk_string (void) const
 
bool is_error (void) const
 
bool is_integer (void) const
 
bool is_null (void) const
 
bool ok (void) const
 
bool ko (void) const
 
 operator bool (void) const
 
const std::string & error (void) const
 
const std::vector< reply > & as_array (void) const
 
const std::string & as_string (void) const
 
int64_t as_integer (void) const
 
void set (void)
 
void set (const std::string &value, string_type reply_type)
 
void set (int64_t value)
 
void set (const std::vector< reply > &rows)
 
replyoperator<< (const reply &reply)
 
type get_type (void) const
 

Detailed Description

cpp_redis::reply is the class that wraps Redis server replies. That is, cpp_redis::reply objects are passed as parameters of commands callbacks and contain the server's response.

Member Enumeration Documentation

◆ string_type

specific type of replies for string-based replies

◆ type

type of reply, baed on redis server standard replies

Constructor & Destructor Documentation

◆ reply() [1/4]

cpp_redis::reply::reply ( void  )

default ctor (set a null reply)

◆ reply() [2/4]

cpp_redis::reply::reply ( const std::string &  value,
string_type  reply_type 
)

ctor for string values

Parameters
valuestring value
reply_typeof string reply

◆ reply() [3/4]

cpp_redis::reply::reply ( int64_t  value)

ctor for int values

Parameters
valueinteger value

◆ reply() [4/4]

cpp_redis::reply::reply ( const std::vector< reply > &  rows)

ctor for array values

Parameters
rowsarray reply
Returns
current instance

Member Function Documentation

◆ as_array()

const std::vector<reply>& cpp_redis::reply::as_array ( void  ) const
Returns
the underlying array

◆ as_integer()

int64_t cpp_redis::reply::as_integer ( void  ) const
Returns
the underlying integer

◆ as_string()

const std::string& cpp_redis::reply::as_string ( void  ) const
Returns
the underlying string

◆ error()

const std::string& cpp_redis::reply::error ( void  ) const
Returns
the underlying error

◆ get_type()

type cpp_redis::reply::get_type ( void  ) const
Returns
reply type

◆ is_array()

bool cpp_redis::reply::is_array ( void  ) const
Returns
whether the reply is an array

◆ is_bulk_string()

bool cpp_redis::reply::is_bulk_string ( void  ) const
Returns
whether the reply is a bulk string

◆ is_error()

bool cpp_redis::reply::is_error ( void  ) const
Returns
whether the reply is an error

◆ is_integer()

bool cpp_redis::reply::is_integer ( void  ) const
Returns
whether the reply is an integer

◆ is_null()

bool cpp_redis::reply::is_null ( void  ) const
Returns
whether the reply is null

◆ is_simple_string()

bool cpp_redis::reply::is_simple_string ( void  ) const
Returns
whether the reply is a simple string

◆ is_string()

bool cpp_redis::reply::is_string ( void  ) const
Returns
whether the reply is a string (simple, bulk, error)

◆ ko()

bool cpp_redis::reply::ko ( void  ) const
Returns
true if function is an error

◆ ok()

bool cpp_redis::reply::ok ( void  ) const
Returns
true if function is not an error

◆ operator bool()

cpp_redis::reply::operator bool ( void  ) const

convenience implicit conversion, same as !is_null() / ok()

◆ operator<<()

reply& cpp_redis::reply::operator<< ( const reply reply)

for array replies, add a new row to the reply

Parameters
replynew row to be appended
Returns
current instance

◆ set() [1/4]

void cpp_redis::reply::set ( void  )

set reply as null

◆ set() [2/4]

void cpp_redis::reply::set ( const std::string &  value,
string_type  reply_type 
)

set a string reply

Parameters
valuestring value
reply_typeof string reply

◆ set() [3/4]

void cpp_redis::reply::set ( int64_t  value)

set an integer reply

Parameters
valueinteger value

◆ set() [4/4]

void cpp_redis::reply::set ( const std::vector< reply > &  rows)

set an array reply

Parameters
rowsarray reply

The documentation for this class was generated from the following file: