Electroneum
lmdb::key_stream< K, V, D > Class Template Reference

#include <key_stream.h>

Public Member Functions

 key_stream (std::unique_ptr< MDB_cursor, D > cur)
 Take ownership of cur without changing position. nullptr valid. More...
 
 key_stream (key_stream &&)=default
 
 key_stream (key_stream const &)=delete
 
 ~key_stream ()=default
 
key_streamoperator= (key_stream &&)=default
 
key_streamoperator= (key_stream const &)=delete
 
std::unique_ptr< MDB_cursor, D > give_cursor () noexcept
 
void reset ()
 
key_iterator< K, V > make_iterator () const
 
boost::iterator_range< key_iterator< K, V > > make_range () const
 

Detailed Description

template<typename K, typename V, typename D>
class lmdb::key_stream< K, V, D >

C++ wrapper for a LMDB read-only cursor on a fixed-sized key K and value V.

Template Parameters
Kkey type being stored by each record.
Vvalue type being stored by each record.
Dcleanup functor for the cursor; usually unique per db/table.

Definition at line 188 of file key_stream.h.

Constructor & Destructor Documentation

◆ key_stream() [1/3]

template<typename K , typename V , typename D >
lmdb::key_stream< K, V, D >::key_stream ( std::unique_ptr< MDB_cursor, D >  cur)
inlineexplicit

Take ownership of cur without changing position. nullptr valid.

Definition at line 194 of file key_stream.h.

195  : cur(std::move(cur))
196  {}
const T & move(const T &t)
Definition: gtest-port.h:1317

◆ key_stream() [2/3]

template<typename K , typename V , typename D >
lmdb::key_stream< K, V, D >::key_stream ( key_stream< K, V, D > &&  )
default

◆ key_stream() [3/3]

template<typename K , typename V , typename D >
lmdb::key_stream< K, V, D >::key_stream ( key_stream< K, V, D > const &  )
delete

◆ ~key_stream()

template<typename K , typename V , typename D >
lmdb::key_stream< K, V, D >::~key_stream ( )
default

Member Function Documentation

◆ give_cursor()

template<typename K , typename V , typename D >
std::unique_ptr<MDB_cursor, D> lmdb::key_stream< K, V, D >::give_cursor ( )
inlinenoexcept

Give up ownership of the cursor. make_iterator() and make_range() can still be invoked, but return the empty set.

Returns
Currently owned LMDB cursor.

Definition at line 210 of file key_stream.h.

211  {
212  return {std::move(cur)};
213  }
const T & move(const T &t)
Definition: gtest-port.h:1317
Here is the call graph for this function:

◆ make_iterator()

template<typename K , typename V , typename D >
key_iterator<K, V> lmdb::key_stream< K, V, D >::make_iterator ( ) const
inline
Exceptions
std::system_errorif LMDB has unexpected errors.
Returns
C++ iterator over database keys from current cursor position that will reach .is_end() after the last key.

Definition at line 234 of file key_stream.h.

235  {
236  return {cur.get()};
237  }
Here is the caller graph for this function:

◆ make_range()

template<typename K , typename V , typename D >
boost::iterator_range<key_iterator<K, V> > lmdb::key_stream< K, V, D >::make_range ( ) const
inline
Exceptions
std::system_errorif LMDB has unexpected errors.
Returns
Range from current cursor position until last key record. Useful in for-each range loops or in templated code

Definition at line 244 of file key_stream.h.

245  {
246  return {make_iterator(), key_iterator<K, V>{}};
247  }
key_iterator< K, V > make_iterator() const
Definition: key_stream.h:234
Here is the call graph for this function:

◆ operator=() [1/2]

template<typename K , typename V , typename D >
key_stream& lmdb::key_stream< K, V, D >::operator= ( key_stream< K, V, D > &&  )
default

◆ operator=() [2/2]

template<typename K , typename V , typename D >
key_stream& lmdb::key_stream< K, V, D >::operator= ( key_stream< K, V, D > const &  )
delete

◆ reset()

template<typename K , typename V , typename D >
void lmdb::key_stream< K, V, D >::reset ( )
inline

Place the stream back at the first key/value. Newly created iterators will start at the first value again.

Note
Invalidates all current iterators, including those created with make_iterator or make_range. Also invalidates all value_iterators created with key_iterator.

Definition at line 223 of file key_stream.h.

224  {
225  if (cur)
226  lmdb::stream::get(*cur, MDB_FIRST, 0, 0);
227  }
std::pair< epee::span< const std::uint8_t >, epee::span< const std::uint8_t > > get(MDB_cursor &cur, MDB_cursor_op op, std::size_t key, std::size_t value)
Here is the call graph for this function:

The documentation for this class was generated from the following file: