Add typedef StringVec

This commit is contained in:
fbraem 2015-11-18 18:13:17 +01:00
parent 8015d827f4
commit 52ce9bf469
2 changed files with 48 additions and 45 deletions

View File

@ -36,6 +36,9 @@ class Redis_API Command : public Array
/// or << operator.
{
public:
typedef std::vector<std::string> StringVec;
Command(const std::string& command);
/// Constructor
@ -48,10 +51,10 @@ public:
static Command append(const std::string& key, const std::string& value);
/// Returns an APPEND command
static Command blpop(const std::vector<std::string>& lists, Int64 timeout = 0);
static Command blpop(const StringVec& lists, Int64 timeout = 0);
/// Returns a BLPOP command
static Command brpop(const std::vector<std::string>& lists, Int64 timeout = 0);
static Command brpop(const StringVec& lists, Int64 timeout = 0);
/// Returns a BRPOP command
static Command brpoplpush(const std::string& sourceList, const std::string& destinationList, Int64 timeout = 0);
@ -63,7 +66,7 @@ public:
static Command del(const std::string& key);
/// Returns an DEL command
static Command del(const std::vector<std::string>& keys);
static Command del(const StringVec& keys);
/// Returns an DEL command
static Command get(const std::string& key);
@ -72,7 +75,7 @@ public:
static Command hdel(const std::string& hash, const std::string& field);
/// Returns an HDEL command
static Command hdel(const std::string& hash, const std::vector<std::string>& fields);
static Command hdel(const std::string& hash, const StringVec& fields);
/// Returns an HDEL command
static Command hexists(const std::string& hash, const std::string& field);
@ -117,7 +120,7 @@ public:
static Command lpush(const std::string& list, const std::string& value, bool create = true);
/// Returns a LPUSH or LPUSHX (when create is false) command
static Command lpush(const std::string& list, const std::vector<std::string>& value, bool create = true);
static Command lpush(const std::string& list, const StringVec& value, bool create = true);
/// Returns a LPUSH or LPUSHX (when create is false) command
static Command lrange(const std::string& list, Int64 start = 0, Int64 stop = -1);
@ -133,7 +136,7 @@ public:
static Command ltrim(const std::string& list, Int64 start = 0, Int64 stop = -1);
/// Returns a LTRIM command
static Command mget(const std::vector<std::string>& keys);
static Command mget(const StringVec& keys);
/// Returns a MGET command
static Command mset(const std::map<std::string, std::string>& keyvalues, bool create = true);
@ -142,7 +145,7 @@ public:
static Command sadd(const std::string& set, const std::string& value);
/// Returns a SADD command
static Command sadd(const std::string& set, const std::vector<std::string>& values);
static Command sadd(const std::string& set, const StringVec& values);
/// Returns a SADD command
static Command scard(const std::string& set);
@ -151,13 +154,13 @@ public:
static Command sdiff(const std::string& set1, const std::string& set2);
/// Returns a SDIFF command
static Command sdiff(const std::string& set, const std::vector<std::string>& sets);
static Command sdiff(const std::string& set, const StringVec& sets);
/// Returns a SDIFF command
static Command sdiffstore(const std::string& set, const std::string& set1, const std::string& set2);
/// Returns a SDIFFSTORE command
static Command sdiffstore(const std::string& set, const std::vector<std::string>& sets);
static Command sdiffstore(const std::string& set, const StringVec& sets);
/// Returns a SDIFFSTORE command
static Command set(const std::string& key, const std::string& value, bool overwrite = true, const Poco::Timespan& expireTime = 0, bool create = true);
@ -169,13 +172,13 @@ public:
static Command sinter(const std::string& set1, const std::string& set2);
/// Returns a SINTER command
static Command sinter(const std::string& set, const std::vector<std::string>& sets);
static Command sinter(const std::string& set, const StringVec& sets);
/// Returns a SINTER command
static Command sinterstore(const std::string& set, const std::string& set1, const std::string& set2);
/// Returns a SINTERSTORE command
static Command sinterstore(const std::string& set, const std::vector<std::string>& sets);
static Command sinterstore(const std::string& set, const StringVec& sets);
/// Returns a SINTERSTORE command
static Command sismember(const std::string& set, const std::string& member);
@ -196,19 +199,19 @@ public:
static Command srem(const std::string& set, const std::string& member);
/// Returns a SREM command
static Command srem(const std::string& set, const std::vector<std::string>& member);
static Command srem(const std::string& set, const StringVec& members);
/// Returns a SREM command
static Command sunion(const std::string& set1, const std::string& set2);
/// Returns a SUNION command
static Command sunion(const std::string& set, const std::vector<std::string>& sets);
static Command sunion(const std::string& set, const StringVec& sets);
/// Returns a SUNION command
static Command sunionstore(const std::string& set, const std::string& set1, const std::string& set2);
/// Returns a SUNIONSTORE command
static Command sunionstore(const std::string& set, const std::vector<std::string>& sets);
static Command sunionstore(const std::string& set, const StringVec& sets);
/// Returns a SUNIONSTORE command
static Command rename(const std::string& key, const std::string& newName, bool overwrite = true);
@ -223,7 +226,7 @@ public:
static Command rpush(const std::string& list, const std::string& value, bool create = true);
/// Returns a RPUSH or RPUSHX (when create is false) command
static Command rpush(const std::string& list, const std::vector<std::string>& value, bool create = true);
static Command rpush(const std::string& list, const StringVec& value, bool create = true);
/// Returns a RPUSH or RPUSHX (when create is false) command
};

View File

@ -43,11 +43,11 @@ Command Command::append(const std::string& key, const std::string& value)
return cmd;
}
Command Command::blpop(const std::vector<std::string>& lists, Int64 timeout)
Command Command::blpop(const StringVec& lists, Int64 timeout)
{
Command cmd("BLPOP");
for(std::vector<std::string>::const_iterator it = lists.begin(); it != lists.end(); ++it)
for(StringVec::const_iterator it = lists.begin(); it != lists.end(); ++it)
{
cmd << *it;
}
@ -56,11 +56,11 @@ Command Command::blpop(const std::vector<std::string>& lists, Int64 timeout)
return cmd;
}
Command Command::brpop(const std::vector<std::string>& lists, Int64 timeout)
Command Command::brpop(const StringVec& lists, Int64 timeout)
{
Command cmd("BRPOP");
for(std::vector<std::string>::const_iterator it = lists.begin(); it != lists.end(); ++it)
for(StringVec::const_iterator it = lists.begin(); it != lists.end(); ++it)
{
cmd << *it;
}
@ -97,11 +97,11 @@ Command Command::del(const std::string& key)
return cmd;
}
Command Command::del(const std::vector<std::string>& keys)
Command Command::del(const StringVec& keys)
{
Command cmd("DEL");
for(std::vector<std::string>::const_iterator it = keys.begin(); it != keys.end(); ++it)
for(StringVec::const_iterator it = keys.begin(); it != keys.end(); ++it)
{
cmd << *it;
}
@ -127,12 +127,12 @@ Command Command::hdel(const std::string& hash, const std::string& field)
return cmd;
}
Command Command::hdel(const std::string& hash, const std::vector<std::string>& fields)
Command Command::hdel(const std::string& hash, const StringVec& fields)
{
Command cmd("HDEL");
cmd << hash;
for(std::vector<std::string>::const_iterator it = fields.begin(); it != fields.end(); ++it)
for(StringVec::const_iterator it = fields.begin(); it != fields.end(); ++it)
{
cmd << *it;
}
@ -262,12 +262,12 @@ Command Command::lpush(const std::string& list, const std::string& value, bool c
return cmd;
}
Command Command::lpush(const std::string& list, const std::vector<std::string>& values, bool create)
Command Command::lpush(const std::string& list, const StringVec& values, bool create)
{
Command cmd(create ? "LPUSH" : "LPUSHX");
cmd << list;
for(std::vector<std::string>::const_iterator it = values.begin(); it != values.end(); ++it)
for(StringVec::const_iterator it = values.begin(); it != values.end(); ++it)
{
cmd << *it;
}
@ -311,11 +311,11 @@ Command Command::ltrim(const std::__cxx11::string& list, Int64 start, Int64 stop
return cmd;
}
Command Command::mget(const std::vector<std::string>& keys)
Command Command::mget(const StringVec& keys)
{
Command cmd("MGET");
for(std::vector<std::string>::const_iterator it = keys.begin(); it != keys.end(); ++it)
for(StringVec::const_iterator it = keys.begin(); it != keys.end(); ++it)
{
cmd << *it;
}
@ -344,12 +344,12 @@ Command Command::sadd(const std::string& set, const std::string& value)
return cmd;
}
Command Command::sadd(const std::string& set, const std::vector<std::string>& values)
Command Command::sadd(const std::string& set, const StringVec& values)
{
Command cmd("SADD");
cmd << set;
for(std::vector<std::string>::const_iterator it = values.begin(); it != values.end(); ++it)
for(StringVec::const_iterator it = values.begin(); it != values.end(); ++it)
{
cmd << *it;
}
@ -375,12 +375,12 @@ Command Command::sdiff(const std::string& set1, const std::string& set2)
return cmd;
}
Command Command::sdiff(const std::string& set, const std::vector<std::string>& sets)
Command Command::sdiff(const std::string& set, const StringVec& sets)
{
Command cmd("SDIFF");
cmd << set;
for(std::vector<std::string>::const_iterator it = sets.begin(); it != sets.end(); ++it)
for(StringVec::const_iterator it = sets.begin(); it != sets.end(); ++it)
{
cmd << *it;
}
@ -397,12 +397,12 @@ Command Command::sdiffstore(const std::string& set, const std::string& set1, con
return cmd;
}
Command Command::sdiffstore(const std::string& set, const std::vector<std::string>& sets)
Command Command::sdiffstore(const std::string& set, const StringVec& sets)
{
Command cmd("SDIFFSTORE");
cmd << set;
for(std::vector<std::string>::const_iterator it = sets.begin(); it != sets.end(); ++it)
for(StringVec::const_iterator it = sets.begin(); it != sets.end(); ++it)
{
cmd << *it;
}
@ -436,12 +436,12 @@ Command Command::sinter(const std::string& set1, const std::string& set2)
return cmd;
}
Command Command::sinter(const std::string& set, const std::vector<std::string>& sets)
Command Command::sinter(const std::string& set, const StringVec& sets)
{
Command cmd("SINTER");
cmd << set;
for(std::vector<std::string>::const_iterator it = sets.begin(); it != sets.end(); ++it)
for(StringVec::const_iterator it = sets.begin(); it != sets.end(); ++it)
{
cmd << *it;
}
@ -458,12 +458,12 @@ Command Command::sinterstore(const std::string& set, const std::string& set1, co
return cmd;
}
Command Command::sinterstore(const std::string& set, const std::vector<std::string>& sets)
Command Command::sinterstore(const std::string& set, const StringVec& sets)
{
Command cmd("SINTERSTORE");
cmd << set;
for(std::vector<std::string>::const_iterator it = sets.begin(); it != sets.end(); ++it)
for(StringVec::const_iterator it = sets.begin(); it != sets.end(); ++it)
{
cmd << *it;
}
@ -527,12 +527,12 @@ Command Command::srem(const std::string& set1, const std::string& member)
return cmd;
}
Command Command::srem(const std::string& set, const std::vector<std::string>& members)
Command Command::srem(const std::string& set, const StringVec& members)
{
Command cmd("SREM");
cmd << set;
for(std::vector<std::string>::const_iterator it = members.begin(); it != members.end(); ++it)
for(StringVec::const_iterator it = members.begin(); it != members.end(); ++it)
{
cmd << *it;
}
@ -549,12 +549,12 @@ Command Command::sunion(const std::string& set1, const std::string& set2)
return cmd;
}
Command Command::sunion(const std::string& set, const std::vector<std::string>& sets)
Command Command::sunion(const std::string& set, const StringVec& sets)
{
Command cmd("SUNION");
cmd << set;
for(std::vector<std::string>::const_iterator it = sets.begin(); it != sets.end(); ++it)
for(StringVec::const_iterator it = sets.begin(); it != sets.end(); ++it)
{
cmd << *it;
}
@ -571,12 +571,12 @@ Command Command::sunionstore(const std::string& set, const std::string& set1, co
return cmd;
}
Command Command::sunionstore(const std::string& set, const std::vector<std::string>& sets)
Command Command::sunionstore(const std::string& set, const StringVec& sets)
{
Command cmd("SUNIONSTORE");
cmd << set;
for(std::vector<std::string>::const_iterator it = sets.begin(); it != sets.end(); ++it)
for(StringVec::const_iterator it = sets.begin(); it != sets.end(); ++it)
{
cmd << *it;
}
@ -621,12 +621,12 @@ Command Command::rpush(const std::string& list, const std::string& value, bool c
return cmd;
}
Command Command::rpush(const std::string& list, const std::vector<std::string>& values, bool create)
Command Command::rpush(const std::string& list, const StringVec& values, bool create)
{
Command cmd(create ? "RPUSH" : "RPUSHX");
cmd << list;
for(std::vector<std::string>::const_iterator it = values.begin(); it != values.end(); ++it)
for(StringVec::const_iterator it = values.begin(); it != values.end(); ++it)
{
cmd << *it;
}