From 4ffc97383cfe7cc00a81fbff5930c3d5e1cb2b49 Mon Sep 17 00:00:00 2001 From: Gerardo Tauriello <gerardo.tauriello@unibas.ch> Date: Fri, 1 Apr 2016 11:37:43 +0200 Subject: [PATCH] Fixed LoadEntity to accept format string. --- modules/io/pymod/wrap_io.cc | 3 ++- modules/io/src/mol/load_entity.cc | 10 +++++----- modules/io/src/mol/load_entity.hh | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/io/pymod/wrap_io.cc b/modules/io/pymod/wrap_io.cc index 6d16af3e9..302720245 100644 --- a/modules/io/pymod/wrap_io.cc +++ b/modules/io/pymod/wrap_io.cc @@ -83,7 +83,8 @@ BOOST_PYTHON_MODULE(_ost_io) def("Instance",IOManager::Instance, return_value_policy<reference_existing_object>() ); - def("LoadEntity",LoadEntity,load_entity_ov()); + def("LoadEntity", LoadEntity, + load_entity_ov(args("filename", "format"))); def("SaveEntity", &save_ent_view, save_entity_view_ov(args("entity", "filename", "format"))); def("SaveEntity", &save_ent_handle, diff --git a/modules/io/src/mol/load_entity.cc b/modules/io/src/mol/load_entity.cc index 98eea40f8..4ce5f94b7 100644 --- a/modules/io/src/mol/load_entity.cc +++ b/modules/io/src/mol/load_entity.cc @@ -30,13 +30,13 @@ namespace ost { namespace io { namespace { -void Import(mol::EntityHandle& eh, const String& filename, int flag) +void Import(mol::EntityHandle& eh, const String& filename, const String& format) { Profile profile_import("import"); LOG_DEBUG("creating EntityIOHandle for " << filename); - EntityIOHandlerP ent_io = IOManager::Instance().FindEntityImportHandler(filename); + EntityIOHandlerP ent_io = IOManager::Instance().FindEntityImportHandler(filename, format); - // TODO: proper error handling + // note: error handling done in FindEntityImportHandler LOG_DEBUG("calling import on entity io handle"); ent_io->Import(eh,filename); @@ -53,12 +53,12 @@ void Import(mol::EntityHandle& eh, const String& filename, int flag) } // anon ns -mol::EntityHandle LoadEntity(const String& filename, int flag) +mol::EntityHandle LoadEntity(const String& filename, const String& format) { LOG_DEBUG("creating emtpy entity"); mol::EntityHandle eh=mol::CreateEntity(); mol::XCSEditor xcs_lock=eh.EditXCS(mol::BUFFERED_EDIT); - Import(eh,filename,flag); + Import(eh, filename, format); return eh; } diff --git a/modules/io/src/mol/load_entity.hh b/modules/io/src/mol/load_entity.hh index 0a38c07af..80ff0bb49 100644 --- a/modules/io/src/mol/load_entity.hh +++ b/modules/io/src/mol/load_entity.hh @@ -25,7 +25,7 @@ namespace ost { namespace io { // load unmanaged entity -DLLEXPORT_OST_IO mol::EntityHandle LoadEntity(const String& filename, int flag=0); +DLLEXPORT_OST_IO mol::EntityHandle LoadEntity(const String& filename, const String& format="auto"); }} // ns -- GitLab