libmdbx  0.11.6.39 (2022-04-13T11:05:50+03:00)
One of the fastest compact embeddable key-value ACID database without WAL.
mdbx::cursor Class Reference

Unmanaged cursor. More...

#include <mdbx.h++>

Inherited by mdbx::cursor_managed.

Classes

struct  move_result
 

Public Types

enum  move_operation {
  first = MDBX_FIRST, last = MDBX_LAST, next = MDBX_NEXT, previous = MDBX_PREV,
  get_current = MDBX_GET_CURRENT, multi_prevkey_lastvalue = MDBX_PREV_NODUP, multi_currentkey_firstvalue = MDBX_FIRST_DUP, multi_currentkey_prevvalue = MDBX_PREV_DUP,
  multi_currentkey_nextvalue = MDBX_NEXT_DUP, multi_currentkey_lastvalue = MDBX_LAST_DUP, multi_nextkey_firstvalue = MDBX_NEXT_NODUP, multi_find_pair = MDBX_GET_BOTH,
  multi_exactkey_lowerboundvalue = MDBX_GET_BOTH_RANGE, find_key = MDBX_SET, key_exact = MDBX_SET_KEY, key_lowerbound = MDBX_SET_RANGE
}
 

Public Member Functions

MDBX_CXX11_CONSTEXPR cursor () noexcept=default
 
 cursor (const cursor &) noexcept=default
 
cursoroperator= (cursor &&other) noexcept
 
 cursor (cursor &&other) noexcept
 
 ~cursor () noexcept
 
MDBX_CXX14_CONSTEXPR operator bool () const noexcept
 
MDBX_CXX14_CONSTEXPR operator const MDBX_cursor * () const
 
MDBX_CXX14_CONSTEXPR operator MDBX_cursor * ()
 
move_result move (move_operation operation, bool throw_notfound)
 
move_result to_first (bool throw_notfound=true)
 
move_result to_previous (bool throw_notfound=true)
 
move_result to_previous_last_multi (bool throw_notfound=true)
 
move_result to_current_first_multi (bool throw_notfound=true)
 
move_result to_current_prev_multi (bool throw_notfound=true)
 
move_result current (bool throw_notfound=true) const
 
move_result to_current_next_multi (bool throw_notfound=true)
 
move_result to_current_last_multi (bool throw_notfound=true)
 
move_result to_next_first_multi (bool throw_notfound=true)
 
move_result to_next (bool throw_notfound=true)
 
move_result to_last (bool throw_notfound=true)
 
move_result move (move_operation operation, const slice &key, bool throw_notfound)
 
move_result find (const slice &key, bool throw_notfound=true)
 
move_result lower_bound (const slice &key, bool throw_notfound=true)
 
move_result move (move_operation operation, const slice &key, const slice &value, bool throw_notfound)
 
move_result find_multivalue (const slice &key, const slice &value, bool throw_notfound=true)
 
move_result lower_bound_multivalue (const slice &key, const slice &value, bool throw_notfound=false)
 
bool seek (const slice &key)
 
bool move (move_operation operation, slice &key, slice &value, bool throw_notfound)
 
size_t count_multivalue () const
 Return count of duplicates for current key. More...
 
bool eof () const
 
bool on_first () const
 
bool on_last () const
 
ptrdiff_t estimate (slice key, slice value) const
 
ptrdiff_t estimate (slice key) const
 
ptrdiff_t estimate (move_operation operation) const
 
void renew (::mdbx::txn &txn)
 Renew/bind a cursor with a new transaction and previously used key-value map handle. More...
 
void bind (::mdbx::txn &txn, ::mdbx::map_handle map_handle)
 Bind/renew a cursor with a new transaction and specified key-value map handle. More...
 
inline ::mdbx::txn txn () const
 Returns the cursor's transaction. More...
 
map_handle map () const
 
 operator::mdbx::txn () const
 
 operator::mdbx::map_handle () const
 
MDBX_error_t put (const slice &key, slice *value, MDBX_put_flags_t flags) noexcept
 
void insert (const slice &key, slice value)
 
value_result try_insert (const slice &key, slice value)
 
slice insert_reserve (const slice &key, size_t value_length)
 
value_result try_insert_reserve (const slice &key, size_t value_length)
 
void upsert (const slice &key, const slice &value)
 
slice upsert_reserve (const slice &key, size_t value_length)
 
void update (const slice &key, const slice &value)
 
bool try_update (const slice &key, const slice &value)
 
slice update_reserve (const slice &key, size_t value_length)
 
value_result try_update_reserve (const slice &key, size_t value_length)
 
bool erase (bool whole_multivalue=false)
 Removes single key-value pair or all multi-values at the current cursor position. More...
 
bool erase (const slice &key, bool whole_multivalue=true)
 Seeks and removes first value or whole multi-value of the given key. More...
 
bool erase (const slice &key, const slice &value)
 Seeks and removes the particular multi-value entry of the key. More...
 

Protected Member Functions

MDBX_CXX11_CONSTEXPR cursor (MDBX_cursor *ptr) noexcept
 
bool move (move_operation operation, MDBX_val *key, MDBX_val *value, bool throw_notfound) const
 
ptrdiff_t estimate (move_operation operation, MDBX_val *key, MDBX_val *value) const
 

Protected Attributes

MDBX_cursorhandle_ {nullptr}
 

Friends

MDBX_CXX11_CONSTEXPR bool operator== (const cursor &a, const cursor &b) noexcept
 
MDBX_CXX11_CONSTEXPR bool operator!= (const cursor &a, const cursor &b) noexcept
 

Detailed Description

Unmanaged cursor.

Like other unmanaged classes, cursor allows copying and assignment for instances, but does not destroys the represented underlying object from the own class destructor.

See also
mdbx_cursor_create()
mdbx_cursor_bind()
mdbx_cursor_close()

Member Enumeration Documentation

◆ move_operation

Enumerator
first 
last 
next 
previous 
get_current 
multi_prevkey_lastvalue 
multi_currentkey_firstvalue 
multi_currentkey_prevvalue 
multi_currentkey_nextvalue 
multi_currentkey_lastvalue 
multi_nextkey_firstvalue 
multi_find_pair 
multi_exactkey_lowerboundvalue 
find_key 
key_exact 
key_lowerbound 

Constructor & Destructor Documentation

◆ cursor() [1/4]

MDBX_CXX11_CONSTEXPR mdbx::cursor::cursor ( MDBX_cursor ptr)
protectednoexcept

◆ cursor() [2/4]

MDBX_CXX11_CONSTEXPR mdbx::cursor::cursor ( )
defaultnoexcept

◆ cursor() [3/4]

mdbx::cursor::cursor ( const cursor )
defaultnoexcept

◆ cursor() [4/4]

mdbx::cursor::cursor ( cursor &&  other)
inlinenoexcept

◆ ~cursor()

mdbx::cursor::~cursor ( )
inlinenoexcept

Member Function Documentation

◆ bind()

void mdbx::cursor::bind ( ::mdbx::txn txn,
::mdbx::map_handle  map_handle 
)
inline

Bind/renew a cursor with a new transaction and specified key-value map handle.

◆ count_multivalue()

size_t mdbx::cursor::count_multivalue ( ) const
inline

Return count of duplicates for current key.

◆ current()

cursor::move_result mdbx::cursor::current ( bool  throw_notfound = true) const
inline

◆ eof()

bool mdbx::cursor::eof ( ) const
inline

◆ erase() [1/3]

bool mdbx::cursor::erase ( bool  whole_multivalue = false)
inline

Removes single key-value pair or all multi-values at the current cursor position.

◆ erase() [2/3]

bool mdbx::cursor::erase ( const slice key,
bool  whole_multivalue = true 
)
inline

Seeks and removes first value or whole multi-value of the given key.

Returns
True if the key is found and a value(s) is removed.

◆ erase() [3/3]

bool mdbx::cursor::erase ( const slice key,
const slice value 
)
inline

Seeks and removes the particular multi-value entry of the key.

Returns
True if the given key-value pair is found and removed.

◆ estimate() [1/4]

ptrdiff_t mdbx::cursor::estimate ( move_operation  operation) const
inline

◆ estimate() [2/4]

ptrdiff_t mdbx::cursor::estimate ( move_operation  operation,
MDBX_val key,
MDBX_val value 
) const
inlineprotected

◆ estimate() [3/4]

ptrdiff_t mdbx::cursor::estimate ( slice  key) const
inline

◆ estimate() [4/4]

ptrdiff_t mdbx::cursor::estimate ( slice  key,
slice  value 
) const
inline

◆ find()

cursor::move_result mdbx::cursor::find ( const slice key,
bool  throw_notfound = true 
)
inline

◆ find_multivalue()

cursor::move_result mdbx::cursor::find_multivalue ( const slice key,
const slice value,
bool  throw_notfound = true 
)
inline

◆ insert()

void mdbx::cursor::insert ( const slice key,
slice  value 
)
inline

◆ insert_reserve()

slice mdbx::cursor::insert_reserve ( const slice key,
size_t  value_length 
)
inline

◆ lower_bound()

cursor::move_result mdbx::cursor::lower_bound ( const slice key,
bool  throw_notfound = true 
)
inline

◆ lower_bound_multivalue()

cursor::move_result mdbx::cursor::lower_bound_multivalue ( const slice key,
const slice value,
bool  throw_notfound = false 
)
inline

◆ map()

map_handle mdbx::cursor::map ( ) const
inline

◆ move() [1/5]

cursor::move_result mdbx::cursor::move ( move_operation  operation,
bool  throw_notfound 
)
inline

◆ move() [2/5]

cursor::move_result mdbx::cursor::move ( move_operation  operation,
const slice key,
bool  throw_notfound 
)
inline

◆ move() [3/5]

cursor::move_result mdbx::cursor::move ( move_operation  operation,
const slice key,
const slice value,
bool  throw_notfound 
)
inline

◆ move() [4/5]

bool mdbx::cursor::move ( move_operation  operation,
MDBX_val key,
MDBX_val value,
bool  throw_notfound 
) const
inlineprotected

◆ move() [5/5]

bool mdbx::cursor::move ( move_operation  operation,
slice key,
slice value,
bool  throw_notfound 
)
inline

◆ on_first()

bool mdbx::cursor::on_first ( ) const
inline

◆ on_last()

bool mdbx::cursor::on_last ( ) const
inline

◆ operator bool()

MDBX_CXX14_CONSTEXPR mdbx::cursor::operator bool ( ) const
noexcept

◆ operator const MDBX_cursor *()

MDBX_CXX14_CONSTEXPR mdbx::cursor::operator const MDBX_cursor * ( ) const

◆ operator MDBX_cursor *()

MDBX_CXX14_CONSTEXPR mdbx::cursor::operator MDBX_cursor * ( )

◆ operator::mdbx::map_handle()

mdbx::cursor::operator::mdbx::map_handle ( ) const
inline

◆ operator::mdbx::txn()

mdbx::cursor::operator::mdbx::txn ( ) const
inline

◆ operator=()

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

◆ put()

MDBX_error_t mdbx::cursor::put ( const slice key,
slice value,
MDBX_put_flags_t  flags 
)
inlinenoexcept

◆ renew()

void mdbx::cursor::renew ( ::mdbx::txn txn)
inline

Renew/bind a cursor with a new transaction and previously used key-value map handle.

◆ seek()

bool mdbx::cursor::seek ( const slice key)
inline

◆ to_current_first_multi()

cursor::move_result mdbx::cursor::to_current_first_multi ( bool  throw_notfound = true)
inline

◆ to_current_last_multi()

cursor::move_result mdbx::cursor::to_current_last_multi ( bool  throw_notfound = true)
inline

◆ to_current_next_multi()

cursor::move_result mdbx::cursor::to_current_next_multi ( bool  throw_notfound = true)
inline

◆ to_current_prev_multi()

cursor::move_result mdbx::cursor::to_current_prev_multi ( bool  throw_notfound = true)
inline

◆ to_first()

cursor::move_result mdbx::cursor::to_first ( bool  throw_notfound = true)
inline

◆ to_last()

cursor::move_result mdbx::cursor::to_last ( bool  throw_notfound = true)
inline

◆ to_next()

cursor::move_result mdbx::cursor::to_next ( bool  throw_notfound = true)
inline

◆ to_next_first_multi()

cursor::move_result mdbx::cursor::to_next_first_multi ( bool  throw_notfound = true)
inline

◆ to_previous()

cursor::move_result mdbx::cursor::to_previous ( bool  throw_notfound = true)
inline

◆ to_previous_last_multi()

cursor::move_result mdbx::cursor::to_previous_last_multi ( bool  throw_notfound = true)
inline

◆ try_insert()

value_result mdbx::cursor::try_insert ( const slice key,
slice  value 
)
inline

◆ try_insert_reserve()

value_result mdbx::cursor::try_insert_reserve ( const slice key,
size_t  value_length 
)
inline

◆ try_update()

bool mdbx::cursor::try_update ( const slice key,
const slice value 
)
inline

◆ try_update_reserve()

value_result mdbx::cursor::try_update_reserve ( const slice key,
size_t  value_length 
)
inline

◆ txn()

txn mdbx::cursor::txn ( ) const
inline

Returns the cursor's transaction.

◆ update()

void mdbx::cursor::update ( const slice key,
const slice value 
)
inline

◆ update_reserve()

slice mdbx::cursor::update_reserve ( const slice key,
size_t  value_length 
)
inline

◆ upsert()

void mdbx::cursor::upsert ( const slice key,
const slice value 
)
inline

◆ upsert_reserve()

slice mdbx::cursor::upsert_reserve ( const slice key,
size_t  value_length 
)
inline

Friends And Related Function Documentation

◆ operator!=

MDBX_CXX11_CONSTEXPR bool operator!= ( const cursor a,
const cursor b 
)
friend

◆ operator==

MDBX_CXX11_CONSTEXPR bool operator== ( const cursor a,
const cursor b 
)
friend

Member Data Documentation

◆ handle_

MDBX_cursor* mdbx::cursor::handle_ {nullptr}
protected

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