mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-07-16 16:24:12 +00:00
Make the scan command in ScanPairs a template parameter.
This commit is contained in:
parent
9949c273a1
commit
78eee0e16f
4 changed files with 12 additions and 5 deletions
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "reply.hpp"
|
||||
#include "helpers/has_method.hpp"
|
||||
#include "enum.h"
|
||||
#include <boost/iterator/iterator_facade.hpp>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
@ -52,6 +53,10 @@ namespace redis {
|
|||
};
|
||||
} //namespace implem
|
||||
|
||||
BETTER_ENUM(ScanCommands, char,
|
||||
SCAN, SSCAN, ZSCAN, HSCAN
|
||||
);
|
||||
|
||||
template <typename ValueFetch>
|
||||
class ScanIterator : private implem::ScanIteratorBaseClass, public implem::ScanIteratorBaseIterator<ValueFetch>, private ValueFetch {
|
||||
friend class boost::iterator_core_access;
|
||||
|
@ -111,13 +116,14 @@ namespace redis {
|
|||
boost::string_ref m_scan_target;
|
||||
};
|
||||
|
||||
template <typename P, typename A=decltype(P().first), typename B=decltype(P().second)>
|
||||
template <typename P, char Command, typename A=decltype(P().first), typename B=decltype(P().second)>
|
||||
struct ScanPairs {
|
||||
static_assert(Command == ScanCommands::HSCAN or Command == ScanCommands::ZSCAN, "Invalid scan command chosen");
|
||||
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 char* command ( void ) { return ScanCommands::_from_integral(Command)._to_string(); }
|
||||
static constexpr const std::size_t step = 2;
|
||||
|
||||
static value_type make_value ( const RedisReplyType* parItem );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue