Mercurial > hg > orthanc
annotate Plugins/Samples/Common/OrthancPluginCppWrapper.cpp @ 2176:fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 25 Nov 2016 12:07:36 +0100 |
parents | aa2915963531 |
children | 11420238f337 |
rev | line source |
---|---|
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 * |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * This program is free software: you can redistribute it and/or |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * modify it under the terms of the GNU General Public License as |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * published by the Free Software Foundation, either version 3 of the |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * License, or (at your option) any later version. |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * In addition, as a special exception, the copyright holders of this |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * program give permission to link the code of its release with the |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * that use the same license as the "OpenSSL" library), and distribute |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * the linked executables. You must obey the GNU General Public License |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * in all respects for all of the code used other than "OpenSSL". If you |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * modify file(s) with this exception, you may extend this exception to |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * your version of the file(s), but you are not obligated to do so. If |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * you do not wish to do so, delete this exception statement from your |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 * version. If you delete this exception statement from all source files |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 * in the program, then also delete it here. |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 * |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 * This program is distributed in the hope that it will be useful, but |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 * WITHOUT ANY WARRANTY; without even the implied warranty of |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 * General Public License for more details. |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 * |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 * You should have received a copy of the GNU General Public License |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 **/ |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 #include "OrthancPluginCppWrapper.h" |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 #include <json/reader.h> |
2058
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
36 #include <json/writer.h> |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 |
2176
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
39 #if HAS_ORTHANC_EXCEPTION == 1 |
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
40 # define THROW_EXCEPTION(code) throw Orthanc::OrthancException(static_cast<Orthanc::ErrorCode>(code)) |
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
41 #else |
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
42 # define THROW_EXCEPTION(code) throw PluginException(code) |
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
43 #endif |
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
44 |
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
45 |
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
46 |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 namespace OrthancPlugins |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 { |
2176
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
49 void ThrowException(OrthancPluginErrorCode code) |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 { |
2176
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
51 THROW_EXCEPTION(code); |
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
52 } |
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
53 |
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
54 |
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
55 const char* GetErrorDescription(OrthancPluginContext* context, |
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
56 OrthancPluginErrorCode code) |
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
57 { |
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
58 const char* description = OrthancPluginGetErrorDescription(context, code); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 if (description) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 return description; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 return "No description available"; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 |
2059 | 69 |
2176
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
70 #if HAS_ORTHANC_EXCEPTION == 0 |
2059 | 71 void PluginException::Check(OrthancPluginErrorCode code) |
72 { | |
73 if (code != OrthancPluginErrorCode_Success) | |
74 { | |
2176
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
75 THROW_EXCEPTION(code); |
2059 | 76 } |
77 } | |
2176
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
78 #endif |
2059 | 79 |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 |
2062
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
81 void MemoryBuffer::Check(OrthancPluginErrorCode code) |
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
82 { |
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
83 if (code != OrthancPluginErrorCode_Success) |
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
84 { |
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
85 // Prevent using garbage information |
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
86 buffer_.data = NULL; |
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
87 buffer_.size = 0; |
2176
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
88 THROW_EXCEPTION(code); |
2062
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
89 } |
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
90 } |
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
91 |
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
92 |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 MemoryBuffer::MemoryBuffer(OrthancPluginContext* context) : |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 context_(context) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 buffer_.data = NULL; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 buffer_.size = 0; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 void MemoryBuffer::Clear() |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 if (buffer_.data != NULL) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 OrthancPluginFreeMemoryBuffer(context_, &buffer_); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 buffer_.data = NULL; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 buffer_.size = 0; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 void MemoryBuffer::Assign(OrthancPluginMemoryBuffer& other) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 Clear(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 buffer_.data = other.data; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 buffer_.size = other.size; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 other.data = NULL; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 other.size = 0; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 void MemoryBuffer::ToString(std::string& target) const |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 if (buffer_.size == 0) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 target.clear(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 target.assign(reinterpret_cast<const char*>(buffer_.data), buffer_.size); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 void MemoryBuffer::ToJson(Json::Value& target) const |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 if (buffer_.data == NULL || |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 buffer_.size == 0) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 { |
2176
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
142 THROW_EXCEPTION(OrthancPluginErrorCode_InternalError); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 const char* tmp = reinterpret_cast<const char*>(buffer_.data); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 Json::Reader reader; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 if (!reader.parse(tmp, tmp + buffer_.size, target)) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 OrthancPluginLogError(context_, "Cannot convert some memory buffer to JSON"); |
2176
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
151 THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 bool MemoryBuffer::RestApiGet(const std::string& uri, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 bool applyPlugins) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 Clear(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 OrthancPluginErrorCode error; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 if (applyPlugins) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 error = OrthancPluginRestApiGetAfterPlugins(context_, &buffer_, uri.c_str()); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
167 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
168 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 error = OrthancPluginRestApiGet(context_, &buffer_, uri.c_str()); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 if (error == OrthancPluginErrorCode_Success) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
173 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
174 return true; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
175 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
176 else if (error == OrthancPluginErrorCode_UnknownResource || |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
177 error == OrthancPluginErrorCode_InexistentItem) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
178 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
179 return false; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
180 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 { |
2176
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
183 THROW_EXCEPTION(error); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
186 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
187 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
188 bool MemoryBuffer::RestApiPost(const std::string& uri, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
189 const char* body, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
190 size_t bodySize, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
191 bool applyPlugins) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
192 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
193 Clear(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
194 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
195 OrthancPluginErrorCode error; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
196 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
197 if (applyPlugins) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
198 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
199 error = OrthancPluginRestApiPostAfterPlugins(context_, &buffer_, uri.c_str(), body, bodySize); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
200 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
201 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
202 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
203 error = OrthancPluginRestApiPost(context_, &buffer_, uri.c_str(), body, bodySize); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
204 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
205 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
206 if (error == OrthancPluginErrorCode_Success) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
207 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
208 return true; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
209 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
210 else if (error == OrthancPluginErrorCode_UnknownResource || |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
211 error == OrthancPluginErrorCode_InexistentItem) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
212 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
213 return false; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
214 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
215 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
216 { |
2176
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
217 THROW_EXCEPTION(error); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
218 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
219 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
220 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
221 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
222 bool MemoryBuffer::RestApiPut(const std::string& uri, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
223 const char* body, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
224 size_t bodySize, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
225 bool applyPlugins) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
226 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
227 Clear(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
228 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
229 OrthancPluginErrorCode error; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
230 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
231 if (applyPlugins) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
232 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
233 error = OrthancPluginRestApiPutAfterPlugins(context_, &buffer_, uri.c_str(), body, bodySize); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
234 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
235 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
236 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
237 error = OrthancPluginRestApiPut(context_, &buffer_, uri.c_str(), body, bodySize); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
238 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
239 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
240 if (error == OrthancPluginErrorCode_Success) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
241 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
242 return true; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
243 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
244 else if (error == OrthancPluginErrorCode_UnknownResource || |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
245 error == OrthancPluginErrorCode_InexistentItem) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
246 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
247 return false; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
248 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
249 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
250 { |
2176
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
251 THROW_EXCEPTION(error); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
252 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
253 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
254 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
255 |
2058
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
256 bool MemoryBuffer::RestApiPost(const std::string& uri, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
257 const Json::Value& body, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
258 bool applyPlugins) |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
259 { |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
260 Json::FastWriter writer; |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
261 return RestApiPost(uri, writer.write(body), applyPlugins); |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
262 } |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
263 |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
264 |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
265 bool MemoryBuffer::RestApiPut(const std::string& uri, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
266 const Json::Value& body, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
267 bool applyPlugins) |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
268 { |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
269 Json::FastWriter writer; |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
270 return RestApiPut(uri, writer.write(body), applyPlugins); |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
271 } |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
272 |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
273 |
2059 | 274 void MemoryBuffer::CreateDicom(const Json::Value& tags, |
275 OrthancPluginCreateDicomFlags flags) | |
276 { | |
277 Clear(); | |
278 | |
279 Json::FastWriter writer; | |
280 std::string s = writer.write(tags); | |
281 | |
2062
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
282 Check(OrthancPluginCreateDicom(context_, &buffer_, s.c_str(), NULL, flags)); |
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
283 } |
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
284 |
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
285 |
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
286 void MemoryBuffer::ReadFile(const std::string& path) |
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
287 { |
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
288 Clear(); |
40ffd0e8676a
generation of etag in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
289 Check(OrthancPluginReadFile(context_, &buffer_, path.c_str())); |
2059 | 290 } |
291 | |
292 | |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
293 OrthancString::OrthancString(OrthancPluginContext* context, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
294 char* str) : |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
295 context_(context), |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
296 str_(str) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
297 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
298 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
299 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
300 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
301 void OrthancString::Clear() |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
302 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
303 if (str_ != NULL) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
304 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
305 OrthancPluginFreeString(context_, str_); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
306 str_ = NULL; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
307 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
308 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
309 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
310 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
311 void OrthancString::ToString(std::string& target) const |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
312 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
313 if (str_ == NULL) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
314 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
315 target.clear(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
316 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
317 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
318 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
319 target.assign(str_); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
320 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
321 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
322 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
323 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
324 void OrthancString::ToJson(Json::Value& target) const |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
325 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
326 if (str_ == NULL) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
327 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
328 OrthancPluginLogError(context_, "Cannot convert an empty memory buffer to JSON"); |
2176
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
329 THROW_EXCEPTION(OrthancPluginErrorCode_InternalError); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
330 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
331 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
332 Json::Reader reader; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
333 if (!reader.parse(str_, target)) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
334 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
335 OrthancPluginLogError(context_, "Cannot convert some memory buffer to JSON"); |
2176
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
336 THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
337 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
338 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
339 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
340 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
341 OrthancConfiguration::OrthancConfiguration(OrthancPluginContext* context) : |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
342 context_(context) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
343 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
344 OrthancString str(context, OrthancPluginGetConfiguration(context)); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
345 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
346 if (str.GetContent() == NULL) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
347 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
348 OrthancPluginLogError(context, "Cannot access the Orthanc configuration"); |
2176
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
349 THROW_EXCEPTION(OrthancPluginErrorCode_InternalError); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
350 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
351 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
352 str.ToJson(configuration_); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
353 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
354 if (configuration_.type() != Json::objectValue) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
355 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
356 OrthancPluginLogError(context, "Unable to read the Orthanc configuration"); |
2176
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
357 THROW_EXCEPTION(OrthancPluginErrorCode_InternalError); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
358 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
359 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
360 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
361 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
362 OrthancPluginContext* OrthancConfiguration::GetContext() const |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
363 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
364 if (context_ == NULL) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
365 { |
2176
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
366 THROW_EXCEPTION(OrthancPluginErrorCode_Plugin); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
367 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
368 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
369 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
370 return context_; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
371 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
372 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
373 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
374 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
375 std::string OrthancConfiguration::GetPath(const std::string& key) const |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
376 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
377 if (path_.empty()) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
378 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
379 return key; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
380 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
381 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
382 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
383 return path_ + "." + key; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
384 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
385 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
386 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
387 |
2167
aa2915963531
"Folders" sub-configuration in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2112
diff
changeset
|
388 bool OrthancConfiguration::IsSection(const std::string& key) const |
aa2915963531
"Folders" sub-configuration in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2112
diff
changeset
|
389 { |
aa2915963531
"Folders" sub-configuration in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2112
diff
changeset
|
390 assert(configuration_.type() == Json::objectValue); |
aa2915963531
"Folders" sub-configuration in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2112
diff
changeset
|
391 |
aa2915963531
"Folders" sub-configuration in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2112
diff
changeset
|
392 return (configuration_.isMember(key) && |
aa2915963531
"Folders" sub-configuration in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2112
diff
changeset
|
393 configuration_[key].type() == Json::objectValue); |
aa2915963531
"Folders" sub-configuration in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2112
diff
changeset
|
394 } |
aa2915963531
"Folders" sub-configuration in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2112
diff
changeset
|
395 |
aa2915963531
"Folders" sub-configuration in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2112
diff
changeset
|
396 |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
397 void OrthancConfiguration::GetSection(OrthancConfiguration& target, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
398 const std::string& key) const |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
399 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
400 assert(configuration_.type() == Json::objectValue); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
401 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
402 target.context_ = context_; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
403 target.path_ = GetPath(key); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
404 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
405 if (!configuration_.isMember(key)) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
406 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
407 target.configuration_ = Json::objectValue; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
408 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
409 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
410 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
411 if (configuration_[key].type() != Json::objectValue) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
412 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
413 if (context_ != NULL) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
414 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
415 std::string s = "The configuration section \"" + target.path_ + "\" is not an associative array as expected"; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
416 OrthancPluginLogError(context_, s.c_str()); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
417 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
418 |
2176
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
419 THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
420 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
421 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
422 target.configuration_ = configuration_[key]; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
423 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
424 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
425 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
426 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
427 bool OrthancConfiguration::LookupStringValue(std::string& target, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
428 const std::string& key) const |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
429 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
430 assert(configuration_.type() == Json::objectValue); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
431 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
432 if (!configuration_.isMember(key)) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
433 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
434 return false; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
435 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
436 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
437 if (configuration_[key].type() != Json::stringValue) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
438 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
439 if (context_ != NULL) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
440 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
441 std::string s = "The configuration option \"" + GetPath(key) + "\" is not a string as expected"; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
442 OrthancPluginLogError(context_, s.c_str()); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
443 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
444 |
2176
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
445 THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
446 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
447 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
448 target = configuration_[key].asString(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
449 return true; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
450 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
451 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
452 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
453 bool OrthancConfiguration::LookupIntegerValue(int& target, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
454 const std::string& key) const |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
455 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
456 assert(configuration_.type() == Json::objectValue); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
457 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
458 if (!configuration_.isMember(key)) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
459 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
460 return false; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
461 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
462 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
463 switch (configuration_[key].type()) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
464 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
465 case Json::intValue: |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
466 target = configuration_[key].asInt(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
467 return true; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
468 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
469 case Json::uintValue: |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
470 target = configuration_[key].asUInt(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
471 return true; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
472 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
473 default: |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
474 if (context_ != NULL) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
475 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
476 std::string s = "The configuration option \"" + GetPath(key) + "\" is not an integer as expected"; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
477 OrthancPluginLogError(context_, s.c_str()); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
478 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
479 |
2176
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
480 THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
481 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
482 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
483 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
484 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
485 bool OrthancConfiguration::LookupUnsignedIntegerValue(unsigned int& target, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
486 const std::string& key) const |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
487 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
488 int tmp; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
489 if (!LookupIntegerValue(tmp, key)) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
490 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
491 return false; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
492 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
493 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
494 if (tmp < 0) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
495 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
496 if (context_ != NULL) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
497 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
498 std::string s = "The configuration option \"" + GetPath(key) + "\" is not a positive integer as expected"; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
499 OrthancPluginLogError(context_, s.c_str()); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
500 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
501 |
2176
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
502 THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
503 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
504 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
505 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
506 target = static_cast<unsigned int>(tmp); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
507 return true; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
508 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
509 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
510 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
511 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
512 bool OrthancConfiguration::LookupBooleanValue(bool& target, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
513 const std::string& key) const |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
514 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
515 assert(configuration_.type() == Json::objectValue); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
516 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
517 if (!configuration_.isMember(key)) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
518 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
519 return false; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
520 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
521 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
522 if (configuration_[key].type() != Json::booleanValue) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
523 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
524 if (context_ != NULL) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
525 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
526 std::string s = "The configuration option \"" + GetPath(key) + "\" is not a Boolean as expected"; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
527 OrthancPluginLogError(context_, s.c_str()); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
528 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
529 |
2176
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
530 THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
531 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
532 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
533 target = configuration_[key].asBool(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
534 return true; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
535 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
536 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
537 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
538 bool OrthancConfiguration::LookupFloatValue(float& target, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
539 const std::string& key) const |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
540 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
541 assert(configuration_.type() == Json::objectValue); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
542 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
543 if (!configuration_.isMember(key)) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
544 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
545 return false; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
546 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
547 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
548 switch (configuration_[key].type()) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
549 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
550 case Json::realValue: |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
551 target = configuration_[key].asFloat(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
552 return true; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
553 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
554 case Json::intValue: |
2112
82461d1e8e17
removal warning with MSVC
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2109
diff
changeset
|
555 target = static_cast<float>(configuration_[key].asInt()); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
556 return true; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
557 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
558 case Json::uintValue: |
2112
82461d1e8e17
removal warning with MSVC
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2109
diff
changeset
|
559 target = static_cast<float>(configuration_[key].asUInt()); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
560 return true; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
561 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
562 default: |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
563 if (context_ != NULL) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
564 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
565 std::string s = "The configuration option \"" + GetPath(key) + "\" is not an integer as expected"; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
566 OrthancPluginLogError(context_, s.c_str()); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
567 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
568 |
2176
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
569 THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
570 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
571 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
572 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
573 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
574 std::string OrthancConfiguration::GetStringValue(const std::string& key, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
575 const std::string& defaultValue) const |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
576 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
577 std::string tmp; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
578 if (LookupStringValue(tmp, key)) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
579 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
580 return tmp; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
581 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
582 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
583 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
584 return defaultValue; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
585 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
586 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
587 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
588 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
589 int OrthancConfiguration::GetIntegerValue(const std::string& key, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
590 int defaultValue) const |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
591 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
592 int tmp; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
593 if (LookupIntegerValue(tmp, key)) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
594 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
595 return tmp; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
596 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
597 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
598 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
599 return defaultValue; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
600 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
601 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
602 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
603 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
604 unsigned int OrthancConfiguration::GetUnsignedIntegerValue(const std::string& key, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
605 unsigned int defaultValue) const |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
606 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
607 unsigned int tmp; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
608 if (LookupUnsignedIntegerValue(tmp, key)) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
609 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
610 return tmp; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
611 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
612 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
613 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
614 return defaultValue; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
615 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
616 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
617 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
618 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
619 bool OrthancConfiguration::GetBooleanValue(const std::string& key, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
620 bool defaultValue) const |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
621 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
622 bool tmp; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
623 if (LookupBooleanValue(tmp, key)) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
624 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
625 return tmp; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
626 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
627 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
628 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
629 return defaultValue; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
630 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
631 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
632 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
633 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
634 float OrthancConfiguration::GetFloatValue(const std::string& key, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
635 float defaultValue) const |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
636 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
637 float tmp; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
638 if (LookupFloatValue(tmp, key)) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
639 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
640 return tmp; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
641 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
642 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
643 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
644 return defaultValue; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
645 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
646 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
647 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
648 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
649 void OrthancImage::Clear() |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
650 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
651 if (image_ != NULL) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
652 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
653 OrthancPluginFreeImage(context_, image_); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
654 image_ = NULL; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
655 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
656 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
657 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
658 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
659 void OrthancImage::CheckImageAvailable() |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
660 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
661 if (image_ == NULL) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
662 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
663 OrthancPluginLogError(context_, "Trying to access a NULL image"); |
2176
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
664 THROW_EXCEPTION(OrthancPluginErrorCode_ParameterOutOfRange); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
665 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
666 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
667 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
668 |
2048 | 669 OrthancImage::OrthancImage(OrthancPluginContext* context) : |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
670 context_(context), |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
671 image_(NULL) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
672 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
673 if (context == NULL) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
674 { |
2176
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
675 THROW_EXCEPTION(OrthancPluginErrorCode_ParameterOutOfRange); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
676 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
677 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
678 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
679 |
2048 | 680 OrthancImage::OrthancImage(OrthancPluginContext* context, |
681 OrthancPluginImage* image) : | |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
682 context_(context), |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
683 image_(image) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
684 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
685 if (context == NULL) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
686 { |
2176
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
687 THROW_EXCEPTION(OrthancPluginErrorCode_ParameterOutOfRange); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
688 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
689 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
690 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
691 |
2048 | 692 OrthancImage::OrthancImage(OrthancPluginContext* context, |
693 OrthancPluginPixelFormat format, | |
694 uint32_t width, | |
695 uint32_t height) : | |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
696 context_(context) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
697 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
698 if (context == NULL) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
699 { |
2176
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
700 THROW_EXCEPTION(OrthancPluginErrorCode_ParameterOutOfRange); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
701 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
702 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
703 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
704 image_ = OrthancPluginCreateImage(context, format, width, height); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
705 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
706 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
707 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
708 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
709 void OrthancImage::UncompressPngImage(const void* data, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
710 size_t size) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
711 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
712 Clear(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
713 image_ = OrthancPluginUncompressImage(context_, data, size, OrthancPluginImageFormat_Png); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
714 if (image_ == NULL) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
715 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
716 OrthancPluginLogError(context_, "Cannot uncompress a PNG image"); |
2176
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
717 THROW_EXCEPTION(OrthancPluginErrorCode_ParameterOutOfRange); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
718 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
719 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
720 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
721 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
722 void OrthancImage::UncompressJpegImage(const void* data, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
723 size_t size) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
724 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
725 Clear(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
726 image_ = OrthancPluginUncompressImage(context_, data, size, OrthancPluginImageFormat_Jpeg); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
727 if (image_ == NULL) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
728 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
729 OrthancPluginLogError(context_, "Cannot uncompress a JPEG image"); |
2176
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
730 THROW_EXCEPTION(OrthancPluginErrorCode_ParameterOutOfRange); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
731 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
732 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
733 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
734 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
735 void OrthancImage::DecodeDicomImage(const void* data, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
736 size_t size, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
737 unsigned int frame) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
738 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
739 Clear(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
740 image_ = OrthancPluginDecodeDicomImage(context_, data, size, frame); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
741 if (image_ == NULL) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
742 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
743 OrthancPluginLogError(context_, "Cannot uncompress a DICOM image"); |
2176
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
744 THROW_EXCEPTION(OrthancPluginErrorCode_ParameterOutOfRange); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
745 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
746 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
747 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
748 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
749 OrthancPluginPixelFormat OrthancImage::GetPixelFormat() |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
750 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
751 CheckImageAvailable(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
752 return OrthancPluginGetImagePixelFormat(context_, image_); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
753 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
754 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
755 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
756 unsigned int OrthancImage::GetWidth() |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
757 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
758 CheckImageAvailable(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
759 return OrthancPluginGetImageWidth(context_, image_); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
760 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
761 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
762 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
763 unsigned int OrthancImage::GetHeight() |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
764 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
765 CheckImageAvailable(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
766 return OrthancPluginGetImageHeight(context_, image_); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
767 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
768 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
769 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
770 unsigned int OrthancImage::GetPitch() |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
771 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
772 CheckImageAvailable(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
773 return OrthancPluginGetImagePitch(context_, image_); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
774 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
775 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
776 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
777 const void* OrthancImage::GetBuffer() |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
778 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
779 CheckImageAvailable(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
780 return OrthancPluginGetImageBuffer(context_, image_); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
781 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
782 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
783 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
784 void OrthancImage::CompressPngImage(MemoryBuffer& target) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
785 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
786 CheckImageAvailable(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
787 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
788 OrthancPluginMemoryBuffer tmp; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
789 OrthancPluginCompressPngImage(context_, &tmp, GetPixelFormat(), |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
790 GetWidth(), GetHeight(), GetPitch(), GetBuffer()); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
791 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
792 target.Assign(tmp); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
793 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
794 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
795 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
796 void OrthancImage::CompressJpegImage(MemoryBuffer& target, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
797 uint8_t quality) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
798 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
799 CheckImageAvailable(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
800 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
801 OrthancPluginMemoryBuffer tmp; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
802 OrthancPluginCompressJpegImage(context_, &tmp, GetPixelFormat(), |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
803 GetWidth(), GetHeight(), GetPitch(), GetBuffer(), quality); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
804 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
805 target.Assign(tmp); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
806 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
807 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
808 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
809 void OrthancImage::AnswerPngImage(OrthancPluginRestOutput* output) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
810 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
811 CheckImageAvailable(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
812 OrthancPluginCompressAndAnswerPngImage(context_, output, GetPixelFormat(), |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
813 GetWidth(), GetHeight(), GetPitch(), GetBuffer()); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
814 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
815 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
816 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
817 void OrthancImage::AnswerJpegImage(OrthancPluginRestOutput* output, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
818 uint8_t quality) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
819 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
820 CheckImageAvailable(); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
821 OrthancPluginCompressAndAnswerJpegImage(context_, output, GetPixelFormat(), |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
822 GetWidth(), GetHeight(), GetPitch(), GetBuffer(), quality); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
823 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
824 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
825 |
2058
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
826 bool RestApiGet(Json::Value& result, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
827 OrthancPluginContext* context, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
828 const std::string& uri, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
829 bool applyPlugins) |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
830 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
831 MemoryBuffer answer(context); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
832 if (!answer.RestApiGet(uri, applyPlugins)) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
833 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
834 return false; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
835 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
836 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
837 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
838 answer.ToJson(result); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
839 return true; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
840 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
841 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
842 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
843 |
2058
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
844 bool RestApiPost(Json::Value& result, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
845 OrthancPluginContext* context, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
846 const std::string& uri, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
847 const char* body, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
848 size_t bodySize, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
849 bool applyPlugins) |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
850 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
851 MemoryBuffer answer(context); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
852 if (!answer.RestApiPost(uri, body, bodySize, applyPlugins)) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
853 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
854 return false; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
855 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
856 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
857 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
858 answer.ToJson(result); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
859 return true; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
860 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
861 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
862 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
863 |
2058
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
864 bool RestApiPost(Json::Value& result, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
865 OrthancPluginContext* context, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
866 const std::string& uri, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
867 const Json::Value& body, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
868 bool applyPlugins) |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
869 { |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
870 Json::FastWriter writer; |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
871 return RestApiPost(result, context, uri, writer.write(body), applyPlugins); |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
872 } |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
873 |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
874 |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
875 bool RestApiPut(Json::Value& result, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
876 OrthancPluginContext* context, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
877 const std::string& uri, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
878 const char* body, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
879 size_t bodySize, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
880 bool applyPlugins) |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
881 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
882 MemoryBuffer answer(context); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
883 if (!answer.RestApiPut(uri, body, bodySize, applyPlugins)) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
884 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
885 return false; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
886 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
887 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
888 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
889 answer.ToJson(result); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
890 return true; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
891 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
892 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
893 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
894 |
2058
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
895 bool RestApiPut(Json::Value& result, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
896 OrthancPluginContext* context, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
897 const std::string& uri, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
898 const Json::Value& body, |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
899 bool applyPlugins) |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
900 { |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
901 Json::FastWriter writer; |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
902 return RestApiPut(result, context, uri, writer.write(body), applyPlugins); |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
903 } |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
904 |
43cd2ab060c7
cont OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2048
diff
changeset
|
905 |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
906 bool RestApiDelete(OrthancPluginContext* context, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
907 const std::string& uri, |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
908 bool applyPlugins) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
909 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
910 OrthancPluginErrorCode error; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
911 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
912 if (applyPlugins) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
913 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
914 error = OrthancPluginRestApiDeleteAfterPlugins(context, uri.c_str()); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
915 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
916 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
917 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
918 error = OrthancPluginRestApiDelete(context, uri.c_str()); |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
919 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
920 |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
921 if (error == OrthancPluginErrorCode_Success) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
922 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
923 return true; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
924 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
925 else if (error == OrthancPluginErrorCode_UnknownResource || |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
926 error == OrthancPluginErrorCode_InexistentItem) |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
927 { |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
928 return false; |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
929 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
930 else |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
931 { |
2176
fead5549aaa7
introduction of HAS_ORTHANC_EXCEPTION to avoid PluginException if not necessary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2167
diff
changeset
|
932 THROW_EXCEPTION(error); |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
933 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
934 } |
2109
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
935 |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
936 |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
937 static void ReportIncompatibleVersion(OrthancPluginContext* context, |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
938 unsigned int major, |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
939 unsigned int minor, |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
940 unsigned int revision) |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
941 { |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
942 char buf[128]; |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
943 sprintf(buf, "Your version of the Orthanc core (%s) is too old to run this plugin (%d.%d.%d is required)", |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
944 context->orthancVersion, major, minor, revision); |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
945 OrthancPluginLogError(context, buf); |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
946 } |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
947 |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
948 |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
949 bool CheckMinimalOrthancVersion(OrthancPluginContext* context, |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
950 unsigned int major, |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
951 unsigned int minor, |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
952 unsigned int revision) |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
953 { |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
954 if (context == NULL) |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
955 { |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
956 OrthancPluginLogError(context, "Bad Orthanc context in the plugin"); |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
957 return false; |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
958 } |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
959 |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
960 if (!strcmp(context->orthancVersion, "mainline")) |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
961 { |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
962 // Assume compatibility with the mainline |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
963 return true; |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
964 } |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
965 |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
966 // Parse the version of the Orthanc core |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
967 int aa, bb, cc; |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
968 if ( |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
969 #ifdef _MSC_VER |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
970 sscanf_s |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
971 #else |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
972 sscanf |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
973 #endif |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
974 (context->orthancVersion, "%4d.%4d.%4d", &aa, &bb, &cc) != 3 || |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
975 aa < 0 || |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
976 bb < 0 || |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
977 cc < 0) |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
978 { |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
979 throw false; |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
980 } |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
981 |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
982 unsigned int a = static_cast<unsigned int>(aa); |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
983 unsigned int b = static_cast<unsigned int>(bb); |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
984 unsigned int c = static_cast<unsigned int>(cc); |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
985 |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
986 // Check the major version number |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
987 |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
988 if (a > major) |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
989 { |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
990 return true; |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
991 } |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
992 |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
993 if (a < major) |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
994 { |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
995 ReportIncompatibleVersion(context, major, minor, revision); |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
996 return false; |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
997 } |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
998 |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
999 |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1000 // Check the minor version number |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1001 assert(a == major); |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1002 |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1003 if (b > minor) |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1004 { |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1005 return true; |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1006 } |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1007 |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1008 if (b < minor) |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1009 { |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1010 ReportIncompatibleVersion(context, major, minor, revision); |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1011 return false; |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1012 } |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1013 |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1014 // Check the patch level version number |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1015 assert(a == major && b == minor); |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1016 |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1017 if (c >= revision) |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1018 { |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1019 return true; |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1020 } |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1021 else |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1022 { |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1023 ReportIncompatibleVersion(context, major, minor, revision); |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1024 return false; |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1025 } |
d5c29fd74ffa
OrthancPlugins::CheckMinimalOrthancVersion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2062
diff
changeset
|
1026 } |
2047
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1027 } |
438f86ee19fc
toolbox shared by all plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1028 |