diff 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
line wrap: on
line diff
--- a/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp	Sat Jul 02 11:16:25 2016 +0200
+++ b/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp	Sat Jul 02 15:09:03 2016 +0200
@@ -61,6 +61,18 @@
   }
 
 
+  void MemoryBuffer::Check(OrthancPluginErrorCode code)
+  {
+    if (code != OrthancPluginErrorCode_Success)
+    {
+      // Prevent using garbage information
+      buffer_.data = NULL;
+      buffer_.size = 0;
+      throw PluginException(code);
+    }
+  }
+
+
   MemoryBuffer::MemoryBuffer(OrthancPluginContext* context) : 
     context_(context)
   {
@@ -250,7 +262,14 @@
     Json::FastWriter writer;
     std::string s = writer.write(tags);
     
-    PluginException::Check(OrthancPluginCreateDicom(context_, &buffer_, s.c_str(), NULL, flags));
+    Check(OrthancPluginCreateDicom(context_, &buffer_, s.c_str(), NULL, flags));
+  }
+
+
+  void MemoryBuffer::ReadFile(const std::string& path)
+  {
+    Clear();
+    Check(OrthancPluginReadFile(context_, &buffer_, path.c_str()));
   }