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 | Private Attributes | List of all members
cpp_redis::reply Class Reference

#include <reply.hpp>

Public Types

enum  type {
  type::error = __CPP_REDIS_REPLY_ERR, type::bulk_string = __CPP_REDIS_REPLY_BULK, type::simple_string = __CPP_REDIS_REPLY_SIMPLE, type::null = __CPP_REDIS_REPLY_NULL,
  type::integer = __CPP_REDIS_REPLY_INT, type::array = __CPP_REDIS_REPLY_ARRAY
}
 
enum  string_type { string_type::error = __CPP_REDIS_REPLY_ERR, string_type::bulk_string = __CPP_REDIS_REPLY_BULK, string_type::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 More...
 
 reply (const reply &)=default
 copy ctor More...
 
replyoperator= (const reply &)=default
 assignment operator More...
 
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
 

Private Attributes

type m_type
 
std::vector< cpp_redis::replym_rows
 
std::string m_strval
 
int64_t m_intval
 

Member Enumeration Documentation

◆ string_type

specific type of replies for string-based replies

Enumerator
error 
bulk_string 
simple_string 

◆ type

type of reply, baed on redis server standard replies

Enumerator
error 
bulk_string 
simple_string 
null 
integer 
array 

Constructor & Destructor Documentation

◆ reply() [1/5]

cpp_redis::reply::reply ( void  )

default ctor (set a null reply)

◆ reply() [2/5]

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/5]

cpp_redis::reply::reply ( int64_t  value)

ctor for int values

Parameters
valueinteger value

◆ reply() [4/5]

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

ctor for array values

Parameters
rowsarray reply
Returns
current instance

◆ ~reply()

cpp_redis::reply::~reply ( void  )
default

dtor

◆ reply() [5/5]

cpp_redis::reply::reply ( const reply )
default

copy ctor

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

◆ operator=()

reply& cpp_redis::reply::operator= ( const reply )
default

assignment operator

◆ 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

Member Data Documentation

◆ m_intval

int64_t cpp_redis::reply::m_intval
private

◆ m_rows

std::vector<cpp_redis::reply> cpp_redis::reply::m_rows
private

◆ m_strval

std::string cpp_redis::reply::m_strval
private

◆ m_type

type cpp_redis::reply::m_type
private

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