Electroneum
Namespaces | Classes | Typedefs | Enumerations | Functions
lmdb Namespace Reference

Namespaces

 anonymous_namespace{database.cpp}
 
 stream
 

Classes

struct  close_env
 Closes LMDB environment handle. More...
 
struct  context
 Context given to LMDB. More...
 
class  database
 Manages a LMDB environment for safe memory-map resizing. Thread-safe. More...
 
class  key_iterator
 
class  key_stream
 
struct  table
 Helper for grouping typical LMDB DBI options. More...
 
struct  basic_table
 Helper for grouping typical LMDB DBI options when key and value are fixed types. More...
 
struct  abort_txn
 
struct  release_read_txn
 
struct  abort_write_txn
 
struct  close_cursor
 
struct  identity
 Prevent instantiation of std::underlying_type<T> when T is not enum. More...
 
class  value_iterator
 
class  value_stream
 

Typedefs

using environment = std::unique_ptr< MDB_env, close_env >
 
using suspended_txn = std::unique_ptr< MDB_txn, abort_txn >
 
using read_txn = std::unique_ptr< MDB_txn, release_read_txn >
 
using write_txn = std::unique_ptr< MDB_txn, abort_write_txn >
 
template<typename T >
using native_type = typename std::conditional< std::is_enum< T >::value, std::underlying_type< T >, identity< T > >::type::type
 

Enumerations

enum class  error : int
 Tracks LMDB error codes. More...
 

Functions

expect< environmentopen_environment (const char *path, MDB_dbi max_dbs) noexcept
 
std::error_category const & error_category () noexcept
 
std::error_code make_error_code (error value) noexcept
 
template<typename K , typename V >
bool operator== (key_iterator< K, V > const &lhs, key_iterator< K, V > const &rhs) noexcept
 
template<typename K , typename V >
bool operator!= (key_iterator< K, V > const &lhs, key_iterator< K, V > const &rhs) noexcept
 
template<typename D >
expect< std::unique_ptr< MDB_cursor, D > > open_cursor (MDB_txn &txn, MDB_dbi tbl) noexcept
 
template<typename T , typename U = typename std::underlying_type<T>::type>
constexpr U to_native (T value) noexcept
 
template<typename T >
MDB_val to_val (T &&value) noexcept
 
constexpr epee::span< const std::uint8_t > to_byte_span (MDB_val value) noexcept
 
template<typename T , std::size_t offset = 0>
int less (MDB_val const *left, MDB_val const *right) noexcept
 
template<typename T , std::size_t offset = 0>
int compare (MDB_val const *left, MDB_val const *right) noexcept
 
template<typename T , typename F , std::size_t offset>
bool operator== (value_iterator< T, F, offset > const &lhs, value_iterator< T, F, offset > const &rhs) noexcept
 
template<typename T , typename F , std::size_t offset>
bool operator!= (value_iterator< T, F, offset > const &lhs, value_iterator< T, F, offset > const &rhs) noexcept
 

Typedef Documentation

◆ environment

using lmdb::environment = typedef std::unique_ptr<MDB_env, close_env>

◆ native_type

template<typename T >
using lmdb::native_type = typedef typename std::conditional< std::is_enum<T>::value, std::underlying_type<T>, identity<T> >::type::type

Get the native type for enums, or return T unchanged. Useful for merging generated machine code for templated functions that use enums with identical size-widths without relying on aggressive identical comdat folding (ICF) support in linker. So with enum defintion enum class enum_foo : unsigned long {}; will always yield assert(&func_foo<unsigned long> == &func_foo<native_type<enum_foo>>).

◆ read_txn

using lmdb::read_txn = typedef std::unique_ptr<MDB_txn, release_read_txn>

◆ suspended_txn

using lmdb::suspended_txn = typedef std::unique_ptr<MDB_txn, abort_txn>

◆ write_txn

using lmdb::write_txn = typedef std::unique_ptr<MDB_txn, abort_write_txn>

Enumeration Type Documentation

◆ error

enum lmdb::error : int
strong

Tracks LMDB error codes.

Function Documentation

◆ compare()

template<typename T , std::size_t offset = 0>
int lmdb::compare ( MDB_val const *  left,
MDB_val const *  right 
)
inlinenoexcept

A LMDB comparison function that uses std::memcmp.

\toaram T is !epee::has_padding

Template Parameters
offsetto T within the value.
Returns
The result of std::memcmp over the value.

◆ error_category()

std::error_category const & lmdb::error_category ( )
noexcept

◆ less()

template<typename T , std::size_t offset = 0>
int lmdb::less ( MDB_val const *  left,
MDB_val const *  right 
)
inlinenoexcept

A LMDB comparison function that uses operator<.

Template Parameters
Thas a defined operator< .
offsetto T within the value.
Returns
-1 if left < right, 1 if right < left, and 0 otherwise.

◆ make_error_code()

std::error_code lmdb::make_error_code ( error  value)
inlinenoexcept

◆ open_cursor()

template<typename D >
expect<std::unique_ptr<MDB_cursor, D> > lmdb::open_cursor ( MDB_txn &  txn,
MDB_dbi  tbl 
)
inlinenoexcept

◆ open_environment()

expect< environment > lmdb::open_environment ( const char *  path,
MDB_dbi  max_dbs 
)
noexcept
Returns
LMDB environment at path with a max of max_dbs tables.

◆ operator!=() [1/2]

template<typename K , typename V >
bool lmdb::operator!= ( key_iterator< K, V > const &  lhs,
key_iterator< K, V > const &  rhs 
)
inlinenoexcept

◆ operator!=() [2/2]

template<typename T , typename F , std::size_t offset>
bool lmdb::operator!= ( value_iterator< T, F, offset > const &  lhs,
value_iterator< T, F, offset > const &  rhs 
)
inlinenoexcept

◆ operator==() [1/2]

template<typename K , typename V >
bool lmdb::operator== ( key_iterator< K, V > const &  lhs,
key_iterator< K, V > const &  rhs 
)
inlinenoexcept

◆ operator==() [2/2]

template<typename T , typename F , std::size_t offset>
bool lmdb::operator== ( value_iterator< T, F, offset > const &  lhs,
value_iterator< T, F, offset > const &  rhs 
)
inlinenoexcept

◆ to_byte_span()

constexpr epee::span<const std::uint8_t> lmdb::to_byte_span ( MDB_val  value)
inlineconstexprnoexcept
Returns
A span over the same chunk of memory as value.

◆ to_native()

template<typename T , typename U = typename std::underlying_type<T>::type>
constexpr U lmdb::to_native ( T  value)
inlineconstexprnoexcept
Returns
value as its native type.

◆ to_val()

template<typename T >
MDB_val lmdb::to_val ( T &&  value)
inlinenoexcept
Returns
value bytes in a LMDB MDB_val object.