Mercurial > hg > orthanc-databases
comparison 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 |
comparison
equal
deleted
inserted
replaced
13:927264a0c137 | 14:9774802fd05f |
---|---|
69 | 69 |
70 memcpy(buffer, content.c_str(), size); | 70 memcpy(buffer, content.c_str(), size); |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 | 74 |
75 StorageBackend::StorageBackend(IDatabaseFactory* factory) : | 75 StorageBackend::StorageBackend(IDatabaseFactory* factory) : |
76 manager_(factory) | 76 manager_(factory) |
77 { | 77 { |
78 } | |
79 | |
80 | |
81 void StorageBackend::ReadToString(std::string& content, | |
82 DatabaseManager::Transaction& transaction, | |
83 const std::string& uuid, | |
84 OrthancPluginContentType type) | |
85 { | |
86 void* buffer = NULL; | |
87 size_t size; | |
88 Read(buffer, size, transaction, uuid, type); | |
89 | |
90 try | |
91 { | |
92 content.resize(size); | |
93 } | |
94 catch (std::bad_alloc&) | |
95 { | |
96 if (size != 0) | |
97 { | |
98 free(buffer); | |
99 } | |
100 | |
101 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotEnoughMemory); | |
102 } | |
103 | |
104 if (size != 0) | |
105 { | |
106 assert(buffer != NULL); | |
107 memcpy(&content[0], buffer, size); | |
108 } | |
109 | |
110 free(buffer); | |
78 } | 111 } |
79 | 112 |
80 | 113 |
81 static OrthancPluginContext* context_ = NULL; | 114 static OrthancPluginContext* context_ = NULL; |
82 static std::auto_ptr<StorageBackend> backend_; | 115 static std::auto_ptr<StorageBackend> backend_; |