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:
parent
ab43215f49
commit
9ef9b05014
2 changed files with 11 additions and 8 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue