Add more comments

This commit is contained in:
fbraem 2015-11-19 22:12:57 +01:00
parent e973bb4faf
commit 80b7804a98
4 changed files with 63 additions and 12 deletions

View File

@ -54,13 +54,22 @@ class Redis_API Client
/// To create Redis commands, the factory methods of the Command class can
/// be used or the Array class can be used directly.
///
/// Command llen = Command::llen("list");
/// Command llen = Command::llen("list");
///
/// is the same as
///
/// Array command;
/// command.add("LLEN").add("list");
/// Array command;
/// command.add("LLEN").add("list");
///
/// or
///
/// Array command;
/// command << "LLEN" << "list";
///
/// or even
///
/// Command command("LLEN");
/// command << "list";
{
public:
Client();
@ -110,9 +119,11 @@ public:
T execute(const Array& command)
/// Sends the Redis Command to the server. It gets the reply
/// and tries to convert it to the given template type.
///
/// A specialization exists for type void, which doesn't read
/// the reply. If the server sends a reply, it is your
/// responsibility to read it ... (Use this for pipelining)
///
/// A BadCastException will be thrown when the reply couldn't be
/// converted. Supported types are Int64, std::string, BulkString,
/// Array and void. When the reply is an Error, it will throw
@ -162,6 +173,7 @@ public:
/// getting all replies.
void setReceiveTimeout(const Timespan& timeout);
/// Sets a receive timeout.
private:
@ -173,6 +185,7 @@ private:
void connect();
/// Connects to the Redis server
void connect(const Timespan& timeout);
/// Connects to the Redis server and sets a timeout.

View File

@ -24,16 +24,24 @@ namespace Poco {
namespace Redis {
class Redis_API Error
/// Represent a Redis error
{
public:
Error();
/// Constructor
Error(const std::string& message);
/// Constructor
virtual ~Error();
/// Destructor
std::string getMessage() const;
/// Returns the error message
void setMessage(const std::string& message);
/// Sets the error message
private:

View File

@ -28,15 +28,21 @@ namespace Poco {
namespace Redis {
class RedisStreamBuf : public BufferedStreamBuf
/// BufferedStreamBuf for Redis
{
public:
RedisStreamBuf(Net::StreamSocket& redis);
/// Constructor
~RedisStreamBuf();
/// Destructor
std::string readLine();
/// Reads a line from Redis (until \r\n is encounterd).
protected:
int readFromDevice(char* buffer, std::streamsize length);
int writeToDevice(const char* buffer, std::streamsize length);
private:

View File

@ -32,37 +32,50 @@ namespace Redis {
class Redis_API RedisType
/// Base class for all Redis types. This class makes it possible to store
/// element with different types in Array.
{
public:
enum Types {
REDIS_INTEGER, // Redis Integer
REDIS_SIMPLE_STRING, // Redis Simple String
REDIS_BULK_STRING, // Redis Bulkstring
REDIS_ARRAY, // Redis Array
REDIS_ERROR // Redis Error
};
typedef SharedPtr<RedisType> Ptr;
RedisType();
/// Constructor
virtual ~RedisType();
/// Destructor
bool isArray() const;
/// Returns true when the value is a Redis array.
bool isBulkString() const;
/// Returns true when the value is a Redis bulkstring.
bool isError() const;
/// Returns true when the value is a Redis error.
bool isInteger() const;
/// Returns true when the value is a Redis integer (64 bit integer)
bool isSimpleString() const;
/// Returns true when the value is a simple string.
virtual int type() const = 0;
/// Returns the type of the value.
virtual void read(RedisInputStream& input) = 0;
/// Reads the value from the stream.
virtual std::string toString() const = 0;
enum Types {
REDIS_INTEGER,
REDIS_SIMPLE_STRING,
REDIS_BULK_STRING,
REDIS_ARRAY,
REDIS_ERROR
};
/// Converts the value to a RESP (REdis Serialization Protocol) string.
static RedisType::Ptr createRedisType(char marker);
/// Create a Redis type based on the marker :
@ -198,46 +211,57 @@ struct RedisTypeTraits<BulkString>
template<typename T>
class Type : public RedisType
/// Template class for all Redis types. This class will use
/// RedisTypeTraits structure for calling the type specific code.
{
public:
Type()
/// Constructor
{
}
Type(const T& t) : _value(t)
/// Constructor
{
}
Type(const Type& copy) : _value(copy._value)
/// Copy Constructor
{
}
virtual ~Type()
/// Destructor
{
}
int type() const
int type() const
/// Returns the type of the value
{
return RedisTypeTraits<T>::TypeId;
}
void read(RedisInputStream& socket)
/// Reads the value from the stream (RESP).
{
RedisTypeTraits<T>::read(socket, _value);
}
std::string toString() const
/// Converts the value to a string based on the RESP protocol.
{
return RedisTypeTraits<T>::toString(_value);
}
T& value()
/// Returns the value
{
return _value;
}
const T& value() const
/// Returns a const value
{
return _value;
}