comparison 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
comparison
equal deleted inserted replaced
2968:e361df74639f 2973:9b734c3e1095
138 size_t GetSize() const 138 size_t GetSize() const
139 { 139 {
140 return buffer_.size; 140 return buffer_.size;
141 } 141 }
142 142
143 bool IsEmpty() const
144 {
145 return GetSize() == 0 || GetData() == NULL;
146 }
147
143 void Clear(); 148 void Clear();
144 149
145 void ToString(std::string& target) const; 150 void ToString(std::string& target) const;
146 151
147 void ToJson(Json::Value& target) const; 152 void ToJson(Json::Value& target) const;
439 const std::string& body, 444 const std::string& body,
440 bool applyPlugins) 445 bool applyPlugins)
441 { 446 {
442 return RestApiPost(result, uri, body.empty() ? NULL : body.c_str(), 447 return RestApiPost(result, uri, body.empty() ? NULL : body.c_str(),
443 body.size(), applyPlugins); 448 body.size(), applyPlugins);
449 }
450
451 inline bool RestApiPost(Json::Value& result,
452 const std::string& uri,
453 const MemoryBuffer& body,
454 bool applyPlugins)
455 {
456 return RestApiPost(result, uri, body.GetData(),
457 body.GetSize(), applyPlugins);
444 } 458 }
445 459
446 bool RestApiPut(Json::Value& result, 460 bool RestApiPut(Json::Value& result,
447 const std::string& uri, 461 const std::string& uri,
448 const char* body, 462 const char* body,