comparison Plugins/Samples/Common/OrthancPluginCppWrapper.cpp @ 2062:40ffd0e8676a

generation of etag in ServeFolders
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 02 Jul 2016 15:09:03 +0200
parents 8e67325eaa3f
children d5c29fd74ffa
comparison
equal deleted inserted replaced
2061:8856f15b3e02 2062:40ffd0e8676a
59 throw PluginException(code); 59 throw PluginException(code);
60 } 60 }
61 } 61 }
62 62
63 63
64 void MemoryBuffer::Check(OrthancPluginErrorCode code)
65 {
66 if (code != OrthancPluginErrorCode_Success)
67 {
68 // Prevent using garbage information
69 buffer_.data = NULL;
70 buffer_.size = 0;
71 throw PluginException(code);
72 }
73 }
74
75
64 MemoryBuffer::MemoryBuffer(OrthancPluginContext* context) : 76 MemoryBuffer::MemoryBuffer(OrthancPluginContext* context) :
65 context_(context) 77 context_(context)
66 { 78 {
67 buffer_.data = NULL; 79 buffer_.data = NULL;
68 buffer_.size = 0; 80 buffer_.size = 0;
248 Clear(); 260 Clear();
249 261
250 Json::FastWriter writer; 262 Json::FastWriter writer;
251 std::string s = writer.write(tags); 263 std::string s = writer.write(tags);
252 264
253 PluginException::Check(OrthancPluginCreateDicom(context_, &buffer_, s.c_str(), NULL, flags)); 265 Check(OrthancPluginCreateDicom(context_, &buffer_, s.c_str(), NULL, flags));
266 }
267
268
269 void MemoryBuffer::ReadFile(const std::string& path)
270 {
271 Clear();
272 Check(OrthancPluginReadFile(context_, &buffer_, path.c_str()));
254 } 273 }
255 274
256 275
257 OrthancString::OrthancString(OrthancPluginContext* context, 276 OrthancString::OrthancString(OrthancPluginContext* context,
258 char* str) : 277 char* str) :