diff --git a/src/backends/redis/command.hpp b/src/backends/redis/command.hpp index ca22514..d4e1ce6 100644 --- a/src/backends/redis/command.hpp +++ b/src/backends/redis/command.hpp @@ -37,9 +37,9 @@ struct redisContext; namespace redis { class Command { public: - typedef ScanIterator> scan_iterator; + typedef ScanIterator> scan_iterator; typedef boost::iterator_range scan_range; - typedef ScanIterator, ScanPairs>> hscan_iterator; + typedef ScanIterator>> hscan_iterator; typedef boost::iterator_range hscan_range; Command ( std::string&& parAddress, uint16_t parPort ); diff --git a/src/backends/redis/scan_iterator.hpp b/src/backends/redis/scan_iterator.hpp index e98dbcc..3c24139 100644 --- a/src/backends/redis/scan_iterator.hpp +++ b/src/backends/redis/scan_iterator.hpp @@ -27,14 +27,14 @@ #include namespace redis { - template + template class ScanIterator; class Command; namespace implem { - template - using ScanIteratorBaseIterator = boost::iterator_facade, const V, boost::forward_traversal_tag>; + template + using ScanIteratorBaseIterator = boost::iterator_facade, const typename ValueFetch::value_type, boost::forward_traversal_tag>; class ScanIteratorBaseClass { protected: @@ -52,10 +52,10 @@ namespace redis { }; } //namespace implem - template - class ScanIterator : private implem::ScanIteratorBaseClass, public implem::ScanIteratorBaseIterator, private ValueFetch { + template + class ScanIterator : private implem::ScanIteratorBaseClass, public implem::ScanIteratorBaseIterator, private ValueFetch { friend class boost::iterator_core_access; - typedef implem::ScanIteratorBaseIterator base_iterator; + typedef implem::ScanIteratorBaseIterator base_iterator; define_has_method(scan_target, ScanTarget); public: typedef typename base_iterator::difference_type difference_type; @@ -78,7 +78,7 @@ namespace redis { void increment ( void ); bool equal ( const ScanIterator& parOther ) const; - const V& dereference ( void ) const; + const value_type& dereference ( void ) const; std::vector m_reply; long long m_scan_context; @@ -87,6 +87,8 @@ namespace redis { template struct ScanSingleValues { + typedef T value_type; + static constexpr const char* command ( void ) { return "SCAN"; } static constexpr const std::size_t step = 1; @@ -95,14 +97,14 @@ namespace redis { template struct ScanPairs { - typedef P PairType; + typedef P value_type; explicit ScanPairs ( boost::string_ref parScanTarget ) : m_scan_target(parScanTarget) {} static constexpr const char* command ( void ) { return "HSCAN"; } static constexpr const std::size_t step = 2; - static PairType make_value ( const RedisReplyType* parItem ); + static value_type make_value ( const RedisReplyType* parItem ); boost::string_ref scan_target ( void ); private: diff --git a/src/backends/redis/scan_iterator.inl b/src/backends/redis/scan_iterator.inl index 3427948..fa75eff 100644 --- a/src/backends/redis/scan_iterator.inl +++ b/src/backends/redis/scan_iterator.inl @@ -23,11 +23,11 @@ namespace redis { namespace implem { } //namespace implem - template + template template - ScanIterator::ScanIterator (Command* parCommand, bool parEnd) : + ScanIterator::ScanIterator (Command* parCommand, bool parEnd) : implem::ScanIteratorBaseClass(parCommand), - implem::ScanIteratorBaseIterator(), + implem::ScanIteratorBaseIterator(), ValueFetch(), m_reply(), m_scan_context(0), @@ -43,11 +43,11 @@ namespace redis { } } - template + template template - ScanIterator::ScanIterator (Command* parCommand, boost::string_ref parKey, bool parEnd) : + ScanIterator::ScanIterator (Command* parCommand, boost::string_ref parKey, bool parEnd) : implem::ScanIteratorBaseClass(parCommand), - implem::ScanIteratorBaseIterator(), + implem::ScanIteratorBaseIterator(), ValueFetch(parKey), m_reply(), m_scan_context(0), @@ -63,13 +63,13 @@ namespace redis { } } - template - bool ScanIterator::is_end() const { + template + bool ScanIterator::is_end() const { return not m_curr_index and m_reply.empty() and not m_scan_context; } - template - void ScanIterator::increment() { + template + void ScanIterator::increment() { assert(not is_end()); static_assert(ValueFetch::step > 0, "Can't have an increase step of 0"); @@ -107,8 +107,8 @@ namespace redis { } } - template - bool ScanIterator::equal (const ScanIterator& parOther) const { + template + bool ScanIterator::equal (const ScanIterator& parOther) const { return (&parOther == this) or (is_end() and parOther.is_end()) or @@ -121,36 +121,36 @@ namespace redis { ); } - template - const V& ScanIterator::dereference() const { + template + auto ScanIterator::dereference() const -> const value_type& { assert(not m_reply.empty()); assert(m_curr_index < m_reply.size()); return m_reply[m_curr_index]; } - template + template template - RedisReplyType ScanIterator::forward_scan_command (typename std::enable_if::value, int>::type) { + RedisReplyType ScanIterator::forward_scan_command (typename std::enable_if::value, int>::type) { return implem::ScanIteratorBaseClass::run(T::command(), T::scan_target(), m_scan_context); } - template + template template - RedisReplyType ScanIterator::forward_scan_command (typename std::enable_if::value, int>::type) { + RedisReplyType ScanIterator::forward_scan_command (typename std::enable_if::value, int>::type) { return implem::ScanIteratorBaseClass::run(T::command(), m_scan_context); } template - const T& ScanSingleValues::make_value (const RedisReplyType* parItem) { + auto ScanSingleValues::make_value (const RedisReplyType* parItem) -> const value_type& { assert(parItem); return get(*parItem); } template - P ScanPairs::make_value (const RedisReplyType* parItem) { + auto ScanPairs::make_value (const RedisReplyType* parItem) -> value_type { assert(parItem); - return PairType(get(parItem[0]), get(parItem[1])); + return value_type(get(parItem[0]), get(parItem[1])); } template