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
|
||||
err = withBrowse_ReadOnly(b, browse, func(db *bolt.DB, tx *bolt.Tx, bucket *bolt.Bucket) 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
|
||||
})
|
||||
})
|
||||
|
@ -19,17 +19,24 @@ int64_t Interop::GetMagic() {
|
||||
|
||||
GoSliceManagedWrapper::GoSliceManagedWrapper(QStringList *qsl) :
|
||||
rawStrings(),
|
||||
strings(),
|
||||
slice()
|
||||
slice(),
|
||||
strings(nullptr)
|
||||
{
|
||||
rawStrings.reserve(qsl->size());
|
||||
strings.reserve(qsl->size());
|
||||
strings = new GoString[qsl->size()];
|
||||
|
||||
for (int i = 0; i < qsl->size(); ++i) {
|
||||
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.len = strings.size(); // * sizeof(GoString);
|
||||
slice.data = static_cast<void*>(strings);
|
||||
slice.len = qsl->size(); // * sizeof(GoString);
|
||||
slice.cap = slice.len;
|
||||
}
|
||||
|
||||
GoSliceManagedWrapper::~GoSliceManagedWrapper()
|
||||
{
|
||||
delete[] strings;
|
||||
}
|
||||
|
@ -10,11 +10,12 @@ class GoSliceManagedWrapper {
|
||||
|
||||
public:
|
||||
GoSliceManagedWrapper(QStringList *qsl);
|
||||
~GoSliceManagedWrapper();
|
||||
protected:
|
||||
QList<QByteArray> rawStrings;
|
||||
QList<GoString> strings;
|
||||
public:
|
||||
GoSlice slice;
|
||||
GoString *strings;
|
||||
};
|
||||
|
||||
class Interop
|
||||
|
@ -82,11 +82,11 @@ void MainWindow::refreshBucketTree(QTreeWidgetItem* itm)
|
||||
for (int i = itm->childCount(); i --> 0;) {
|
||||
delete itm->takeChild(i);
|
||||
}
|
||||
|
||||
/*
|
||||
if (browsePath.size() > 1) {
|
||||
return; // only go one level deep
|
||||
}
|
||||
|
||||
*/
|
||||
auto *bdb = GET_BDB(top);
|
||||
|
||||
QString error;
|
||||
@ -187,17 +187,15 @@ void MainWindow::on_bucketTree_currentItemChanged(QTreeWidgetItem *current, QTre
|
||||
if (current->parent() == nullptr) {
|
||||
// Selected a database
|
||||
ui->stackedWidget->setCurrentWidget(ui->databasePage);
|
||||
ui->databasePropertiesArea->clear();
|
||||
|
||||
auto *bdb = GET_BDB(current);
|
||||
bdb->getStatsJSON(
|
||||
[=](QString j) {
|
||||
ui->databasePropertiesArea->clear();
|
||||
ui->databasePropertiesArea->setPlainText(j);
|
||||
},
|
||||
[=](QString error) {
|
||||
QMessageBox qmb;
|
||||
qmb.setText(tr("Error retrieving database statistics: %1").arg(error));
|
||||
qmb.exec();
|
||||
ui->databasePropertiesArea->setPlainText(tr("Error retrieving database statistics: %1").arg(error));
|
||||
}
|
||||
);
|
||||
|
||||
@ -205,6 +203,7 @@ void MainWindow::on_bucketTree_currentItemChanged(QTreeWidgetItem *current, QTre
|
||||
// Selected a bucket
|
||||
|
||||
ui->stackedWidget->setCurrentWidget(ui->bucketPage);
|
||||
ui->bucketPropertiesArea->clear();
|
||||
|
||||
QStringList browse;
|
||||
QTreeWidgetItem *top = current;
|
||||
@ -217,13 +216,10 @@ void MainWindow::on_bucketTree_currentItemChanged(QTreeWidgetItem *current, QTre
|
||||
bdb->getBucketStatsJSON(
|
||||
browse,
|
||||
[=](QString j) {
|
||||
ui->bucketPropertiesArea->clear();
|
||||
ui->bucketPropertiesArea->setPlainText(j);
|
||||
},
|
||||
[=](QString error) {
|
||||
QMessageBox qmb;
|
||||
qmb.setText(tr("Error retrieving bucket statistics: %1").arg(error));
|
||||
qmb.exec();
|
||||
ui->bucketPropertiesArea->setPlainText(tr("Error retrieving bucket statistics: %1").arg(error));
|
||||
}
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user