Electroneum
Loading...
Searching...
No Matches
lmdb::value_stream< T, D > Class Template Reference

#include <value_stream.h>

Public Member Functions

 value_stream (std::unique_ptr< MDB_cursor, D > cur)
 Take ownership of cur without changing position. nullptr valid.
 value_stream (value_stream &&)=default
 value_stream (value_stream const &)=delete
 ~value_stream ()=default
value_streamoperator= (value_stream &&)=default
value_streamoperator= (value_stream const &)=delete
std::unique_ptr< MDB_cursor, D > give_cursor () noexcept
void reset ()
std::size_t count () const
template<typename U = T, typename F = U, std::size_t offset = 0>
value_iterator< U, F, offset > make_iterator () const
template<typename U = T, typename F = U, std::size_t offset = 0>
boost::iterator_range< value_iterator< U, F, offset > > make_range () const

Detailed Description

template<typename T, typename D>
class lmdb::value_stream< T, D >

C++ wrapper for a LMDB read-only cursor on a fixed-sized value T.

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

Definition at line 186 of file value_stream.h.

Constructor & Destructor Documentation

◆ value_stream() [1/3]

template<typename T, typename D>
lmdb::value_stream< T, D >::value_stream ( std::unique_ptr< MDB_cursor, D > cur)
inlineexplicit

Take ownership of cur without changing position. nullptr valid.

Definition at line 192 of file value_stream.h.

193 : cur(std::move(cur))
194 {}
Here is the caller graph for this function:

◆ value_stream() [2/3]

template<typename T, typename D>
lmdb::value_stream< T, D >::value_stream ( value_stream< T, D > && )
default
Here is the call graph for this function:

◆ value_stream() [3/3]

template<typename T, typename D>
lmdb::value_stream< T, D >::value_stream ( value_stream< T, D > const & )
delete
Here is the call graph for this function:

◆ ~value_stream()

template<typename T, typename D>
lmdb::value_stream< T, D >::~value_stream ( )
default

Member Function Documentation

◆ count()

template<typename T, typename D>
std::size_t lmdb::value_stream< T, D >::count ( ) const
inline
Exceptions
std::system_errorif LMDB has unexpected errors.
Returns
Number of values at this key.

Definition at line 230 of file value_stream.h.

231 {
232 return lmdb::stream::count(cur.get());
233 }
mdb_size_t count(MDB_cursor *cur)
Here is the call graph for this function:

◆ give_cursor()

template<typename T, typename D>
std::unique_ptr< MDB_cursor, D > lmdb::value_stream< T, D >::give_cursor ( )
inlinenoexcept

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

Returns
Currently owned LMDB cursor.

Definition at line 208 of file value_stream.h.

209 {
210 return {std::move(cur)};
211 }

◆ make_iterator()

template<typename T, typename D>
template<typename U = T, typename F = U, std::size_t offset = 0>
value_iterator< U, F, offset > lmdb::value_stream< T, D >::make_iterator ( ) const
inline

Return a C++ iterator over database values from current cursor position that will reach .is_end() after the last duplicate key record. Calling make_iterator() will return an iterator whose operator* will return entire value (T). make_iterator<ELECTRONEUM_FIELD(account, id)>() will return an iterator whose operator* will return a decltype(account.id) object - the other fields in the struct account are never copied from the database.

Exceptions
std::system_errorif LMDB has unexpected errors.
Returns
C++ iterator starting at current cursor position.

Definition at line 249 of file value_stream.h.

250 {
251 static_assert(std::is_same<U, T>(), "was ELECTRONEUM_FIELD used with wrong type?");
252 return {cur.get()};
253 }
Here is the caller graph for this function:

◆ make_range()

template<typename T, typename D>
template<typename U = T, typename F = U, std::size_t offset = 0>
boost::iterator_range< value_iterator< U, F, offset > > lmdb::value_stream< T, D >::make_range ( ) const
inline

Return a range from current cursor position until last duplicate key record. Useful in for-each range loops or in templated code expecting a range of elements. Calling make_range() will return a range of T objects. make_range<ELECTRONEUM_FIELD(account, id)>() will return a range of decltype(account.id) objects - the other fields in the struct account are never copied from the database.

Exceptions
std::system_errorif LMDB has unexpected errors.
Returns
An InputIterator range over values at cursor position.

Definition at line 267 of file value_stream.h.

268 {
270 }
value_iterator< U, F, offset > make_iterator() const
Here is the call graph for this function:

◆ operator=() [1/2]

template<typename T, typename D>
value_stream & lmdb::value_stream< T, D >::operator= ( value_stream< T, D > && )
default
Here is the call graph for this function:

◆ operator=() [2/2]

template<typename T, typename D>
value_stream & lmdb::value_stream< T, D >::operator= ( value_stream< T, D > const & )
delete
Here is the call graph for this function:

◆ reset()

template<typename T, typename D>
void lmdb::value_stream< T, D >::reset ( )
inline

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

Note
Invalidates all current iterators from this, including those created with make_iterator or make_range.

Definition at line 220 of file value_stream.h.

221 {
222 if (cur)
223 lmdb::stream::get(*cur, MDB_FIRST_DUP, 0, 0);
224 }
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:
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/src/lmdb/value_stream.h