diff --git a/src/ifcwrap/IfcParseWrapper.i b/src/ifcwrap/IfcParseWrapper.i index 30e932d018..86ba620d10 100644 --- a/src/ifcwrap/IfcParseWrapper.i +++ b/src/ifcwrap/IfcParseWrapper.i @@ -207,6 +207,23 @@ static IfcUtil::ArgumentType helper_fn_attribute_type(const IfcUtil::IfcBaseClas return $self->schema()->name(); } + PyObject* key_value_store_query(const std::string& key) const { + auto* storage = std::visit([](auto& m) -> IfcParse::impl::rocks_db_file_storage const * { + if constexpr (std::is_same_v, IfcParse::impl::rocks_db_file_storage>) { + return &m; + } + return nullptr; + }, $self->storage_); + if (!storage) { + Py_RETURN_NONE; + } + std::string value; + if (storage->db->Get(storage->ropts, key, &value) != rocksdb::Status::OK()) { + Py_RETURN_NONE; + } + return PyBytes_FromStringAndSize(value.data(), value.size()); + } + %pythoncode %{ # Hide the getters with read-only property implementations header = property(header) @@ -593,6 +610,7 @@ static IfcUtil::ArgumentType helper_fn_attribute_type(const IfcUtil::IfcBaseClas %include "../ifcparse/file_open_status.h" %include "../ifcparse/IfcBaseClass.h" %include "../ifcparse/IfcSchema.h" +%include "../serializers/RocksDbSerializer.h" // The IfcFile* returned by open() is to be freed by SWIG/Python %newobject open; diff --git a/src/ifcwrap/IfcPython.i b/src/ifcwrap/IfcPython.i index 51b0969591..0b69e90d85 100644 --- a/src/ifcwrap/IfcPython.i +++ b/src/ifcwrap/IfcPython.i @@ -201,6 +201,7 @@ #include "../serializers/WavefrontObjSerializer.h" #include "../serializers/ColladaSerializer.h" #include "../serializers/HdfSerializer.h" + #include "../serializers/RocksDbSerializer.h" #ifdef HAS_SCHEMA_2x3 #include "../ifcparse/Ifc2x3.h" @@ -301,6 +302,7 @@ constexpr bool is_std_vector_vector_v = is_std_vector_vector::value; #include "../serializers/XmlSerializer.h" #include "../serializers/GltfSerializer.h" #include "../serializers/TtlWktSerializer.h" + #include "../serializers/RocksDbSerializer.h" #ifdef HAS_SCHEMA_2x3 #include "../ifcparse/Ifc2x3.h"