void export_table_view()

in src/table_view.cc [32:74]


void export_table_view(py::module_& m) {
    py::class_<TableViewConfiguration>(m, "TableViewConfiguration")
        .def(py::init<>())
        .def("subscription_name",
             [](TableViewConfiguration& config, const std::string& name) { config.subscriptionName = name; })
        .def("schema",
             [](TableViewConfiguration& config, const SchemaInfo& schema) { config.schemaInfo = schema; });

    py::class_<TableView>(m, "TableView")
        .def(py::init<>())
        .def("get",
             [](const TableView& view, const std::string& key) -> std::pair<bool, py::bytes> {
                 py::gil_scoped_release release;
                 std::string value;
                 bool available = view.getValue(key, value);
                 py::gil_scoped_acquire acquire;
                 if (available) {
                     return std::make_pair(true, py::bytes(std::move(value)));
                 } else {
                     return std::make_pair(false, py::bytes());
                 }
             })
        .def("size", &TableView::size, py::call_guard<py::gil_scoped_release>())
        .def("for_each",
             [](TableView& view, std::function<void(std::string, py::bytes)> callback) {
                 py::gil_scoped_release release;
                 view.forEach([callback](const std::string& key, const std::string& value) {
                     py::gil_scoped_acquire acquire;
                     callback(key, py::bytes(value));
                 });
             })
        .def("for_each_and_listen",
             [](TableView& view, std::function<void(std::string, py::bytes)> callback) {
                 py::gil_scoped_release release;
                 view.forEachAndListen([callback](const std::string& key, const std::string& value) {
                     py::gil_scoped_acquire acquire;
                     callback(key, py::bytes(value));
                 });
             })
        .def("close", [](TableView& view) {
            waitForAsyncResult([&view](ResultCallback callback) { view.closeAsync(callback); });
        });
}