Mercurial > hg > orthanc-databases
diff Framework/Plugins/StorageBackend.cpp @ 14:9774802fd05f
PostgreSQLStorageArea working
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 09 Jul 2018 20:28:27 +0200 |
parents | 41543239072d |
children | 9e419261f1c9 |
line wrap: on
line diff
--- a/Framework/Plugins/StorageBackend.cpp Mon Jul 09 18:42:34 2018 +0200 +++ b/Framework/Plugins/StorageBackend.cpp Mon Jul 09 20:28:27 2018 +0200 @@ -71,13 +71,46 @@ } } - + StorageBackend::StorageBackend(IDatabaseFactory* factory) : manager_(factory) { } + void StorageBackend::ReadToString(std::string& content, + DatabaseManager::Transaction& transaction, + const std::string& uuid, + OrthancPluginContentType type) + { + void* buffer = NULL; + size_t size; + Read(buffer, size, transaction, uuid, type); + + try + { + content.resize(size); + } + catch (std::bad_alloc&) + { + if (size != 0) + { + free(buffer); + } + + throw Orthanc::OrthancException(Orthanc::ErrorCode_NotEnoughMemory); + } + + if (size != 0) + { + assert(buffer != NULL); + memcpy(&content[0], buffer, size); + } + + free(buffer); + } + + static OrthancPluginContext* context_ = NULL; static std::auto_ptr<StorageBackend> backend_;