1
0
Fork 0
mirror of https://github.com/KingDuckZ/dindexer.git synced 2024-11-29 01:33:46 +00:00

Move variant types enum out of implem namespace.

Also assert that you can get the type you are trying to get before
actually trying.
This commit is contained in:
King_DuckZ 2016-06-14 09:37:57 +01:00
parent ab43215f49
commit 9ef9b05014
2 changed files with 11 additions and 8 deletions

View file

@ -21,10 +21,12 @@
namespace redis {
const long long& get_integer (const Reply& parReply) {
assert(RedisVariantType_Integer == parReply.which());
return boost::get<long long>(parReply);
}
const std::string& get_string (const Reply& parReply) {
assert(RedisVariantType_String == parReply.which());
return boost::get<std::string>(parReply);
}
@ -33,9 +35,9 @@ namespace redis {
const auto type = parReply.which();
switch (type) {
case implem::RedisVariantType_Integer:
case RedisVariantType_Integer:
return get_integer(parReply);
case implem::RedisVariantType_String:
case RedisVariantType_String:
return lexical_cast<long long>(get_string(parReply));
default:
assert(false);
@ -44,6 +46,7 @@ namespace redis {
}
const std::vector<Reply>& get_array (const Reply& parReply) {
assert(RedisVariantType_Array == parReply.which());
return boost::get<std::vector<Reply>>(parReply);
}

View file

@ -31,13 +31,13 @@ namespace redis {
std::string,
std::vector<Reply>
>;
enum RedisVariantTypes {
RedisVariantType_Integer = 0,
RedisVariantType_String,
RedisVariantType_Array,
RedisVariantType_Bool
};
} //namespace implem
enum RedisVariantTypes {
RedisVariantType_Integer = 0,
RedisVariantType_String,
RedisVariantType_Array,
RedisVariantType_Bool
};
struct Reply : implem::RedisVariantType {
using base_class = implem::RedisVariantType;