mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-07-02 14:04:22 +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 {
|
namespace redis {
|
||||||
const long long& get_integer (const Reply& parReply) {
|
const long long& get_integer (const Reply& parReply) {
|
||||||
|
assert(RedisVariantType_Integer == parReply.which());
|
||||||
return boost::get<long long>(parReply);
|
return boost::get<long long>(parReply);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& get_string (const Reply& parReply) {
|
const std::string& get_string (const Reply& parReply) {
|
||||||
|
assert(RedisVariantType_String == parReply.which());
|
||||||
return boost::get<std::string>(parReply);
|
return boost::get<std::string>(parReply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,9 +35,9 @@ namespace redis {
|
||||||
|
|
||||||
const auto type = parReply.which();
|
const auto type = parReply.which();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case implem::RedisVariantType_Integer:
|
case RedisVariantType_Integer:
|
||||||
return get_integer(parReply);
|
return get_integer(parReply);
|
||||||
case implem::RedisVariantType_String:
|
case RedisVariantType_String:
|
||||||
return lexical_cast<long long>(get_string(parReply));
|
return lexical_cast<long long>(get_string(parReply));
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
|
@ -44,6 +46,7 @@ namespace redis {
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<Reply>& get_array (const Reply& parReply) {
|
const std::vector<Reply>& get_array (const Reply& parReply) {
|
||||||
|
assert(RedisVariantType_Array == parReply.which());
|
||||||
return boost::get<std::vector<Reply>>(parReply);
|
return boost::get<std::vector<Reply>>(parReply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,13 +31,13 @@ namespace redis {
|
||||||
std::string,
|
std::string,
|
||||||
std::vector<Reply>
|
std::vector<Reply>
|
||||||
>;
|
>;
|
||||||
enum RedisVariantTypes {
|
|
||||||
RedisVariantType_Integer = 0,
|
|
||||||
RedisVariantType_String,
|
|
||||||
RedisVariantType_Array,
|
|
||||||
RedisVariantType_Bool
|
|
||||||
};
|
|
||||||
} //namespace implem
|
} //namespace implem
|
||||||
|
enum RedisVariantTypes {
|
||||||
|
RedisVariantType_Integer = 0,
|
||||||
|
RedisVariantType_String,
|
||||||
|
RedisVariantType_Array,
|
||||||
|
RedisVariantType_Bool
|
||||||
|
};
|
||||||
|
|
||||||
struct Reply : implem::RedisVariantType {
|
struct Reply : implem::RedisVariantType {
|
||||||
using base_class = implem::RedisVariantType;
|
using base_class = implem::RedisVariantType;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue