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

Resource class for `MDB_dbi` handles. More...

`#include <lmdb++.h>`

## Public Member Functions

| dbi (const MDB_dbi handle) noexcept
| Constructor.
| dbi (dbi &&other) noexcept
| Move constructor.
dbi & | operator= (dbi &&other) noexcept
| Move assignment operator.
| ~dbi () noexcept
| Destructor.
| operator MDB_dbi () const noexcept
| Returns the underlying `MDB_dbi` handle.
MDB_dbi | handle () const noexcept
| Returns the underlying `MDB_dbi` handle.
MDB_stat | stat (MDB_txn *const txn) const
| Returns statistics for this database.
unsigned int | flags (MDB_txn *const txn) const
| Retrieves the flags for this database handle.
std::size_t | size (MDB_txn *const txn) const
| Returns the number of records in this database.
void | drop (MDB_txn *const txn, const bool del=false)
dbi & | set_compare (MDB_txn *const txn, MDB_cmp_func *const cmp=nullptr)
| Sets a custom key comparison function for this database.
bool | get (MDB_txn *const txn, const val &key, val &data)
| Retrieves a key/value pair from this database.
template<typename K >
bool | get (MDB_txn *const txn, const K &key) const
| Retrieves a key from this database.
template<typename K , typename V >
bool | get (MDB_txn *const txn, const K &key, V &val) const
| Retrieves a key/value pair from this database.
template<typename V >
bool | get (MDB_txn *const txn, const char *const key, V &val) const
| Retrieves a key/value pair from this database.
bool | put (MDB_txn *const txn, const val &key, val &data, const unsigned int flags=default_put_flags)
| Stores a key/value pair into this database.
template<typename K >
bool | put (MDB_txn *const txn, const K &key, const unsigned int flags=default_put_flags)
| Stores a key into this database.
template<typename K , typename V >
bool | put (MDB_txn *const txn, const K &key, const V &val, const unsigned int flags=default_put_flags)
| Stores a key/value pair into this database.
template<typename V >
bool | put (MDB_txn *const txn, const char *const key, const V &val, const unsigned int flags=default_put_flags)
| Stores a key/value pair into this database.
bool | put (MDB_txn *const txn, const char *const key, const char *const val, const unsigned int flags=default_put_flags)
| Stores a key/value pair into this database.
bool | del (MDB_txn *const txn, const val &key)
| Removes a key/value pair from this database.
template<typename K >
bool | del (MDB_txn *const txn, const K &key)
| Removes a key/value pair from this database.

## Static Public Member Functions

static dbi | open (MDB_txn *const txn, const char *const name=nullptr, const unsigned int flags=default_flags)
| Opens a database handle.

## Static Public Attributes

static constexpr unsigned int | default_flags = 0
static constexpr unsigned int | default_put_flags = 0

## Protected Attributes

MDB_dbi | _handle {0}

## Detailed Description

Resource class for `MDB_dbi` handles.

Note
  Instances of this class are movable, but not copyable.

See also
  http://symas.com/mdb/doc/group__mdb.html#gadbe68a06c448dfb62da16443d251a78b

## Constructor & Destructor Documentation

## dbi() [1/2]

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

inline noexcept

Constructor.

Parameters

  handle | a valid `MDB_dbi` handle

## dbi() [2/2]

lmdb::dbi::dbi | ( | dbi && | other | ) |

inline noexcept

Move constructor.

## ~dbi()

lmdb::dbi::~dbi | ( |  | ) |

inline noexcept

Destructor.

## Member Function Documentation

## del() [1/2]

template<typename K >

bool lmdb::dbi::del | ( | MDB_txn *const | txn,
|  | const K & | key
| ) |  |

inline

Removes a key/value pair from this database.

Parameters

  txn | a transaction handle
  key |

Exceptions

  lmdb::error | on failure

## del() [2/2]

bool lmdb::dbi::del | ( | MDB_txn *const | txn,
|  | const val & | key
| ) |  |

inline

Removes a key/value pair from this database.

Parameters

  txn | a transaction handle
  key |

Exceptions

  lmdb::error | on failure

## drop()

void lmdb::dbi::drop | ( | MDB_txn *const | txn,
|  | const bool | del = `false`
| ) |  |

inline

Parameters

  txn | a transaction handle
  del |

Exceptions

  lmdb::error | on failure

## flags()

unsigned int lmdb::dbi::flags | ( | MDB_txn *const | txn | ) | const

inline

Retrieves the flags for this database handle.

Parameters

  txn | a transaction handle

Exceptions

  lmdb::error | on failure

## get() [1/4]

template<typename V >

bool lmdb::dbi::get | ( | MDB_txn *const | txn,
|  | const char *const | key,
|  | V & | val
| ) |  | const

inline

Retrieves a key/value pair from this database.

Parameters

  txn | a transaction handle
  key | a NUL-terminated string key
  val |

Exceptions

  lmdb::error | on failure

## get() [2/4]

template<typename K >

bool lmdb::dbi::get | ( | MDB_txn *const | txn,
|  | const K & | key
| ) |  | const

inline

Retrieves a key from this database.

Parameters

  txn | a transaction handle
  key |

Exceptions

  lmdb::error | on failure

## get() [3/4]

template<typename K , typename V >

bool lmdb::dbi::get | ( | MDB_txn *const | txn,
|  | const K & | key,
|  | V & | val
| ) |  | const

inline

Retrieves a key/value pair from this database.

Parameters

  txn | a transaction handle
  key |
  val |

Exceptions

  lmdb::error | on failure

## get() [4/4]

bool lmdb::dbi::get | ( | MDB_txn *const | txn,
|  | const val & | key,
|  | val & | data
| ) |  |

inline

Retrieves a key/value pair from this database.

Parameters

  txn | a transaction handle
  key |
  data |

Exceptions

  lmdb::error | on failure

## handle()

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

inline noexcept

Returns the underlying `MDB_dbi` handle.

## open()

static dbi lmdb::dbi::open | ( | MDB_txn *const | txn,
|  | const char *const | name = `nullptr`,
|  | const unsigned int | flags = `default_flags`
| ) |  |

inline static

Opens a database handle.

Parameters

  txn | the transaction handle
  name |
  flags |

Exceptions

  lmdb::error | on failure

## operator MDB_dbi()

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

inline noexcept

Returns the underlying `MDB_dbi` handle.

## operator=()

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

inline noexcept

Move assignment operator.

## put() [1/5]

bool lmdb::dbi::put | ( | MDB_txn *const | txn,
|  | const char *const | key,
|  | const char *const | val,
|  | const unsigned int | flags = `default_put_flags`
| ) |  |

inline

Stores a key/value pair into this database.

Parameters

  txn | a transaction handle
  key | a NUL-terminated string key
  val | a NUL-terminated string key
  flags |

Exceptions

  lmdb::error | on failure

## put() [2/5]

template<typename V >

bool lmdb::dbi::put | ( | MDB_txn *const | txn,
|  | const char *const | key,
|  | const V & | val,
|  | const unsigned int | flags = `default_put_flags`
| ) |  |

inline

Stores a key/value pair into this database.

Parameters

  txn | a transaction handle
  key | a NUL-terminated string key
  val |
  flags |

Exceptions

  lmdb::error | on failure

## put() [3/5]

template<typename K >

bool lmdb::dbi::put | ( | MDB_txn *const | txn,
|  | const K & | key,
|  | const unsigned int | flags = `default_put_flags`
| ) |  |

inline

Stores a key into this database.

Parameters

  txn | a transaction handle
  key |
  flags |

Exceptions

  lmdb::error | on failure

## put() [4/5]

template<typename K , typename V >

bool lmdb::dbi::put | ( | MDB_txn *const | txn,
|  | const K & | key,
|  | const V & | val,
|  | const unsigned int | flags = `default_put_flags`
| ) |  |

inline

Stores a key/value pair into this database.

Parameters

  txn | a transaction handle
  key |
  val |
  flags |

Exceptions

  lmdb::error | on failure

## put() [5/5]

bool lmdb::dbi::put | ( | MDB_txn *const | txn,
|  | const val & | key,
|  | val & | data,
|  | const unsigned int | flags = `default_put_flags`
| ) |  |

inline

Stores a key/value pair into this database.

Parameters

  txn | a transaction handle
  key |
  data |
  flags |

Exceptions

  lmdb::error | on failure

## set_compare()

dbi & lmdb::dbi::set_compare | ( | MDB_txn *const | txn,
|  | MDB_cmp_func *const | cmp = `nullptr`
| ) |  |

inline

Sets a custom key comparison function for this database.

Parameters

  txn | a transaction handle
  cmp | the comparison function

Exceptions

  lmdb::error | on failure

## size()

std::size_t lmdb::dbi::size | ( | MDB_txn *const | txn | ) | const

inline

Returns the number of records in this database.

Parameters

  txn | a transaction handle

Exceptions

  lmdb::error | on failure

## stat()

MDB_stat lmdb::dbi::stat | ( | MDB_txn *const | txn | ) | const

inline

Returns statistics for this database.

Parameters

  txn | a transaction handle

Exceptions

  lmdb::error | on failure

## Member Data Documentation

## _handle

MDB_dbi lmdb::dbi::_handle {0}

protected

## default_flags

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

static constexpr

## default_put_flags

constexpr unsigned int lmdb::dbi::default_put_flags = 0

static constexpr

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

- lmdb++.h