From cb2ed50e1fd609f0c5620ff309def600a6eda57b Mon Sep 17 00:00:00 2001 From: bert hubert Date: Fri, 4 Jan 2019 20:51:04 +0100 Subject: [PATCH] getKey for typed +const correctness --- lmdb-safe.hh | 10 +++++----- lmdb-typed.hh | 6 ++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lmdb-safe.hh b/lmdb-safe.hh index de5cdc6..6084aa8 100644 --- a/lmdb-safe.hh +++ b/lmdb-safe.hh @@ -108,7 +108,7 @@ struct MDBOutVal template ::value, - T>::type* = nullptr> + T>::type* = nullptr> const T get() { T ret; @@ -121,10 +121,10 @@ struct MDBOutVal template ::value,T>::type* = nullptr> - T get(); + T get() const; template - T get_struct() + T get_struct() const { T ret; if(d_mdbval.mv_size != sizeof(T)) @@ -137,12 +137,12 @@ struct MDBOutVal MDB_val d_mdbval; }; -template<> inline std::string MDBOutVal::get() +template<> inline std::string MDBOutVal::get() const { return std::string((char*)d_mdbval.mv_data, d_mdbval.mv_size); } -template<> inline string_view MDBOutVal::get() +template<> inline string_view MDBOutVal::get() const { return string_view((char*)d_mdbval.mv_data, d_mdbval.mv_size); } diff --git a/lmdb-typed.hh b/lmdb-typed.hh index 79a103e..78ef80a 100644 --- a/lmdb-typed.hh +++ b/lmdb-typed.hh @@ -412,6 +412,12 @@ public: return d_key.get(); } + const MDBOutVal& getKey() + { + return d_key; + } + + // transaction we are part of Parent* d_parent; typename Parent::cursor_t d_cursor;