From d2fff64381402a4ada9bbe3673603bbc81b2d0f6 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Wed, 21 Jun 2017 21:10:26 +0100 Subject: [PATCH] Experimenting with passing binary ints on to redis. --- include/incredis/arg_to_bin_safe.hpp | 10 ++++++++++ lib/duckhandy | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/incredis/arg_to_bin_safe.hpp b/include/incredis/arg_to_bin_safe.hpp index 5981e1d..9eb2d59 100644 --- a/include/incredis/arg_to_bin_safe.hpp +++ b/include/incredis/arg_to_bin_safe.hpp @@ -19,6 +19,7 @@ #define id9348909738B047B7B6912D73CB519039 #include "duckhandy/compatibility.h" +#include "duckhandy/endianness.hpp" #include #include #include @@ -76,6 +77,15 @@ namespace redis { boost::string_view m_data; }; + template<> + struct MakeCharInfo { + MakeCharInfo (RedisInt parValue) : m_value(dhandy::htobe(parValue)) {} + const char* data() const { return reinterpret_cast(&m_value); } + std::size_t size() const { return sizeof(RedisInt); } + private: + RedisInt m_value; + }; + template inline const char* arg_to_bin_safe_char (const T& parArg) { return MakeCharInfo(parArg).data(); diff --git a/lib/duckhandy b/lib/duckhandy index 7bcdb10..3276bc6 160000 --- a/lib/duckhandy +++ b/lib/duckhandy @@ -1 +1 @@ -Subproject commit 7bcdb10d19d02d11ed22ec00bbea43198ec756e8 +Subproject commit 3276bc64f4afbf3dee1256654700b763e89bcd98