licensing, initial documentation initiative
This commit is contained in:
parent
f5612dc3c5
commit
763d956bf8
30 changed files with 1178 additions and 383 deletions
39
src/base.cpp
39
src/base.cpp
|
@ -1,18 +1,20 @@
|
|||
// Squawk messenger.
|
||||
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/*
|
||||
* LMDB Abstraction Layer.
|
||||
* Copyright (C) 2023 Yury Gubich <blue@macaw.me>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "base.h"
|
||||
#include "exceptions.h"
|
||||
|
@ -38,15 +40,22 @@ LMDBAL::Base::~Base() {
|
|||
|
||||
void LMDBAL::Base::close() {
|
||||
if (opened) {
|
||||
for (LMDBAL::TransactionID id : *transactions)
|
||||
mdb_txn_abort(id);
|
||||
|
||||
for (const std::pair<const std::string, iStorage*>& pair : tables) {
|
||||
iStorage* table = pair.second;
|
||||
mdb_dbi_close(environment, table->dbi);
|
||||
}
|
||||
mdb_env_close(environment);
|
||||
transactions->clear();
|
||||
opened = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Almost every LMDBAL::Base require it to be opened, this function opens it. It laso creates the directory for the database if it was an initial launch
|
||||
*/
|
||||
void LMDBAL::Base::open() {
|
||||
if (!opened) {
|
||||
mdb_env_create(&environment);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue