Electroneum
Toggle main menu visibility
Loading...
Searching...
No Matches
table.cpp
Go to the documentation of this file.
1
// Copyright (c) 2018, The Monero Project
2
// All rights reserved.
3
//
4
// Redistribution and use in source and binary forms, with or without modification, are
5
// permitted provided that the following conditions are met:
6
//
7
// 1. Redistributions of source code must retain the above copyright notice, this list of
8
// conditions and the following disclaimer.
9
//
10
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
11
// of conditions and the following disclaimer in the documentation and/or other
12
// materials provided with the distribution.
13
//
14
// 3. Neither the name of the copyright holder nor the names of its contributors may be
15
// used to endorse or promote products derived from this software without specific
16
// prior written permission.
17
//
18
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
19
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
26
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
#include "
table.h
"
28
29
namespace
lmdb
30
{
31
expect<MDB_dbi>
table::open
(
MDB_txn
&
write_txn
)
const
noexcept
32
{
33
ELECTRONEUM_PRECOND
(
name
!=
nullptr
);
34
35
MDB_dbi
out;
36
ELECTRONEUM_LMDB_CHECK
(
mdb_dbi_open
(&
write_txn
,
name
,
flags
, &out));
37
if
(
key_cmp
&& !(
flags
&
MDB_INTEGERKEY
))
38
ELECTRONEUM_LMDB_CHECK
(
mdb_set_compare
(&
write_txn
, out,
key_cmp
));
39
if
(
value_cmp
&& !(
flags
&
MDB_INTEGERDUP
))
40
ELECTRONEUM_LMDB_CHECK
(
mdb_set_dupsort
(&
write_txn
, out,
value_cmp
));
41
return
out;
42
}
43
}
expect
Definition
expect.h:133
ELECTRONEUM_PRECOND
#define ELECTRONEUM_PRECOND(...)
If precondition fails, return error::kInvalidArgument in current scope.
Definition
expect.h:39
mdb_set_compare
int mdb_set_compare(MDB_txn *txn, MDB_dbi dbi, MDB_cmp_func *cmp)
Set a custom key comparison function for a database.
mdb_dbi_open
int mdb_dbi_open(MDB_txn *txn, const char *name, unsigned int flags, MDB_dbi *dbi)
Open a database in the environment.
mdb_set_dupsort
int mdb_set_dupsort(MDB_txn *txn, MDB_dbi dbi, MDB_cmp_func *cmp)
Set a custom data comparison function for a MDB_DUPSORT database.
MDB_INTEGERKEY
#define MDB_INTEGERKEY
Definition
lmdb.h:349
MDB_INTEGERDUP
#define MDB_INTEGERDUP
Definition
lmdb.h:353
MDB_txn
struct MDB_txn MDB_txn
Opaque structure for a transaction handle.
Definition
lmdb.h:267
MDB_dbi
unsigned int MDB_dbi
A handle for an individual database in the DB environment.
Definition
lmdb.h:270
lmdb
Definition
database.cpp:46
lmdb::write_txn
std::unique_ptr< MDB_txn, abort_write_txn > write_txn
Definition
transaction.h:94
ELECTRONEUM_LMDB_CHECK
#define ELECTRONEUM_LMDB_CHECK(...)
Executes a LMDB command, and returns errors via lmdb::error enum.
Definition
error.h:33
lmdb::table::open
expect< MDB_dbi > open(MDB_txn &write_txn) const noexcept
Definition
table.cpp:31
lmdb::table::flags
const unsigned flags
Definition
table.h:17
lmdb::table::value_cmp
MDB_cmp_func *const value_cmp
Definition
table.h:19
lmdb::table::name
char const *const name
Definition
table.h:16
lmdb::table::key_cmp
MDB_cmp_func *const key_cmp
Definition
table.h:18
table.h
src
lmdb
table.cpp
Generated on
for Electroneum by
1.17.0