mirror of
https://github.com/KingDuckZ/incredis
synced 2024-12-27 21:35:42 +00:00
Replace long long with RedisInt typedef.
This commit is contained in:
parent
0da5c0de3c
commit
68a73d3eb6
5 changed files with 21 additions and 20 deletions
|
@ -23,6 +23,7 @@
|
|||
#include <vector>
|
||||
|
||||
namespace redis {
|
||||
typedef long long RedisInt;
|
||||
struct Reply;
|
||||
|
||||
class ErrorString {
|
||||
|
@ -49,7 +50,7 @@ namespace redis {
|
|||
|
||||
namespace implem {
|
||||
using RedisVariantType = boost::variant<
|
||||
long long,
|
||||
RedisInt,
|
||||
std::string,
|
||||
std::vector<Reply>,
|
||||
ErrorString,
|
||||
|
@ -70,7 +71,7 @@ namespace redis {
|
|||
using base_class = implem::RedisVariantType;
|
||||
|
||||
Reply ( void ) = default;
|
||||
Reply ( long long parVal ) : base_class(parVal) {}
|
||||
Reply ( RedisInt parVal ) : base_class(parVal) {}
|
||||
Reply ( std::string&& parVal ) : base_class(std::move(parVal)) {}
|
||||
Reply ( std::vector<Reply>&& parVal ) : base_class(std::move(parVal)) {}
|
||||
Reply ( ErrorString&& parVal ) : base_class(std::move(parVal)) {}
|
||||
|
@ -86,8 +87,8 @@ namespace redis {
|
|||
bool is_nil ( void ) const;
|
||||
};
|
||||
|
||||
const long long& get_integer ( const Reply& parReply );
|
||||
long long get_integer_autoconv_if_str ( const Reply& parReply );
|
||||
const RedisInt& get_integer ( const Reply& parReply );
|
||||
RedisInt get_integer_autoconv_if_str ( const Reply& parReply );
|
||||
const std::string& get_string ( const Reply& parReply );
|
||||
const std::vector<Reply>& get_array ( const Reply& parReply );
|
||||
const ErrorString& get_error_string ( const Reply& parReply );
|
||||
|
|
|
@ -44,8 +44,8 @@ namespace redis {
|
|||
~ScanIteratorBaseClass ( void ) noexcept = default;
|
||||
|
||||
bool is_connected ( void ) const;
|
||||
Reply run ( const char* parCommand, long long parScanContext, std::size_t parCount );
|
||||
Reply run ( const char* parCommand, const boost::string_ref& parParameter, long long parScanContext, std::size_t parCount );
|
||||
Reply run ( const char* parCommand, RedisInt parScanContext, std::size_t parCount );
|
||||
Reply run ( const char* parCommand, const boost::string_ref& parParameter, RedisInt parScanContext, std::size_t parCount );
|
||||
|
||||
bool is_equal ( const ScanIteratorBaseClass& parOther ) const { return m_command == parOther.m_command; }
|
||||
|
||||
|
@ -78,9 +78,9 @@ namespace redis {
|
|||
|
||||
private:
|
||||
template <typename T>
|
||||
Reply forward_scan_command ( typename std::enable_if<HasScanTargetMethod<T>::value, long long>::type parContext );
|
||||
Reply forward_scan_command ( typename std::enable_if<HasScanTargetMethod<T>::value, RedisInt>::type parContext );
|
||||
template <typename T>
|
||||
Reply forward_scan_command ( typename std::enable_if<not HasScanTargetMethod<T>::value, long long>::type parContext );
|
||||
Reply forward_scan_command ( typename std::enable_if<not HasScanTargetMethod<T>::value, RedisInt>::type parContext );
|
||||
bool is_end ( void ) const;
|
||||
|
||||
void increment ( void );
|
||||
|
@ -88,7 +88,7 @@ namespace redis {
|
|||
const value_type& dereference ( void ) const;
|
||||
|
||||
std::vector<value_type> m_reply;
|
||||
long long m_scan_context;
|
||||
RedisInt m_scan_context;
|
||||
std::size_t m_curr_index;
|
||||
};
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ namespace redis {
|
|||
}
|
||||
else {
|
||||
std::vector<Reply> array_reply;
|
||||
long long new_context = m_scan_context;
|
||||
RedisInt new_context = m_scan_context;
|
||||
|
||||
do {
|
||||
auto whole_reply = this->forward_scan_command<ValueFetch>(new_context);
|
||||
|
@ -131,13 +131,13 @@ namespace redis {
|
|||
|
||||
template <typename ValueFetch>
|
||||
template <typename T>
|
||||
Reply ScanIterator<ValueFetch>::forward_scan_command (typename std::enable_if<HasScanTargetMethod<T>::value, long long>::type parContext) {
|
||||
Reply ScanIterator<ValueFetch>::forward_scan_command (typename std::enable_if<HasScanTargetMethod<T>::value, RedisInt>::type parContext) {
|
||||
return implem::ScanIteratorBaseClass::run(T::command(), T::scan_target(), parContext, T::work_count);
|
||||
}
|
||||
|
||||
template <typename ValueFetch>
|
||||
template <typename T>
|
||||
Reply ScanIterator<ValueFetch>::forward_scan_command (typename std::enable_if<not HasScanTargetMethod<T>::value, long long>::type parContext) {
|
||||
Reply ScanIterator<ValueFetch>::forward_scan_command (typename std::enable_if<not HasScanTargetMethod<T>::value, RedisInt>::type parContext) {
|
||||
return implem::ScanIteratorBaseClass::run(T::command(), parContext, T::work_count);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
#include <boost/variant/get.hpp>
|
||||
|
||||
namespace redis {
|
||||
const long long& get_integer (const Reply& parReply) {
|
||||
const RedisInt& get_integer (const Reply& parReply) {
|
||||
assert(parReply.is_integer());
|
||||
return boost::get<long long>(parReply);
|
||||
return boost::get<RedisInt>(parReply);
|
||||
}
|
||||
|
||||
const std::string& get_string (const Reply& parReply) {
|
||||
|
@ -34,7 +34,7 @@ namespace redis {
|
|||
return boost::get<std::string>(parReply);
|
||||
}
|
||||
|
||||
long long get_integer_autoconv_if_str (const Reply &parReply) {
|
||||
RedisInt get_integer_autoconv_if_str (const Reply &parReply) {
|
||||
using dhandy::lexical_cast;
|
||||
|
||||
const auto type = parReply.which();
|
||||
|
@ -42,7 +42,7 @@ namespace redis {
|
|||
case RedisVariantType_Integer:
|
||||
return get_integer(parReply);
|
||||
case RedisVariantType_String:
|
||||
return lexical_cast<long long>(get_string(parReply));
|
||||
return lexical_cast<RedisInt>(get_string(parReply));
|
||||
default:
|
||||
assert(false);
|
||||
return 0;
|
||||
|
@ -70,7 +70,7 @@ namespace redis {
|
|||
}
|
||||
|
||||
template <>
|
||||
const long long& get<long long> (const Reply& parReply) {
|
||||
const RedisInt& get<RedisInt> (const Reply& parReply) {
|
||||
return get_integer(parReply);
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ namespace redis {
|
|||
|
||||
template const std::string& get<std::string> ( const Reply& parReply );
|
||||
template const std::vector<Reply>& get<std::vector<Reply>> ( const Reply& parReply );
|
||||
template const long long& get<long long> ( const Reply& parReply );
|
||||
template const RedisInt& get<RedisInt> ( const Reply& parReply );
|
||||
template const ErrorString& get<ErrorString> ( const Reply& parReply );
|
||||
template const StatusString& get<StatusString> ( const Reply& parReply );
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace redis {
|
|||
return m_command and m_command->is_connected();
|
||||
}
|
||||
|
||||
Reply ScanIteratorBaseClass::run (const char* parCommand, long long parScanContext, std::size_t parCount) {
|
||||
Reply ScanIteratorBaseClass::run (const char* parCommand, RedisInt parScanContext, std::size_t parCount) {
|
||||
const auto scan_context = dhandy::lexical_cast<std::string>(parScanContext);
|
||||
const auto count_hint = dhandy::lexical_cast<std::string>(parCount);
|
||||
if (m_match_pattern.empty())
|
||||
|
@ -50,7 +50,7 @@ namespace redis {
|
|||
return m_command->run(parCommand, scan_context, "MATCH", m_match_pattern, "COUNT", count_hint);
|
||||
}
|
||||
|
||||
Reply ScanIteratorBaseClass::run (const char* parCommand, const boost::string_ref& parParameter, long long parScanContext, std::size_t parCount) {
|
||||
Reply ScanIteratorBaseClass::run (const char* parCommand, const boost::string_ref& parParameter, RedisInt parScanContext, std::size_t parCount) {
|
||||
const auto scan_context = dhandy::lexical_cast<std::string>(parScanContext);
|
||||
const auto count_hint = dhandy::lexical_cast<std::string>(parCount);
|
||||
if (m_match_pattern.empty())
|
||||
|
|
Loading…
Reference in a new issue