comparison 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
comparison
equal deleted inserted replaced
105:42dcf1438943 107:a3e8ac8b7256
37 37
38 #include <orthanc/OrthancCPlugin.h> 38 #include <orthanc/OrthancCPlugin.h>
39 #include <boost/noncopyable.hpp> 39 #include <boost/noncopyable.hpp>
40 #include <boost/lexical_cast.hpp> 40 #include <boost/lexical_cast.hpp>
41 #include <json/value.h> 41 #include <json/value.h>
42 42 #include <list>
43 43 #include <set>
44 #if (ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER >= 2 || \ 44
45 (ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER == 1 && \ 45
46 ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER >= 2)) 46
47 #define ORTHANC_PLUGINS_VERSION_IS_ABOVE(major, minor, revision) \
48 (ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER > major || \
49 (ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER == major && \
50 (ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER > minor || \
51 (ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER == minor && \
52 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER >= revision))))
53
54
55 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 2, 0)
47 // The "OrthancPluginFindMatcher()" primitive was introduced in Orthanc 1.2.0 56 // The "OrthancPluginFindMatcher()" primitive was introduced in Orthanc 1.2.0
48 # define HAS_ORTHANC_PLUGIN_FIND_MATCHER 1 57 # define HAS_ORTHANC_PLUGIN_FIND_MATCHER 1
49 #else 58 #else
50 # define HAS_ORTHANC_PLUGIN_FIND_MATCHER 0 59 # define HAS_ORTHANC_PLUGIN_FIND_MATCHER 0
51 #endif 60 #endif
63 private: 72 private:
64 OrthancPluginContext* context_; 73 OrthancPluginContext* context_;
65 OrthancPluginMemoryBuffer buffer_; 74 OrthancPluginMemoryBuffer buffer_;
66 75
67 void Check(OrthancPluginErrorCode code); 76 void Check(OrthancPluginErrorCode code);
77
78 bool CheckHttp(OrthancPluginErrorCode code);
68 79
69 public: 80 public:
70 MemoryBuffer(OrthancPluginContext* context); 81 MemoryBuffer(OrthancPluginContext* context);
71 82
72 ~MemoryBuffer() 83 ~MemoryBuffer()
149 160
150 void DicomToJson(Json::Value& target, 161 void DicomToJson(Json::Value& target,
151 OrthancPluginDicomToJsonFormat format, 162 OrthancPluginDicomToJsonFormat format,
152 OrthancPluginDicomToJsonFlags flags, 163 OrthancPluginDicomToJsonFlags flags,
153 uint32_t maxStringLength); 164 uint32_t maxStringLength);
165
166 bool HttpGet(const std::string& url,
167 const std::string& username,
168 const std::string& password);
169
170 bool HttpPost(const std::string& url,
171 const std::string& body,
172 const std::string& username,
173 const std::string& password);
174
175 bool HttpPut(const std::string& url,
176 const std::string& body,
177 const std::string& username,
178 const std::string& password);
154 }; 179 };
155 180
156 181
157 class OrthancString : public boost::noncopyable 182 class OrthancString : public boost::noncopyable
158 { 183 {
229 bool LookupBooleanValue(bool& target, 254 bool LookupBooleanValue(bool& target,
230 const std::string& key) const; 255 const std::string& key) const;
231 256
232 bool LookupFloatValue(float& target, 257 bool LookupFloatValue(float& target,
233 const std::string& key) const; 258 const std::string& key) const;
259
260 bool LookupListOfStrings(std::list<std::string>& target,
261 const std::string& key,
262 bool allowSingleString) const;
263
264 bool LookupSetOfStrings(std::set<std::string>& target,
265 const std::string& key,
266 bool allowSingleString) const;
234 267
235 std::string GetStringValue(const std::string& key, 268 std::string GetStringValue(const std::string& key,
236 const std::string& defaultValue) const; 269 const std::string& defaultValue) const;
237 270
238 int GetIntegerValue(const std::string& key, 271 int GetIntegerValue(const std::string& key,
401 434
402 bool RestApiDelete(OrthancPluginContext* context, 435 bool RestApiDelete(OrthancPluginContext* context,
403 const std::string& uri, 436 const std::string& uri,
404 bool applyPlugins); 437 bool applyPlugins);
405 438
439 bool HttpDelete(OrthancPluginContext* context,
440 const std::string& url,
441 const std::string& username,
442 const std::string& password);
443
406 inline void LogError(OrthancPluginContext* context, 444 inline void LogError(OrthancPluginContext* context,
407 const std::string& message) 445 const std::string& message)
408 { 446 {
409 if (context != NULL) 447 if (context != NULL)
410 { 448 {
428 { 466 {
429 OrthancPluginLogInfo(context, message.c_str()); 467 OrthancPluginLogInfo(context, message.c_str());
430 } 468 }
431 } 469 }
432 470
471 void ReportMinimalOrthancVersion(OrthancPluginContext* context,
472 unsigned int major,
473 unsigned int minor,
474 unsigned int revision);
475
433 bool CheckMinimalOrthancVersion(OrthancPluginContext* context, 476 bool CheckMinimalOrthancVersion(OrthancPluginContext* context,
434 unsigned int major, 477 unsigned int major,
435 unsigned int minor, 478 unsigned int minor,
436 unsigned int revision); 479 unsigned int revision);
437 480