working cgo slices, working nested-bucket operations
This commit is contained in:
parent
679d1140cc
commit
546681a0ef
5
main.go
5
main.go
@ -177,7 +177,10 @@ func Bolt_ListBuckets(b ObjectReference, browse []string) ObjectReference {
|
|||||||
// Nested-mode
|
// Nested-mode
|
||||||
err = withBrowse_ReadOnly(b, browse, func(db *bolt.DB, tx *bolt.Tx, bucket *bolt.Bucket) error {
|
err = withBrowse_ReadOnly(b, browse, func(db *bolt.DB, tx *bolt.Tx, bucket *bolt.Bucket) error {
|
||||||
return bucket.ForEach(func(k, v []byte) error {
|
return bucket.ForEach(func(k, v []byte) error {
|
||||||
pNC.content <- CallResponse{s: string(k)}
|
// non-nil v means it's a data item
|
||||||
|
if v == nil {
|
||||||
|
pNC.content <- CallResponse{s: string(k)}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -19,17 +19,24 @@ int64_t Interop::GetMagic() {
|
|||||||
|
|
||||||
GoSliceManagedWrapper::GoSliceManagedWrapper(QStringList *qsl) :
|
GoSliceManagedWrapper::GoSliceManagedWrapper(QStringList *qsl) :
|
||||||
rawStrings(),
|
rawStrings(),
|
||||||
strings(),
|
slice(),
|
||||||
slice()
|
strings(nullptr)
|
||||||
{
|
{
|
||||||
rawStrings.reserve(qsl->size());
|
rawStrings.reserve(qsl->size());
|
||||||
strings.reserve(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).toUtf8() );
|
||||||
strings.push_back(GoString{ rawStrings[i].data(), rawStrings[i].size() });
|
strings[i].p = rawStrings[i].data();
|
||||||
|
strings[i].n = rawStrings[i].size();
|
||||||
}
|
}
|
||||||
|
|
||||||
slice.data = static_cast<void*>( & strings[0] );
|
slice.data = static_cast<void*>(strings);
|
||||||
slice.len = strings.size(); // * sizeof(GoString);
|
slice.len = qsl->size(); // * sizeof(GoString);
|
||||||
slice.cap = slice.len;
|
slice.cap = slice.len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GoSliceManagedWrapper::~GoSliceManagedWrapper()
|
||||||
|
{
|
||||||
|
delete[] strings;
|
||||||
|
}
|
||||||
|
@ -10,11 +10,12 @@ class GoSliceManagedWrapper {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
GoSliceManagedWrapper(QStringList *qsl);
|
GoSliceManagedWrapper(QStringList *qsl);
|
||||||
|
~GoSliceManagedWrapper();
|
||||||
protected:
|
protected:
|
||||||
QList<QByteArray> rawStrings;
|
QList<QByteArray> rawStrings;
|
||||||
QList<GoString> strings;
|
|
||||||
public:
|
public:
|
||||||
GoSlice slice;
|
GoSlice slice;
|
||||||
|
GoString *strings;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Interop
|
class Interop
|
||||||
|
@ -82,11 +82,11 @@ void MainWindow::refreshBucketTree(QTreeWidgetItem* itm)
|
|||||||
for (int i = itm->childCount(); i --> 0;) {
|
for (int i = itm->childCount(); i --> 0;) {
|
||||||
delete itm->takeChild(i);
|
delete itm->takeChild(i);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
if (browsePath.size() > 1) {
|
if (browsePath.size() > 1) {
|
||||||
return; // only go one level deep
|
return; // only go one level deep
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
auto *bdb = GET_BDB(top);
|
auto *bdb = GET_BDB(top);
|
||||||
|
|
||||||
QString error;
|
QString error;
|
||||||
@ -187,17 +187,15 @@ void MainWindow::on_bucketTree_currentItemChanged(QTreeWidgetItem *current, QTre
|
|||||||
if (current->parent() == nullptr) {
|
if (current->parent() == nullptr) {
|
||||||
// Selected a database
|
// Selected a database
|
||||||
ui->stackedWidget->setCurrentWidget(ui->databasePage);
|
ui->stackedWidget->setCurrentWidget(ui->databasePage);
|
||||||
|
ui->databasePropertiesArea->clear();
|
||||||
|
|
||||||
auto *bdb = GET_BDB(current);
|
auto *bdb = GET_BDB(current);
|
||||||
bdb->getStatsJSON(
|
bdb->getStatsJSON(
|
||||||
[=](QString j) {
|
[=](QString j) {
|
||||||
ui->databasePropertiesArea->clear();
|
|
||||||
ui->databasePropertiesArea->setPlainText(j);
|
ui->databasePropertiesArea->setPlainText(j);
|
||||||
},
|
},
|
||||||
[=](QString error) {
|
[=](QString error) {
|
||||||
QMessageBox qmb;
|
ui->databasePropertiesArea->setPlainText(tr("Error retrieving database statistics: %1").arg(error));
|
||||||
qmb.setText(tr("Error retrieving database statistics: %1").arg(error));
|
|
||||||
qmb.exec();
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -205,6 +203,7 @@ void MainWindow::on_bucketTree_currentItemChanged(QTreeWidgetItem *current, QTre
|
|||||||
// Selected a bucket
|
// Selected a bucket
|
||||||
|
|
||||||
ui->stackedWidget->setCurrentWidget(ui->bucketPage);
|
ui->stackedWidget->setCurrentWidget(ui->bucketPage);
|
||||||
|
ui->bucketPropertiesArea->clear();
|
||||||
|
|
||||||
QStringList browse;
|
QStringList browse;
|
||||||
QTreeWidgetItem *top = current;
|
QTreeWidgetItem *top = current;
|
||||||
@ -217,13 +216,10 @@ void MainWindow::on_bucketTree_currentItemChanged(QTreeWidgetItem *current, QTre
|
|||||||
bdb->getBucketStatsJSON(
|
bdb->getBucketStatsJSON(
|
||||||
browse,
|
browse,
|
||||||
[=](QString j) {
|
[=](QString j) {
|
||||||
ui->bucketPropertiesArea->clear();
|
|
||||||
ui->bucketPropertiesArea->setPlainText(j);
|
ui->bucketPropertiesArea->setPlainText(j);
|
||||||
},
|
},
|
||||||
[=](QString error) {
|
[=](QString error) {
|
||||||
QMessageBox qmb;
|
ui->bucketPropertiesArea->setPlainText(tr("Error retrieving bucket statistics: %1").arg(error));
|
||||||
qmb.setText(tr("Error retrieving bucket statistics: %1").arg(error));
|
|
||||||
qmb.exec();
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user