Added new Reply class.

This commit is contained in:
Nathan Osman 2013-08-01 15:26:26 -07:00
parent 5345c07c9f
commit d42dc66f4e
1 changed files with 85 additions and 0 deletions

85
include/qredis/reply.h Normal file
View File

@ -0,0 +1,85 @@
#ifndef QREDIS_REPLY_H
#define QREDIS_REPLY_H
#include <QVariant>
#include "qredis_export.h"
namespace QRedis
{
/**
* @brief Represents a Redis reply
*/
class QREDIS_EXPORT Reply
{
public:
/**
* @brief Reply types
*/
enum Type {
/**
* @brief A status reply
*
* The value property will contain the status message returned
* by the server as a QString.
*/
Status,
/**
* @brief An error reply
*
* The value property will contain the error message returned by
* the server as a QString.
*/
Error,
/**
* @brief An integer reply
*
* The value property will contain the integer value returned by
* the server as a qlonglong.
*/
Integer,
/**
* @brief A bulk reply
*
* The value property will contain the bulk reply returned by
* the server as a QByteArray.
*/
Bulk,
/**
* @brief A multi-bulk reply
*
* The value property will contain the multi-bulk reply returned
* by the server as a QVariantList. Each entry in the list is of
* type Reply.
*/
MultiBulk
};
/**
* @brief Initializes the reply
* @param type the type of the reply
* @param value the value of the reply
*/
Reply(Type type, QVariant & value) : _type(type), _value(value) {}
/**
* @brief Returns the type of the reply
* @return the reply type
*/
Type type() const { return _type; }
/**
* @brief Returns the value of the reply
* @return the reply value
*/
QVariant & value() const { return _value; }
private:
Type _type;
QVariant _value;
};
}
#endif // QREDIS_REPLY_H