lmdb++
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
lmdb::cursor Class Reference

Resource class for MDB_cursor* handles. More...

#include <lmdb++.h>

Public Member Functions

 cursor (MDB_cursor *const handle) noexcept
 Constructor. More...
 
 cursor (cursor &&other) noexcept
 Move constructor. More...
 
cursoroperator= (cursor &&other) noexcept
 Move assignment operator. More...
 
 ~cursor () noexcept
 Destructor. More...
 
 operator MDB_cursor * () const noexcept
 Returns the underlying MDB_cursor* handle. More...
 
MDB_cursor * handle () const noexcept
 Returns the underlying MDB_cursor* handle. More...
 
void close () noexcept
 Closes this cursor. More...
 
void renew (MDB_txn *const txn)
 Renews this cursor. More...
 
MDB_txn * txn () const noexcept
 Returns the cursor's transaction handle. More...
 
MDB_dbi dbi () const noexcept
 Returns the cursor's database handle. More...
 
bool get (MDB_val *const key, const MDB_cursor_op op)
 Retrieves a key from the database. More...
 
bool get (lmdb::val &key, const MDB_cursor_op op)
 Retrieves a key from the database. More...
 
bool get (MDB_val *const key, MDB_val *const val, const MDB_cursor_op op)
 Retrieves a key/value pair from the database. More...
 
bool get (lmdb::val &key, lmdb::val &val, const MDB_cursor_op op)
 Retrieves a key/value pair from the database. More...
 
bool get (std::string &key, std::string &val, const MDB_cursor_op op)
 Retrieves a key/value pair from the database. More...
 
template<typename K >
bool find (const K &key, const MDB_cursor_op op=MDB_SET)
 Positions this cursor at the given key. More...
 

Static Public Member Functions

static cursor open (MDB_txn *const txn, const MDB_dbi dbi)
 Creates an LMDB cursor. More...
 

Static Public Attributes

static constexpr unsigned int default_flags = 0
 

Protected Attributes

MDB_cursor * _handle {nullptr}
 

Detailed Description

Resource class for MDB_cursor* handles.

Note
Instances of this class are movable, but not copyable.
See also
http://symas.com/mdb/doc/group__internal.html#structMDB__cursor

Constructor & Destructor Documentation

lmdb::cursor::cursor ( MDB_cursor *const  handle)
inlinenoexcept

Constructor.

Parameters
handlea valid MDB_cursor* handle
lmdb::cursor::cursor ( cursor &&  other)
inlinenoexcept

Move constructor.

lmdb::cursor::~cursor ( )
inlinenoexcept

Destructor.

Member Function Documentation

void lmdb::cursor::close ( )
inlinenoexcept

Closes this cursor.

Note
this method is idempotent
Postcondition
handle() == nullptr
MDB_dbi lmdb::cursor::dbi ( ) const
inlinenoexcept

Returns the cursor's database handle.

template<typename K >
bool lmdb::cursor::find ( const K &  key,
const MDB_cursor_op  op = MDB_SET 
)
inline

Positions this cursor at the given key.

Parameters
key
op
Exceptions
lmdb::erroron failure
bool lmdb::cursor::get ( MDB_val *const  key,
const MDB_cursor_op  op 
)
inline

Retrieves a key from the database.

Parameters
key
op
Exceptions
lmdb::erroron failure
bool lmdb::cursor::get ( lmdb::val key,
const MDB_cursor_op  op 
)
inline

Retrieves a key from the database.

Parameters
key
op
Exceptions
lmdb::erroron failure
bool lmdb::cursor::get ( MDB_val *const  key,
MDB_val *const  val,
const MDB_cursor_op  op 
)
inline

Retrieves a key/value pair from the database.

Parameters
key
val(may be nullptr)
op
Exceptions
lmdb::erroron failure
bool lmdb::cursor::get ( lmdb::val key,
lmdb::val val,
const MDB_cursor_op  op 
)
inline

Retrieves a key/value pair from the database.

Parameters
key
val
op
Exceptions
lmdb::erroron failure
bool lmdb::cursor::get ( std::string &  key,
std::string &  val,
const MDB_cursor_op  op 
)
inline

Retrieves a key/value pair from the database.

Parameters
key
val
op
Exceptions
lmdb::erroron failure
MDB_cursor* lmdb::cursor::handle ( ) const
inlinenoexcept

Returns the underlying MDB_cursor* handle.

static cursor lmdb::cursor::open ( MDB_txn *const  txn,
const MDB_dbi  dbi 
)
inlinestatic

Creates an LMDB cursor.

Parameters
txnthe transaction handle
dbithe database handle
Exceptions
lmdb::erroron failure
lmdb::cursor::operator MDB_cursor * ( ) const
inlinenoexcept

Returns the underlying MDB_cursor* handle.

cursor& lmdb::cursor::operator= ( cursor &&  other)
inlinenoexcept

Move assignment operator.

void lmdb::cursor::renew ( MDB_txn *const  txn)
inline

Renews this cursor.

Parameters
txnthe transaction scope
Exceptions
lmdb::erroron failure
MDB_txn* lmdb::cursor::txn ( ) const
inlinenoexcept

Returns the cursor's transaction handle.

Member Data Documentation

MDB_cursor* lmdb::cursor::_handle {nullptr}
protected
constexpr unsigned int lmdb::cursor::default_flags = 0
static

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