qbolt/qbolt/boltdb.cpp

34 lines
714 B
C++

#include "boltdb.h"
BoltDB::BoltDB()
{
}
BoltDB* BoltDB::createFrom(QString filePath, QString &errorOut)
{
auto opts = Bolt_Options_New_Readonly();
QByteArray filePathBytes(filePath.toUtf8());
GoString filePathGS = Interop::toGoString_WeakRef(&filePathBytes);
auto open_ret = Bolt_Open(filePathGS, 0444, opts);
if (open_ret.r1.v != nullptr) {
errorOut = Interop::GetError(open_ret.r1);
return nullptr;
}
BoltDB *ret = new BoltDB();
ret->gmsDbRef = open_ret.r0;
return ret;
}
BoltDB::~BoltDB()
{
auto err = Bolt_Close(this->gmsDbRef);
if (err.v != nullptr) {
// Error closing database:
// errorOut = Interop::GetError(err);
}
}