diff Plugins/Samples/Common/OrthancPluginCppWrapper.h @ 2973:9b734c3e1095

more defensive parsing of responses
author am@osimis.io
date Thu, 06 Dec 2018 10:39:08 +0100
parents e361df74639f
children 5947aeedf41f
line wrap: on
line diff
--- a/Plugins/Samples/Common/OrthancPluginCppWrapper.h	Wed Dec 05 16:30:28 2018 +0100
+++ b/Plugins/Samples/Common/OrthancPluginCppWrapper.h	Thu Dec 06 10:39:08 2018 +0100
@@ -140,6 +140,11 @@
       return buffer_.size;
     }
 
+    bool IsEmpty() const
+    {
+      return GetSize() == 0 || GetData() == NULL;
+    }
+
     void Clear();
 
     void ToString(std::string& target) const;
@@ -443,6 +448,15 @@
                        body.size(), applyPlugins);
   }
 
+  inline bool RestApiPost(Json::Value& result,
+                          const std::string& uri,
+                          const MemoryBuffer& body,
+                          bool applyPlugins)
+  {
+    return RestApiPost(result, uri, body.GetData(),
+                       body.GetSize(), applyPlugins);
+  }
+
   bool RestApiPut(Json::Value& result,
                   const std::string& uri,
                   const char* body,