changeset 2851:859e880ac9a8

merge
author am@osimis.io
date Mon, 01 Oct 2018 14:19:45 +0200
parents 9f949922d603 (diff) c67b5d80b758 (current diff)
children d4f44a8028a1 52b017d22a4f
files Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Plugins/Samples/Common/OrthancPluginCppWrapper.h
diffstat 1 files changed, 110 insertions(+), 110 deletions(-) [+]
line wrap: on
line diff
--- a/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp	Mon Oct 01 13:05:07 2018 +0200
+++ b/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp	Mon Oct 01 14:19:45 2018 +0200
@@ -20,7 +20,7 @@
  * you do not wish to do so, delete this exception statement from your
  * version. If you delete this exception statement from all source files
  * in the program, then also delete it here.
- * 
+ *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -76,7 +76,7 @@
   }
 
 
-  MemoryBuffer::MemoryBuffer(OrthancPluginContext* context) : 
+  MemoryBuffer::MemoryBuffer(OrthancPluginContext* context) :
     context_(context)
   {
     buffer_.data = NULL;
@@ -346,7 +346,7 @@
                                            password.empty() ? NULL : password.c_str()));
   }
   
- 
+
   bool MemoryBuffer::HttpPut(const std::string& url,
                              const std::string& body,
                              const std::string& username,
@@ -374,10 +374,10 @@
                   const std::string& password)
   {
     OrthancPluginErrorCode error = OrthancPluginHttpDelete
-      (context_, url.c_str(),
-       username.empty() ? NULL : username.c_str(),
-       password.empty() ? NULL : password.c_str());
-  
+        (context_, url.c_str(),
+         username.empty() ? NULL : username.c_str(),
+         password.empty() ? NULL : password.c_str());
+
     if (error == OrthancPluginErrorCode_Success)
     {
       return true;
@@ -394,7 +394,7 @@
   }
   
 
-  OrthancConfiguration::OrthancConfiguration(OrthancPluginContext* context) : 
+  OrthancConfiguration::OrthancConfiguration(OrthancPluginContext* context) :
     context_(context)
   {
     OrthancString str(context);
@@ -519,22 +519,22 @@
 
     switch (configuration_[key].type())
     {
-      case Json::intValue:
-        target = configuration_[key].asInt();
-        return true;
-        
-      case Json::uintValue:
-        target = configuration_[key].asUInt();
-        return true;
-        
-      default:
-        if (context_ != NULL)
-        {
-          std::string s = "The configuration option \"" + GetPath(key) + "\" is not an integer as expected";
-          OrthancPluginLogError(context_, s.c_str());
-        }
+    case Json::intValue:
+      target = configuration_[key].asInt();
+      return true;
+
+    case Json::uintValue:
+      target = configuration_[key].asUInt();
+      return true;
 
-        ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
+    default:
+      if (context_ != NULL)
+      {
+        std::string s = "The configuration option \"" + GetPath(key) + "\" is not an integer as expected";
+        OrthancPluginLogError(context_, s.c_str());
+      }
+
+      ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
     }
   }
 
@@ -604,26 +604,26 @@
 
     switch (configuration_[key].type())
     {
-      case Json::realValue:
-        target = configuration_[key].asFloat();
-        return true;
-        
-      case Json::intValue:
-        target = static_cast<float>(configuration_[key].asInt());
-        return true;
-        
-      case Json::uintValue:
-        target = static_cast<float>(configuration_[key].asUInt());
-        return true;
-        
-      default:
-        if (context_ != NULL)
-        {
-          std::string s = "The configuration option \"" + GetPath(key) + "\" is not an integer as expected";
-          OrthancPluginLogError(context_, s.c_str());
-        }
+    case Json::realValue:
+      target = configuration_[key].asFloat();
+      return true;
+
+    case Json::intValue:
+      target = static_cast<float>(configuration_[key].asInt());
+      return true;
 
-        ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
+    case Json::uintValue:
+      target = static_cast<float>(configuration_[key].asUInt());
+      return true;
+
+    default:
+      if (context_ != NULL)
+      {
+        std::string s = "The configuration option \"" + GetPath(key) + "\" is not an integer as expected";
+        OrthancPluginLogError(context_, s.c_str());
+      }
+
+      ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
     }
   }
 
@@ -643,41 +643,41 @@
 
     switch (configuration_[key].type())
     {
-      case Json::arrayValue:
+    case Json::arrayValue:
+    {
+      bool ok = true;
+
+      for (Json::Value::ArrayIndex i = 0; ok && i < configuration_[key].size(); i++)
       {
-        bool ok = true;
-    
-        for (Json::Value::ArrayIndex i = 0; ok && i < configuration_[key].size(); i++)
+        if (configuration_[key][i].type() == Json::stringValue)
         {
-          if (configuration_[key][i].type() == Json::stringValue)
-          {
-            target.push_back(configuration_[key][i].asString());
-          }
-          else
-          {
-            ok = false;
-          }
+          target.push_back(configuration_[key][i].asString());
         }
-
-        if (ok)
+        else
         {
-          return true;
+          ok = false;
         }
-
-        break;
       }
 
-      case Json::stringValue:
-        if (allowSingleString)
-        {
-          target.push_back(configuration_[key].asString());
-          return true;
-        }
+      if (ok)
+      {
+        return true;
+      }
+
+      break;
+    }
 
-        break;
+    case Json::stringValue:
+      if (allowSingleString)
+      {
+        target.push_back(configuration_[key].asString());
+        return true;
+      }
 
-      default:
-        break;
+      break;
+
+    default:
+      break;
     }
 
     if (context_ != NULL)
@@ -702,7 +702,7 @@
       target.clear();
 
       for (std::list<std::string>::const_iterator
-             it = lst.begin(); it != lst.end(); ++it)
+           it = lst.begin(); it != lst.end(); ++it)
       {
         target.insert(*it);
       }
@@ -982,7 +982,7 @@
     return OrthancPluginGetImagePitch(context_, image_);
   }
 
-    
+
   const void* OrthancImage::GetBuffer()
   {
     CheckImageAvailable();
@@ -995,7 +995,7 @@
     CheckImageAvailable();
     
     OrthancPluginMemoryBuffer tmp;
-    OrthancPluginCompressPngImage(context_, &tmp, GetPixelFormat(), 
+    OrthancPluginCompressPngImage(context_, &tmp, GetPixelFormat(),
                                   GetWidth(), GetHeight(), GetPitch(), GetBuffer());
 
     target.Assign(tmp);
@@ -1008,7 +1008,7 @@
     CheckImageAvailable();
     
     OrthancPluginMemoryBuffer tmp;
-    OrthancPluginCompressJpegImage(context_, &tmp, GetPixelFormat(), 
+    OrthancPluginCompressJpegImage(context_, &tmp, GetPixelFormat(),
                                    GetWidth(), GetHeight(), GetPitch(), GetBuffer(), quality);
     
     target.Assign(tmp);
@@ -1064,7 +1064,7 @@
 
   FindMatcher::~FindMatcher()
   {
-    // The "worklist_" field 
+    // The "worklist_" field
 
     if (matcher_ != NULL)
     {
@@ -1230,7 +1230,7 @@
                      ") is too old to run this plugin (version " +
                      boost::lexical_cast<std::string>(major) + "." +
                      boost::lexical_cast<std::string>(minor) + "." +
-                     boost::lexical_cast<std::string>(revision) + 
+                     boost::lexical_cast<std::string>(revision) +
                      " is required)");
     
     OrthancPluginLogError(context, s.c_str());
@@ -1244,7 +1244,7 @@
   {
     if (context == NULL)
     {
-      OrthancPluginLogError(context, "Bad Orthanc context in the plugin");      
+      OrthancPluginLogError(context, "Bad Orthanc context in the plugin");
       return false;
     }
 
@@ -1256,16 +1256,16 @@
 
     // Parse the version of the Orthanc core
     int aa, bb, cc;
-    if ( 
-#ifdef _MSC_VER
-      sscanf_s
-#else
-      sscanf
-#endif
-      (context->orthancVersion, "%4d.%4d.%4d", &aa, &bb, &cc) != 3 ||
-      aa < 0 ||
-      bb < 0 ||
-      cc < 0)
+    if (
+    #ifdef _MSC_VER
+        sscanf_s
+    #else
+        sscanf
+    #endif
+        (context->orthancVersion, "%4d.%4d.%4d", &aa, &bb, &cc) != 3 ||
+        aa < 0 ||
+        bb < 0 ||
+        cc < 0)
     {
       return false;
     }
@@ -1340,7 +1340,7 @@
   {
     if (context_ == NULL)
     {
-      ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_NullPointer);          
+      ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_NullPointer);
     }
 
     peers_ = OrthancPluginGetPeers(context_);
@@ -1484,9 +1484,9 @@
     OrthancPluginMemoryBuffer answer;
     uint16_t status;
     OrthancPluginErrorCode code = OrthancPluginCallPeerApi
-      (context_, &answer, NULL, &status, peers_, 
-       static_cast<uint32_t>(index), OrthancPluginHttpMethod_Get, uri.c_str(),
-       0, NULL, NULL, NULL, 0, timeout_);
+        (context_, &answer, NULL, &status, peers_,
+         static_cast<uint32_t>(index), OrthancPluginHttpMethod_Get, uri.c_str(),
+         0, NULL, NULL, NULL, 0, timeout_);
 
     if (code == OrthancPluginErrorCode_Success)
     {
@@ -1515,7 +1515,7 @@
                            const std::string& uri) const
   {
     MemoryBuffer buffer(context_);
-      
+
     if (DoGet(buffer, index, uri))
     {
       buffer.ToJson(target);
@@ -1527,13 +1527,13 @@
     }
   }
   
-      
+
   bool OrthancPeers::DoGet(Json::Value& target,
                            const std::string& name,
                            const std::string& uri) const
   {
     MemoryBuffer buffer(context_);
-      
+
     if (DoGet(buffer, name, uri))
     {
       buffer.ToJson(target);
@@ -1563,7 +1563,7 @@
                             const std::string& body) const
   {
     MemoryBuffer buffer(context_);
-      
+
     if (DoPost(buffer, index, uri, body))
     {
       buffer.ToJson(target);
@@ -1575,14 +1575,14 @@
     }
   }
   
-      
+
   bool OrthancPeers::DoPost(Json::Value& target,
                             const std::string& name,
                             const std::string& uri,
                             const std::string& body) const
   {
     MemoryBuffer buffer(context_);
-      
+
     if (DoPost(buffer, name, uri, body))
     {
       buffer.ToJson(target);
@@ -1608,9 +1608,9 @@
     OrthancPluginMemoryBuffer answer;
     uint16_t status;
     OrthancPluginErrorCode code = OrthancPluginCallPeerApi
-      (context_, &answer, NULL, &status, peers_, 
-       static_cast<uint32_t>(index), OrthancPluginHttpMethod_Post, uri.c_str(),
-       0, NULL, NULL, body.empty() ? NULL : body.c_str(), body.size(), timeout_);
+        (context_, &answer, NULL, &status, peers_,
+         static_cast<uint32_t>(index), OrthancPluginHttpMethod_Post, uri.c_str(),
+         0, NULL, NULL, body.empty() ? NULL : body.c_str(), body.size(), timeout_);
 
     if (code == OrthancPluginErrorCode_Success)
     {
@@ -1636,9 +1636,9 @@
     OrthancPluginMemoryBuffer answer;
     uint16_t status;
     OrthancPluginErrorCode code = OrthancPluginCallPeerApi
-      (context_, &answer, NULL, &status, peers_, 
-       static_cast<uint32_t>(index), OrthancPluginHttpMethod_Put, uri.c_str(),
-       0, NULL, NULL, body.empty() ? NULL : body.c_str(), body.size(), timeout_);
+        (context_, &answer, NULL, &status, peers_,
+         static_cast<uint32_t>(index), OrthancPluginHttpMethod_Put, uri.c_str(),
+         0, NULL, NULL, body.empty() ? NULL : body.c_str(), body.size(), timeout_);
 
     if (code == OrthancPluginErrorCode_Success)
     {
@@ -1673,9 +1673,9 @@
     OrthancPluginMemoryBuffer answer;
     uint16_t status;
     OrthancPluginErrorCode code = OrthancPluginCallPeerApi
-      (context_, &answer, NULL, &status, peers_, 
-       static_cast<uint32_t>(index), OrthancPluginHttpMethod_Put, uri.c_str(),
-       0, NULL, NULL, NULL, 0, timeout_);
+        (context_, &answer, NULL, &status, peers_,
+         static_cast<uint32_t>(index), OrthancPluginHttpMethod_Put, uri.c_str(),
+         0, NULL, NULL, NULL, 0, timeout_);
 
     if (code == OrthancPluginErrorCode_Success)
     {
@@ -1874,10 +1874,10 @@
     {
       ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange);
     }
-      
+
     progress_ = progress;
   }
-    
+
 
   OrthancJob::OrthancJob(const std::string& jobType) :
     jobType_(jobType),
@@ -1887,7 +1887,7 @@
     ClearSerialized();
   }
 
-    
+
   OrthancPluginJob* OrthancJob::Create(OrthancPluginContext* context,
                                        OrthancJob* job)
   {
@@ -1897,9 +1897,9 @@
     }
 
     OrthancPluginJob* orthanc = OrthancPluginCreateJob(
-      context, job, CallbackFinalize, job->jobType_.c_str(),
-      CallbackGetProgress, CallbackGetContent, CallbackGetSerialized,
-      CallbackStep, CallbackStop, CallbackReset);
+          context, job, CallbackFinalize, job->jobType_.c_str(),
+          CallbackGetProgress, CallbackGetContent, CallbackGetSerialized,
+          CallbackStep, CallbackStop, CallbackReset);
 
     if (orthanc == NULL)
     {