Mercurial > hg > orthanc
changeset 2058:43cd2ab060c7
cont OrthancPluginCppWrapper
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 30 Jun 2016 08:20:23 +0200 |
parents | 54417b0831c4 |
children | 8e67325eaa3f |
files | Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Plugins/Samples/Common/OrthancPluginCppWrapper.h |
diffstat | 2 files changed, 110 insertions(+), 49 deletions(-) [+] |
line wrap: on
line diff
--- a/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Wed Jun 29 13:40:24 2016 +0200 +++ b/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Thu Jun 30 08:20:23 2016 +0200 @@ -33,6 +33,7 @@ #include "OrthancPluginCppWrapper.h" #include <json/reader.h> +#include <json/writer.h> namespace OrthancPlugins @@ -214,6 +215,24 @@ } + bool MemoryBuffer::RestApiPost(const std::string& uri, + const Json::Value& body, + bool applyPlugins) + { + Json::FastWriter writer; + return RestApiPost(uri, writer.write(body), applyPlugins); + } + + + bool MemoryBuffer::RestApiPut(const std::string& uri, + const Json::Value& body, + bool applyPlugins) + { + Json::FastWriter writer; + return RestApiPut(uri, writer.write(body), applyPlugins); + } + + OrthancString::OrthancString(OrthancPluginContext* context, char* str) : context_(context), @@ -738,10 +757,10 @@ } - bool RestApiGetJson(Json::Value& result, - OrthancPluginContext* context, - const std::string& uri, - bool applyPlugins) + bool RestApiGet(Json::Value& result, + OrthancPluginContext* context, + const std::string& uri, + bool applyPlugins) { MemoryBuffer answer(context); if (!answer.RestApiGet(uri, applyPlugins)) @@ -756,12 +775,12 @@ } - bool RestApiPostJson(Json::Value& result, - OrthancPluginContext* context, - const std::string& uri, - const char* body, - size_t bodySize, - bool applyPlugins) + bool RestApiPost(Json::Value& result, + OrthancPluginContext* context, + const std::string& uri, + const char* body, + size_t bodySize, + bool applyPlugins) { MemoryBuffer answer(context); if (!answer.RestApiPost(uri, body, bodySize, applyPlugins)) @@ -776,12 +795,23 @@ } - bool RestApiPutJson(Json::Value& result, - OrthancPluginContext* context, - const std::string& uri, - const char* body, - size_t bodySize, - bool applyPlugins) + bool RestApiPost(Json::Value& result, + OrthancPluginContext* context, + const std::string& uri, + const Json::Value& body, + bool applyPlugins) + { + Json::FastWriter writer; + return RestApiPost(result, context, uri, writer.write(body), applyPlugins); + } + + + bool RestApiPut(Json::Value& result, + OrthancPluginContext* context, + const std::string& uri, + const char* body, + size_t bodySize, + bool applyPlugins) { MemoryBuffer answer(context); if (!answer.RestApiPut(uri, body, bodySize, applyPlugins)) @@ -796,6 +826,17 @@ } + bool RestApiPut(Json::Value& result, + OrthancPluginContext* context, + const std::string& uri, + const Json::Value& body, + bool applyPlugins) + { + Json::FastWriter writer; + return RestApiPut(result, context, uri, writer.write(body), applyPlugins); + } + + bool RestApiDelete(OrthancPluginContext* context, const std::string& uri, bool applyPlugins)
--- a/Plugins/Samples/Common/OrthancPluginCppWrapper.h Wed Jun 29 13:40:24 2016 +0200 +++ b/Plugins/Samples/Common/OrthancPluginCppWrapper.h Thu Jun 30 08:20:23 2016 +0200 @@ -127,6 +127,14 @@ bool applyPlugins); bool RestApiPost(const std::string& uri, + const Json::Value& body, + bool applyPlugins); + + bool RestApiPut(const std::string& uri, + const Json::Value& body, + bool applyPlugins); + + bool RestApiPost(const std::string& uri, const std::string& body, bool applyPlugins) { @@ -285,49 +293,61 @@ }; - bool RestApiGetJson(Json::Value& result, - OrthancPluginContext* context, - const std::string& uri, - bool applyPlugins); + bool RestApiGet(Json::Value& result, + OrthancPluginContext* context, + const std::string& uri, + bool applyPlugins); - bool RestApiPostJson(Json::Value& result, - OrthancPluginContext* context, - const std::string& uri, - const char* body, - size_t bodySize, - bool applyPlugins); + bool RestApiPost(Json::Value& result, + OrthancPluginContext* context, + const std::string& uri, + const char* body, + size_t bodySize, + bool applyPlugins); + + bool RestApiPost(Json::Value& result, + OrthancPluginContext* context, + const std::string& uri, + const Json::Value& body, + bool applyPlugins); - bool RestApiPutJson(Json::Value& result, - OrthancPluginContext* context, - const std::string& uri, - const char* body, - size_t bodySize, - bool applyPlugins); + inline bool RestApiPost(Json::Value& result, + OrthancPluginContext* context, + const std::string& uri, + const std::string& body, + bool applyPlugins) + { + return RestApiPost(result, context, uri, body.empty() ? NULL : body.c_str(), + body.size(), applyPlugins); + } - inline bool RestApiPostJson(Json::Value& result, - OrthancPluginContext* context, - const std::string& uri, - const std::string& body, - bool applyPlugins) + bool RestApiPut(Json::Value& result, + OrthancPluginContext* context, + const std::string& uri, + const char* body, + size_t bodySize, + bool applyPlugins); + + bool RestApiPut(Json::Value& result, + OrthancPluginContext* context, + const std::string& uri, + const Json::Value& body, + bool applyPlugins); + + inline bool RestApiPut(Json::Value& result, + OrthancPluginContext* context, + const std::string& uri, + const std::string& body, + bool applyPlugins) { - return RestApiPostJson(result, context, uri, body.empty() ? NULL : body.c_str(), - body.size(), applyPlugins); + return RestApiPut(result, context, uri, body.empty() ? NULL : body.c_str(), + body.size(), applyPlugins); } bool RestApiDelete(OrthancPluginContext* context, const std::string& uri, bool applyPlugins); - inline bool RestApiPutJson(Json::Value& result, - OrthancPluginContext* context, - const std::string& uri, - const std::string& body, - bool applyPlugins) - { - return RestApiPutJson(result, context, uri, body.empty() ? NULL : body.c_str(), - body.size(), applyPlugins); - } - bool RestApiDelete(OrthancPluginContext* context, const std::string& uri, bool applyPlugins);