more binary correctness
This commit is contained in:
parent
40e84ac230
commit
54ad6015b7
@ -45,27 +45,27 @@ static bool handleTriple(int r0, char* r1, int64_t r2, QString& errorOut) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BoltDB::addBucket(QStringList bucketPath, QByteArray bucketName, QString& errorOut)
|
bool BoltDB::addBucket(const QList<QByteArray>& bucketPath, QByteArray bucketName, QString& errorOut)
|
||||||
{
|
{
|
||||||
GoSliceManagedWrapper browse(&bucketPath);
|
GoSliceManagedWrapper browse(bucketPath);
|
||||||
GoString bucketNameGS = Interop::toGoString_WeakRef(&bucketName);
|
GoString bucketNameGS = Interop::toGoString_WeakRef(&bucketName);
|
||||||
auto resp = ::Bolt_CreateBucket(this->gmsDbRef, browse.slice, bucketNameGS);
|
auto resp = ::Bolt_CreateBucket(this->gmsDbRef, browse.slice, bucketNameGS);
|
||||||
|
|
||||||
return handleTriple(resp.r0, resp.r1, resp.r2, errorOut);
|
return handleTriple(resp.r0, resp.r1, resp.r2, errorOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BoltDB::deleteBucket(QStringList bucketPath, QByteArray bucketName, QString& errorOut)
|
bool BoltDB::deleteBucket(const QList<QByteArray>& bucketPath, QByteArray bucketName, QString& errorOut)
|
||||||
{
|
{
|
||||||
GoSliceManagedWrapper browse(&bucketPath);
|
GoSliceManagedWrapper browse(bucketPath);
|
||||||
GoString bucketNameGS = Interop::toGoString_WeakRef(&bucketName);
|
GoString bucketNameGS = Interop::toGoString_WeakRef(&bucketName);
|
||||||
auto resp = ::Bolt_DeleteBucket(this->gmsDbRef, browse.slice, bucketNameGS);
|
auto resp = ::Bolt_DeleteBucket(this->gmsDbRef, browse.slice, bucketNameGS);
|
||||||
|
|
||||||
return handleTriple(resp.r0, resp.r1, resp.r2, errorOut);
|
return handleTriple(resp.r0, resp.r1, resp.r2, errorOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BoltDB::setItem(QStringList bucketPath, QByteArray keyName, QByteArray value, QString& errorOut)
|
bool BoltDB::setItem(const QList<QByteArray>& bucketPath, QByteArray keyName, QByteArray value, QString& errorOut)
|
||||||
{
|
{
|
||||||
GoSliceManagedWrapper browse(&bucketPath);
|
GoSliceManagedWrapper browse(bucketPath);
|
||||||
GoString keyNameGS = Interop::toGoString_WeakRef(&keyName);
|
GoString keyNameGS = Interop::toGoString_WeakRef(&keyName);
|
||||||
GoString valueGS = Interop::toGoString_WeakRef(&value);
|
GoString valueGS = Interop::toGoString_WeakRef(&value);
|
||||||
auto resp = ::Bolt_SetItem(this->gmsDbRef, browse.slice, keyNameGS, valueGS);
|
auto resp = ::Bolt_SetItem(this->gmsDbRef, browse.slice, keyNameGS, valueGS);
|
||||||
@ -73,9 +73,9 @@ bool BoltDB::setItem(QStringList bucketPath, QByteArray keyName, QByteArray valu
|
|||||||
return handleTriple(resp.r0, resp.r1, resp.r2, errorOut);
|
return handleTriple(resp.r0, resp.r1, resp.r2, errorOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BoltDB::deleteItem(QStringList bucketPath, QByteArray keyName, QString& errorOut)
|
bool BoltDB::deleteItem(const QList<QByteArray>& bucketPath, QByteArray keyName, QString& errorOut)
|
||||||
{
|
{
|
||||||
GoSliceManagedWrapper browse(&bucketPath);
|
GoSliceManagedWrapper browse(bucketPath);
|
||||||
GoString keyNameGS = Interop::toGoString_WeakRef(&keyName);
|
GoString keyNameGS = Interop::toGoString_WeakRef(&keyName);
|
||||||
auto resp = ::Bolt_DeleteItem(this->gmsDbRef, browse.slice, keyNameGS);
|
auto resp = ::Bolt_DeleteItem(this->gmsDbRef, browse.slice, keyNameGS);
|
||||||
|
|
||||||
@ -89,20 +89,20 @@ bool BoltDB::listBucketsAtRoot(QString& errorOut, NameReciever cb)
|
|||||||
return pumpNext(listJob, errorOut, cb);
|
return pumpNext(listJob, errorOut, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BoltDB::listBuckets(QStringList bucketPath, QString& errorOut, NameReciever cb)
|
bool BoltDB::listBuckets(const QList<QByteArray>& bucketPath, QString& errorOut, NameReciever cb)
|
||||||
{
|
{
|
||||||
if (bucketPath.size() == 0) {
|
if (bucketPath.size() == 0) {
|
||||||
return listBucketsAtRoot(errorOut, cb);
|
return listBucketsAtRoot(errorOut, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
GoSliceManagedWrapper browse(&bucketPath);
|
GoSliceManagedWrapper browse(bucketPath);
|
||||||
auto listJob = ::Bolt_ListBuckets(this->gmsDbRef, browse.slice);
|
auto listJob = ::Bolt_ListBuckets(this->gmsDbRef, browse.slice);
|
||||||
return pumpNext(listJob, errorOut, cb);
|
return pumpNext(listJob, errorOut, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BoltDB::listKeys(QStringList bucketPath, QString& errorOut, std::function<void(QByteArray, int64_t)> cb)
|
bool BoltDB::listKeys(const QList<QByteArray>& bucketPath, QString& errorOut, std::function<void(QByteArray, int64_t)> cb)
|
||||||
{
|
{
|
||||||
GoSliceManagedWrapper browse(&bucketPath);
|
GoSliceManagedWrapper browse(bucketPath);
|
||||||
auto listJob = ::Bolt_ListItems(this->gmsDbRef, browse.slice);
|
auto listJob = ::Bolt_ListItems(this->gmsDbRef, browse.slice);
|
||||||
return pumpNext(listJob, errorOut, [=](QByteArray b) {
|
return pumpNext(listJob, errorOut, [=](QByteArray b) {
|
||||||
// First 8 bytes are little-endian uint64 len
|
// First 8 bytes are little-endian uint64 len
|
||||||
@ -111,9 +111,9 @@ bool BoltDB::listKeys(QStringList bucketPath, QString& errorOut, std::function<v
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BoltDB::getData(QStringList bucketPath, QByteArray key, std::function<void(QByteArray)> onSuccess, std::function<void(QString)> onError)
|
bool BoltDB::getData(const QList<QByteArray>& bucketPath, QByteArray key, std::function<void(QByteArray)> onSuccess, std::function<void(QString)> onError)
|
||||||
{
|
{
|
||||||
GoSliceManagedWrapper browse(&bucketPath);
|
GoSliceManagedWrapper browse(bucketPath);
|
||||||
GoString keyGS = Interop::toGoString_WeakRef(&key);
|
GoString keyGS = Interop::toGoString_WeakRef(&key);
|
||||||
auto resp = ::Bolt_GetItem(this->gmsDbRef, browse.slice, keyGS);
|
auto resp = ::Bolt_GetItem(this->gmsDbRef, browse.slice, keyGS);
|
||||||
|
|
||||||
@ -185,9 +185,9 @@ bool BoltDB::getStatsJSON(std::function<void(QByteArray)> onSuccess, std::functi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BoltDB::getBucketStatsJSON(QStringList bucketPath, std::function<void(QByteArray)> onSuccess, std::function<void(QString)> onError)
|
bool BoltDB::getBucketStatsJSON(const QList<QByteArray>& bucketPath, std::function<void(QByteArray)> onSuccess, std::function<void(QString)> onError)
|
||||||
{
|
{
|
||||||
GoSliceManagedWrapper sliceWrapper(&bucketPath);
|
GoSliceManagedWrapper sliceWrapper(bucketPath);
|
||||||
auto statresp = Bolt_BucketStats(this->gmsDbRef, sliceWrapper.slice);
|
auto statresp = Bolt_BucketStats(this->gmsDbRef, sliceWrapper.slice);
|
||||||
|
|
||||||
if (statresp.r0 == ERROR_AND_STOP_CALLING) {
|
if (statresp.r0 == ERROR_AND_STOP_CALLING) {
|
||||||
|
@ -18,23 +18,23 @@ public:
|
|||||||
|
|
||||||
bool listBucketsAtRoot(QString& errorOut, NameReciever cb);
|
bool listBucketsAtRoot(QString& errorOut, NameReciever cb);
|
||||||
|
|
||||||
bool listBuckets(QStringList bucketPath, QString& errorOut, NameReciever cb);
|
bool listBuckets(const QList<QByteArray>& bucketPath, QString& errorOut, NameReciever cb);
|
||||||
|
|
||||||
bool addBucket(QStringList bucketPath, QByteArray bucketName, QString& errorOut);
|
bool addBucket(const QList<QByteArray>& bucketPath, QByteArray bucketName, QString& errorOut);
|
||||||
|
|
||||||
bool deleteBucket(QStringList bucketPath, QByteArray bucketName, QString& errorOut);
|
bool deleteBucket(const QList<QByteArray>& bucketPath, QByteArray bucketName, QString& errorOut);
|
||||||
|
|
||||||
bool setItem(QStringList bucketPath, QByteArray keyName, QByteArray value, QString& errorOut);
|
bool setItem(const QList<QByteArray>& bucketPath, QByteArray keyName, QByteArray value, QString& errorOut);
|
||||||
|
|
||||||
bool deleteItem(QStringList bucketPath, QByteArray keyName, QString& errorOut);
|
bool deleteItem(const QList<QByteArray>& bucketPath, QByteArray keyName, QString& errorOut);
|
||||||
|
|
||||||
bool listKeys(QStringList bucketPath, QString& errorOut, std::function<void(QByteArray, int64_t)> cb);
|
bool listKeys(const QList<QByteArray>& bucketPath, QString& errorOut, std::function<void(QByteArray, int64_t)> cb);
|
||||||
|
|
||||||
bool getData(QStringList bucketPath, QByteArray key, std::function<void(QByteArray)> onSuccess, std::function<void(QString)> onError);
|
bool getData(const QList<QByteArray>& bucketPath, QByteArray key, std::function<void(QByteArray)> onSuccess, std::function<void(QString)> onError);
|
||||||
|
|
||||||
bool getStatsJSON(std::function<void(QByteArray)> onSuccess, std::function<void(QString)> onError);
|
bool getStatsJSON(std::function<void(QByteArray)> onSuccess, std::function<void(QString)> onError);
|
||||||
|
|
||||||
bool getBucketStatsJSON(QStringList bucketPath, std::function<void(QByteArray)> onSuccess, std::function<void(QString)> onError);
|
bool getBucketStatsJSON(const QList<QByteArray>& bucketPath, std::function<void(QByteArray)> onSuccess, std::function<void(QString)> onError);
|
||||||
|
|
||||||
~BoltDB();
|
~BoltDB();
|
||||||
|
|
||||||
|
@ -17,22 +17,22 @@ int64_t Interop::GetMagic() {
|
|||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
GoSliceManagedWrapper::GoSliceManagedWrapper(QStringList *qsl) :
|
GoSliceManagedWrapper::GoSliceManagedWrapper(const QList<QByteArray>& qsl) :
|
||||||
rawStrings(),
|
rawStrings(),
|
||||||
slice(),
|
slice(),
|
||||||
strings(nullptr)
|
strings(nullptr)
|
||||||
{
|
{
|
||||||
rawStrings.reserve(qsl->size());
|
rawStrings.reserve(qsl.size());
|
||||||
strings = new GoString[qsl->size()];
|
strings = new GoString[qsl.size()];
|
||||||
|
|
||||||
for (int i = 0; i < qsl->size(); ++i) {
|
for (int i = 0; i < qsl.size(); ++i) {
|
||||||
rawStrings.push_back( qsl->at(i).toUtf8() );
|
rawStrings.push_back( qsl.at(i) );
|
||||||
strings[i].p = rawStrings[i].data();
|
strings[i].p = rawStrings[i].data();
|
||||||
strings[i].n = rawStrings[i].size();
|
strings[i].n = rawStrings[i].size();
|
||||||
}
|
}
|
||||||
|
|
||||||
slice.data = static_cast<void*>(strings);
|
slice.data = static_cast<void*>(strings);
|
||||||
slice.len = qsl->size(); // * sizeof(GoString);
|
slice.len = qsl.size(); // * sizeof(GoString);
|
||||||
slice.cap = slice.len;
|
slice.cap = slice.len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ class GoSliceManagedWrapper {
|
|||||||
Q_DISABLE_COPY(GoSliceManagedWrapper)
|
Q_DISABLE_COPY(GoSliceManagedWrapper)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GoSliceManagedWrapper(QStringList *qsl);
|
GoSliceManagedWrapper(const QList<QByteArray>& qsl);
|
||||||
~GoSliceManagedWrapper();
|
~GoSliceManagedWrapper();
|
||||||
protected:
|
protected:
|
||||||
QList<QByteArray> rawStrings;
|
QList<QByteArray> rawStrings;
|
||||||
|
@ -117,9 +117,9 @@ static const QString getDisplayName(const QByteArray &qba) {
|
|||||||
void MainWindow::refreshBucketTree(QTreeWidgetItem* itm)
|
void MainWindow::refreshBucketTree(QTreeWidgetItem* itm)
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *top = itm;
|
QTreeWidgetItem *top = itm;
|
||||||
QStringList browsePath;
|
QList<QByteArray> browsePath;
|
||||||
while(top->parent() != nullptr) {
|
while(top->parent() != nullptr) {
|
||||||
browsePath.push_front(top->text(0));
|
browsePath.push_front(top->data(0, BinaryDataRole).toByteArray());
|
||||||
top = top->parent();
|
top = top->parent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,10 +252,10 @@ void MainWindow::on_bucketTree_currentItemChanged(QTreeWidgetItem *current, QTre
|
|||||||
ui->stackedWidget->setCurrentWidget(ui->bucketPage);
|
ui->stackedWidget->setCurrentWidget(ui->bucketPage);
|
||||||
ui->bucketPropertiesArea->clear();
|
ui->bucketPropertiesArea->clear();
|
||||||
|
|
||||||
QStringList browse;
|
QList<QByteArray> browse;
|
||||||
QTreeWidgetItem *top = current;
|
QTreeWidgetItem *top = current;
|
||||||
while (top->parent() != nullptr) {
|
while (top->parent() != nullptr) {
|
||||||
browse.push_front(top->text(0));
|
browse.push_front(top->data(0, BinaryDataRole).toByteArray());
|
||||||
top = top->parent();
|
top = top->parent();
|
||||||
}
|
}
|
||||||
auto *bdb = GET_BDB(top);
|
auto *bdb = GET_BDB(top);
|
||||||
@ -279,7 +279,7 @@ void MainWindow::on_bucketTree_currentItemChanged(QTreeWidgetItem *current, QTre
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::refreshData(BoltDB *bdb, QStringList browse)
|
void MainWindow::refreshData(BoltDB *bdb, const QList<QByteArray>& browse)
|
||||||
{
|
{
|
||||||
// Load the data tab
|
// Load the data tab
|
||||||
ui->bucketData->clear();
|
ui->bucketData->clear();
|
||||||
@ -313,14 +313,14 @@ void MainWindow::on_actionClear_selection_triggered()
|
|||||||
return; \
|
return; \
|
||||||
} \
|
} \
|
||||||
QTreeWidgetItem* top = itm; \
|
QTreeWidgetItem* top = itm; \
|
||||||
QStringList browse; \
|
QList<QByteArray> browse; \
|
||||||
while(top->parent() != nullptr) { \
|
while(top->parent() != nullptr) { \
|
||||||
browse.push_front(top->text(0)); \
|
browse.push_front(top->data(0, BinaryDataRole).toByteArray()); \
|
||||||
top = top->parent(); \
|
top = top->parent(); \
|
||||||
} \
|
} \
|
||||||
auto *bdb = GET_BDB(top);
|
auto *bdb = GET_BDB(top);
|
||||||
|
|
||||||
void MainWindow::openEditor(BoltDB *bdb, QStringList saveAs, QByteArray saveAsKey, QByteArray currentContent)
|
void MainWindow::openEditor(BoltDB *bdb, const QList<QByteArray>& saveAs, QByteArray saveAsKey, QByteArray currentContent)
|
||||||
{
|
{
|
||||||
auto iw = new ItemWindow();
|
auto iw = new ItemWindow();
|
||||||
iw->ContentArea()->setPlainText(QString::fromUtf8(currentContent));
|
iw->ContentArea()->setPlainText(QString::fromUtf8(currentContent));
|
||||||
|
@ -56,8 +56,8 @@ private slots:
|
|||||||
protected:
|
protected:
|
||||||
void openDatabase(QString file, bool readOnly);
|
void openDatabase(QString file, bool readOnly);
|
||||||
void refreshBucketTree(QTreeWidgetItem* top);
|
void refreshBucketTree(QTreeWidgetItem* top);
|
||||||
void refreshData(BoltDB *bdb, QStringList browse);
|
void refreshData(BoltDB *bdb, const QList<QByteArray>& browse);
|
||||||
void openEditor(BoltDB *bdb, QStringList saveAs, QByteArray saveAsKey, QByteArray currentContent);
|
void openEditor(BoltDB *bdb, const QList<QByteArray>& saveAs, QByteArray saveAsKey, QByteArray currentContent);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
|
Loading…
Reference in New Issue
Block a user