Mercurial > hg > orthanc-stone
comparison RenderingPlugin/Sources/OrthancPluginConnection.cpp @ 1885:ddaee6b96501
retrieving rt-struct info
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 14 Jan 2022 19:04:05 +0100 |
parents | |
children | 07964689cb0b |
comparison
equal
deleted
inserted
replaced
1884:0c6923982fdd | 1885:ddaee6b96501 |
---|---|
1 /** | |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium | |
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium | |
7 * | |
8 * This program is free software: you can redistribute it and/or | |
9 * modify it under the terms of the GNU General Public License as | |
10 * published by the Free Software Foundation, either version 3 of the | |
11 * License, or (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, but | |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 * General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
20 **/ | |
21 | |
22 | |
23 #include "OrthancPluginConnection.h" | |
24 | |
25 #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" | |
26 | |
27 #include <OrthancException.h> | |
28 | |
29 namespace OrthancStone | |
30 { | |
31 void OrthancPluginConnection::RestApiGet(std::string& result, | |
32 const std::string& uri) | |
33 { | |
34 OrthancPlugins::MemoryBuffer tmp; | |
35 | |
36 if (tmp.RestApiGet(uri, false)) | |
37 { | |
38 tmp.ToString(result); | |
39 } | |
40 else | |
41 { | |
42 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); | |
43 } | |
44 } | |
45 | |
46 | |
47 void OrthancPluginConnection::RestApiPost(std::string& result, | |
48 const std::string& uri, | |
49 const std::string& body) | |
50 { | |
51 OrthancPlugins::MemoryBuffer tmp; | |
52 | |
53 if (tmp.RestApiPost(uri, body.empty() ? NULL : body.c_str(), body.size(), false)) | |
54 { | |
55 tmp.ToString(result); | |
56 } | |
57 else | |
58 { | |
59 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); | |
60 } | |
61 } | |
62 | |
63 | |
64 void OrthancPluginConnection::RestApiPut(std::string& result, | |
65 const std::string& uri, | |
66 const std::string& body) | |
67 { | |
68 OrthancPlugins::MemoryBuffer tmp; | |
69 | |
70 if (tmp.RestApiPut(uri, body.empty() ? NULL : body.c_str(), body.size(), false)) | |
71 { | |
72 tmp.ToString(result); | |
73 } | |
74 else | |
75 { | |
76 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); | |
77 } | |
78 } | |
79 | |
80 | |
81 void OrthancPluginConnection::RestApiDelete(const std::string& uri) | |
82 { | |
83 if (!OrthancPlugins::RestApiDelete(uri, false)) | |
84 { | |
85 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); | |
86 } | |
87 } | |
88 } |