Loading...
Searching...
No Matches
lmdb::cursor Class Reference

Resource class for `MDB_cursor*` handles. More...

`#include <lmdb++.h>`

## Public Member Functions

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

## Static Public Member Functions

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

## 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

## cursor() [1/2]

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

inline noexcept

Constructor.

Parameters

  handle | a valid `MDB_cursor*` handle

## cursor() [2/2]

lmdb::cursor::cursor | ( | cursor && | other | ) |

inline noexcept

Move constructor.

## ~cursor()

lmdb::cursor::~cursor | ( |  | ) |

inline noexcept

Destructor.

## Member Function Documentation

## close()

void lmdb::cursor::close | ( |  | ) |

inline noexcept

Closes this cursor.

Note
  this method is idempotent

Postcondition
  `handle() == nullptr`

## dbi()

MDB_dbi lmdb::cursor::dbi | ( |  | ) | const

inline noexcept

Returns the cursor's database handle.

## find()

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::error | on failure

## get() [1/5]

bool lmdb::cursor::get | ( | lmdb::val & | key,
|  | const MDB_cursor_op | op
| ) |  |

inline

Retrieves a key from the database.

Parameters

  key |
  op |

Exceptions

  lmdb::error | on failure

## get() [2/5]

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::error | on failure

## get() [3/5]

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::error | on failure

## get() [4/5]

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::error | on failure

## get() [5/5]

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::error | on failure

## handle()

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

inline noexcept

Returns the underlying `MDB_cursor*` handle.

## open()

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

inline static

Creates an LMDB cursor.

Parameters

  txn | the transaction handle
  dbi | the database handle

Exceptions

  lmdb::error | on failure

## operator MDB_cursor *()

lmdb::cursor::operator MDB_cursor * | ( |  | ) | const

inline noexcept

Returns the underlying `MDB_cursor*` handle.

## operator=()

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

inline noexcept

Move assignment operator.

## renew()

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

inline

Renews this cursor.

Parameters

  txn | the transaction scope

Exceptions

  lmdb::error | on failure

## txn()

MDB_txn * lmdb::cursor::txn | ( |  | ) | const

inline noexcept

Returns the cursor's transaction handle.

## Member Data Documentation

## _handle

MDB_cursor* lmdb::cursor::_handle {nullptr}

protected

## default_flags

constexpr unsigned int lmdb::cursor::default_flags = 0

static constexpr

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

- lmdb++.h