diff Resources/Orthanc/Plugins/Samples/Common/OrthancPluginCppWrapper.h @ 107:a3e8ac8b7256

support for OpenBSD
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 23 Aug 2017 11:10:48 +0200
parents ff0ef01c332c
children a18bfe1fdd62
line wrap: on
line diff
--- a/Resources/Orthanc/Plugins/Samples/Common/OrthancPluginCppWrapper.h	Wed Mar 22 15:53:48 2017 +0100
+++ b/Resources/Orthanc/Plugins/Samples/Common/OrthancPluginCppWrapper.h	Wed Aug 23 11:10:48 2017 +0200
@@ -39,11 +39,20 @@
 #include <boost/noncopyable.hpp>
 #include <boost/lexical_cast.hpp>
 #include <json/value.h>
+#include <list>
+#include <set>
+
 
 
-#if (ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER >= 2 ||   \
-     (ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER == 1 &&  \
-      ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER >= 2))
+#define ORTHANC_PLUGINS_VERSION_IS_ABOVE(major, minor, revision) \
+  (ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER > major ||               \
+   (ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER == major &&             \
+    (ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER > minor ||             \
+     (ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER == minor &&           \
+      ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER >= revision))))
+  
+
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 2, 0)
 // The "OrthancPluginFindMatcher()" primitive was introduced in Orthanc 1.2.0
 #  define HAS_ORTHANC_PLUGIN_FIND_MATCHER  1
 #else
@@ -66,6 +75,8 @@
 
     void Check(OrthancPluginErrorCode code);
 
+    bool CheckHttp(OrthancPluginErrorCode code);
+
   public:
     MemoryBuffer(OrthancPluginContext* context);
 
@@ -151,6 +162,20 @@
                      OrthancPluginDicomToJsonFormat format,
                      OrthancPluginDicomToJsonFlags flags,
                      uint32_t maxStringLength);
+
+    bool HttpGet(const std::string& url,
+                 const std::string& username,
+                 const std::string& password);
+ 
+    bool HttpPost(const std::string& url,
+                  const std::string& body,
+                  const std::string& username,
+                  const std::string& password);
+ 
+    bool HttpPut(const std::string& url,
+                 const std::string& body,
+                 const std::string& username,
+                 const std::string& password);
   };
 
 
@@ -232,6 +257,14 @@
     bool LookupFloatValue(float& target,
                           const std::string& key) const;
 
+    bool LookupListOfStrings(std::list<std::string>& target,
+                             const std::string& key,
+                             bool allowSingleString) const;
+
+    bool LookupSetOfStrings(std::set<std::string>& target,
+                            const std::string& key,
+                            bool allowSingleString) const;
+
     std::string GetStringValue(const std::string& key,
                                const std::string& defaultValue) const;
 
@@ -403,6 +436,11 @@
                      const std::string& uri,
                      bool applyPlugins);
 
+  bool HttpDelete(OrthancPluginContext* context,
+                  const std::string& url,
+                  const std::string& username,
+                  const std::string& password);
+
   inline void LogError(OrthancPluginContext* context,
                        const std::string& message)
   {
@@ -430,6 +468,11 @@
     }
   }
 
+  void ReportMinimalOrthancVersion(OrthancPluginContext* context,
+                                   unsigned int major,
+                                   unsigned int minor,
+                                   unsigned int revision);
+  
   bool CheckMinimalOrthancVersion(OrthancPluginContext* context,
                                   unsigned int major,
                                   unsigned int minor,