From 68a73d3eb6c45cac6b65aa2fd0849d38d7d57bae Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Fri, 2 Dec 2016 14:15:04 +0000 Subject: [PATCH] Replace long long with RedisInt typedef. --- include/incredis/reply.hpp | 9 +++++---- include/incredis/scan_iterator.hpp | 10 +++++----- include/incredis/scan_iterator.inl | 6 +++--- src/reply.cpp | 12 ++++++------ src/scan_iterator.cpp | 4 ++-- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/include/incredis/reply.hpp b/include/incredis/reply.hpp index 1539dc7..10ab56e 100644 --- a/include/incredis/reply.hpp +++ b/include/incredis/reply.hpp @@ -23,6 +23,7 @@ #include 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, 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&& 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& get_array ( const Reply& parReply ); const ErrorString& get_error_string ( const Reply& parReply ); diff --git a/include/incredis/scan_iterator.hpp b/include/incredis/scan_iterator.hpp index f7be2f0..ddd5fcd 100644 --- a/include/incredis/scan_iterator.hpp +++ b/include/incredis/scan_iterator.hpp @@ -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 - Reply forward_scan_command ( typename std::enable_if::value, long long>::type parContext ); + Reply forward_scan_command ( typename std::enable_if::value, RedisInt>::type parContext ); template - Reply forward_scan_command ( typename std::enable_if::value, long long>::type parContext ); + Reply forward_scan_command ( typename std::enable_if::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 m_reply; - long long m_scan_context; + RedisInt m_scan_context; std::size_t m_curr_index; }; diff --git a/include/incredis/scan_iterator.inl b/include/incredis/scan_iterator.inl index d08072c..d748e17 100644 --- a/include/incredis/scan_iterator.inl +++ b/include/incredis/scan_iterator.inl @@ -82,7 +82,7 @@ namespace redis { } else { std::vector array_reply; - long long new_context = m_scan_context; + RedisInt new_context = m_scan_context; do { auto whole_reply = this->forward_scan_command(new_context); @@ -131,13 +131,13 @@ namespace redis { template template - Reply ScanIterator::forward_scan_command (typename std::enable_if::value, long long>::type parContext) { + Reply ScanIterator::forward_scan_command (typename std::enable_if::value, RedisInt>::type parContext) { return implem::ScanIteratorBaseClass::run(T::command(), T::scan_target(), parContext, T::work_count); } template template - Reply ScanIterator::forward_scan_command (typename std::enable_if::value, long long>::type parContext) { + Reply ScanIterator::forward_scan_command (typename std::enable_if::value, RedisInt>::type parContext) { return implem::ScanIteratorBaseClass::run(T::command(), parContext, T::work_count); } diff --git a/src/reply.cpp b/src/reply.cpp index eb2be05..5b40126 100644 --- a/src/reply.cpp +++ b/src/reply.cpp @@ -20,9 +20,9 @@ #include namespace redis { - const long long& get_integer (const Reply& parReply) { + const RedisInt& get_integer (const Reply& parReply) { assert(parReply.is_integer()); - return boost::get(parReply); + return boost::get(parReply); } const std::string& get_string (const Reply& parReply) { @@ -34,7 +34,7 @@ namespace redis { return boost::get(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(get_string(parReply)); + return lexical_cast(get_string(parReply)); default: assert(false); return 0; @@ -70,7 +70,7 @@ namespace redis { } template <> - const long long& get (const Reply& parReply) { + const RedisInt& get (const Reply& parReply) { return get_integer(parReply); } @@ -92,7 +92,7 @@ namespace redis { template const std::string& get ( const Reply& parReply ); template const std::vector& get> ( const Reply& parReply ); - template const long long& get ( const Reply& parReply ); + template const RedisInt& get ( const Reply& parReply ); template const ErrorString& get ( const Reply& parReply ); template const StatusString& get ( const Reply& parReply ); diff --git a/src/scan_iterator.cpp b/src/scan_iterator.cpp index ee905f6..6758988 100644 --- a/src/scan_iterator.cpp +++ b/src/scan_iterator.cpp @@ -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(parScanContext); const auto count_hint = dhandy::lexical_cast(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(parScanContext); const auto count_hint = dhandy::lexical_cast(parCount); if (m_match_pattern.empty())