Electroneum
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 {
32  {
33  ELECTRONEUM_PRECOND(name != nullptr);
34 
35  MDB_dbi out;
37  if (key_cmp && !(flags & MDB_INTEGERKEY))
39  if (value_cmp && !(flags & MDB_INTEGERDUP))
41  return out;
42  }
43 }
int mdb_dbi_open(MDB_txn *txn, const char *name, unsigned int flags, MDB_dbi *dbi)
Open a database in the environment.
#define ELECTRONEUM_LMDB_CHECK(...)
Executes a LMDB command, and returns errors via lmdb::error enum.
Definition: error.h:33
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.
std::unique_ptr< MDB_txn, abort_write_txn > write_txn
Definition: transaction.h:94
const char * name
struct MDB_txn MDB_txn
Opaque structure for a transaction handle.
Definition: lmdb.h:267
#define MDB_INTEGERDUP
Definition: lmdb.h:353
Definition: expect.h:70
#define MDB_INTEGERKEY
Definition: lmdb.h:349
int mdb_set_compare(MDB_txn *txn, MDB_dbi dbi, MDB_cmp_func *cmp)
Set a custom key comparison function for a database.
unsigned int MDB_dbi
A handle for an individual database in the DB environment.
Definition: lmdb.h:270
#define ELECTRONEUM_PRECOND(...)
If precondition fails, return ::error::kInvalidArgument in current scope.
Definition: expect.h:39
expect< MDB_dbi > open(MDB_txn &write_txn) const noexcept
Definition: table.cpp:31