Add some type helper functions

This commit is contained in:
fbraem 2015-10-26 15:56:52 +01:00
parent a46ef4144e
commit 611f38002f

View File

@ -40,6 +40,16 @@ public:
RedisType(); RedisType();
virtual ~RedisType(); virtual ~RedisType();
bool isArray() const;
bool isBulkString() const;
bool isError() const;
bool isInteger() const;
bool isSimpleString() const;
virtual int type() const = 0; virtual int type() const = 0;
virtual void read(RedisSocket& socket) = 0; virtual void read(RedisSocket& socket) = 0;
@ -66,6 +76,31 @@ private:
}; };
inline bool RedisType::isArray() const
{
return type() == REDIS_ARRAY;
}
inline bool RedisType::isBulkString() const
{
return type() == REDIS_BULK_STRING;
}
inline bool RedisType::isError() const
{
return type() == REDIS_ERROR;
}
inline bool RedisType::isInteger() const
{
return type() == REDIS_INTEGER;
}
inline bool RedisType::isSimpleString() const
{
return type() == REDIS_SIMPLE_STRING;
}
template<typename T> template<typename T>
struct ElementTraits struct ElementTraits
{ {