mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-31 22:45:36 +01:00
Move createRedisType to Type
This commit is contained in:
parent
74b1ef2bb2
commit
723704ad16
@ -54,6 +54,14 @@ public:
|
||||
REDIS_ERROR
|
||||
};
|
||||
|
||||
static RedisType::Ptr createRedisType(char marker);
|
||||
/// Create a Redis type based on the marker :
|
||||
/// + : a simple string (std::string)
|
||||
/// - : an error (Error)
|
||||
/// $ : a bulk string (BulkString)
|
||||
/// * : an array (Array)
|
||||
/// : : a signed 64 bit integer (Int64)
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
@ -199,6 +207,7 @@ void Type<BulkString>::read(RedisSocket& socket)
|
||||
|
||||
socket.readLine(line);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -90,7 +90,7 @@ void Client::writeCommand(const Array& command)
|
||||
|
||||
RedisType::Ptr Client::readReply()
|
||||
{
|
||||
RedisType::Ptr result = createRedisType(_socket.get());
|
||||
RedisType::Ptr result = RedisType::createRedisType(_socket.get());
|
||||
if ( result.isNull() )
|
||||
{
|
||||
throw RedisException("Invalid Redis type returned");
|
||||
@ -121,29 +121,5 @@ void Client::sendCommands(const std::vector<Array>& commands, std::vector<RedisT
|
||||
}
|
||||
}
|
||||
|
||||
RedisType::Ptr Client::createRedisType(char marker)
|
||||
{
|
||||
RedisType::Ptr result;
|
||||
|
||||
switch(marker)
|
||||
{
|
||||
case ElementTraits<Int64>::marker :
|
||||
result = new Type<Int64>();
|
||||
break;
|
||||
case ElementTraits<std::string>::marker :
|
||||
result = new Type<std::string>();
|
||||
break;
|
||||
case ElementTraits<BulkString>::marker :
|
||||
result = new Type<BulkString>();
|
||||
break;
|
||||
case ElementTraits<Array>::marker :
|
||||
result = new Type<Array>();
|
||||
break;
|
||||
case ElementTraits<Error>::marker :
|
||||
result = new Type<Error>();
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} } // Poco::Redis
|
||||
|
@ -16,6 +16,8 @@
|
||||
//
|
||||
|
||||
#include "Poco/Redis/Type.h"
|
||||
#include "Poco/Redis/Error.h"
|
||||
#include "Poco/Redis/Array.h"
|
||||
|
||||
namespace Poco {
|
||||
namespace Redis {
|
||||
@ -29,4 +31,31 @@ RedisType::~RedisType()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
RedisType::Ptr RedisType::createRedisType(char marker)
|
||||
{
|
||||
RedisType::Ptr result;
|
||||
|
||||
switch(marker)
|
||||
{
|
||||
case ElementTraits<Int64>::marker :
|
||||
result = new Type<Int64>();
|
||||
break;
|
||||
case ElementTraits<std::string>::marker :
|
||||
result = new Type<std::string>();
|
||||
break;
|
||||
case ElementTraits<BulkString>::marker :
|
||||
result = new Type<BulkString>();
|
||||
break;
|
||||
case ElementTraits<Array>::marker :
|
||||
result = new Type<Array>();
|
||||
break;
|
||||
case ElementTraits<Error>::marker :
|
||||
result = new Type<Error>();
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}}
|
Loading…
x
Reference in New Issue
Block a user