annotate Plugins/Samples/Common/FullOrthancDataset.cpp @ 3387:a48d652f1500

new function OrthancPluginHttpClientChunkedBody(), new class OrthancPlugins::HttpClient
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 05 Jun 2019 17:17:48 +0200
parents 4e43e67f8ecf
children 94f4a18a79cc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2179
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
3060
4e43e67f8ecf preparing for 2019
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
2179
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * In addition, as a special exception, the copyright holders of this
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * program give permission to link the code of its release with the
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * the linked executables. You must obey the GNU General Public License
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * your version of the file(s), but you are not obligated to do so. If
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * you do not wish to do so, delete this exception statement from your
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * version. If you delete this exception statement from all source files
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 * in the program, then also delete it here.
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 *
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * This program is distributed in the hope that it will be useful, but
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * You should have received a copy of the GNU General Public License
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 **/
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #include "FullOrthancDataset.h"
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
2237
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2180
diff changeset
36 #include "OrthancPluginException.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2180
diff changeset
37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2180
diff changeset
38 #include <stdio.h>
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2180
diff changeset
39 #include <cassert>
2179
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 namespace OrthancPlugins
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 {
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 static const Json::Value* AccessTag(const Json::Value& dataset,
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 const DicomTag& tag)
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 {
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 if (dataset.type() != Json::objectValue)
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 {
2237
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2180
diff changeset
48 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
2179
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 }
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 char name[16];
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 sprintf(name, "%04x,%04x", tag.GetGroup(), tag.GetElement());
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 if (!dataset.isMember(name))
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 {
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 return NULL;
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 }
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 const Json::Value& value = dataset[name];
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 if (value.type() != Json::objectValue ||
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 !value.isMember("Name") ||
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 !value.isMember("Type") ||
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 !value.isMember("Value") ||
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 value["Name"].type() != Json::stringValue ||
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 value["Type"].type() != Json::stringValue)
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 {
2237
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2180
diff changeset
67 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
2179
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 }
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 return &value;
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 }
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 static const Json::Value& GetSequenceContent(const Json::Value& sequence)
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 {
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 assert(sequence.type() == Json::objectValue);
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 assert(sequence.isMember("Type"));
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 assert(sequence.isMember("Value"));
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 const Json::Value& value = sequence["Value"];
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 if (sequence["Type"].asString() != "Sequence" ||
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 value.type() != Json::arrayValue)
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 {
2237
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2180
diff changeset
85 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
2179
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 }
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 else
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 {
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 return value;
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 }
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 }
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 static bool GetStringInternal(std::string& result,
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 const Json::Value& tag)
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 {
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 assert(tag.type() == Json::objectValue);
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 assert(tag.isMember("Type"));
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 assert(tag.isMember("Value"));
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 const Json::Value& value = tag["Value"];
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 if (tag["Type"].asString() != "String" ||
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 value.type() != Json::stringValue)
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 {
2237
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2180
diff changeset
106 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
2179
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 }
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 else
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 {
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 result = value.asString();
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 return true;
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 }
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 }
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 const Json::Value* FullOrthancDataset::LookupPath(const DicomPath& path) const
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 {
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 const Json::Value* content = &root_;
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 for (unsigned int depth = 0; depth < path.GetPrefixLength(); depth++)
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 {
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 const Json::Value* sequence = AccessTag(*content, path.GetPrefixTag(depth));
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 if (sequence == NULL)
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 {
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 return NULL;
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 }
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 const Json::Value& nextContent = GetSequenceContent(*sequence);
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 size_t index = path.GetPrefixIndex(depth);
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 if (index >= nextContent.size())
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 {
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 return NULL;
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 }
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 else
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 {
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 content = &nextContent[static_cast<Json::Value::ArrayIndex>(index)];
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 }
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 }
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 return AccessTag(*content, path.GetFinalTag());
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 }
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144
2180
71b8bec8ca91 improvements
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2179
diff changeset
145 void FullOrthancDataset::CheckRoot() const
71b8bec8ca91 improvements
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2179
diff changeset
146 {
71b8bec8ca91 improvements
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2179
diff changeset
147 if (root_.type() != Json::objectValue)
71b8bec8ca91 improvements
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2179
diff changeset
148 {
2237
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2180
diff changeset
149 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
2180
71b8bec8ca91 improvements
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2179
diff changeset
150 }
71b8bec8ca91 improvements
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2179
diff changeset
151 }
71b8bec8ca91 improvements
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2179
diff changeset
152
71b8bec8ca91 improvements
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2179
diff changeset
153
2179
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 FullOrthancDataset::FullOrthancDataset(IOrthancConnection& orthanc,
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 const std::string& uri)
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 {
2180
71b8bec8ca91 improvements
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2179
diff changeset
157 IOrthancConnection::RestApiGet(root_, orthanc, uri);
71b8bec8ca91 improvements
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2179
diff changeset
158 CheckRoot();
71b8bec8ca91 improvements
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2179
diff changeset
159 }
71b8bec8ca91 improvements
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2179
diff changeset
160
71b8bec8ca91 improvements
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2179
diff changeset
161
71b8bec8ca91 improvements
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2179
diff changeset
162 FullOrthancDataset::FullOrthancDataset(const std::string& content)
71b8bec8ca91 improvements
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2179
diff changeset
163 {
71b8bec8ca91 improvements
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2179
diff changeset
164 IOrthancConnection::ParseJson(root_, content);
71b8bec8ca91 improvements
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2179
diff changeset
165 CheckRoot();
2179
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 }
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168
2278
fd5869e3ed5e new constructors in FullOrthancDataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
169 FullOrthancDataset::FullOrthancDataset(const void* content,
fd5869e3ed5e new constructors in FullOrthancDataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
170 size_t size)
fd5869e3ed5e new constructors in FullOrthancDataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
171 {
fd5869e3ed5e new constructors in FullOrthancDataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
172 IOrthancConnection::ParseJson(root_, content, size);
fd5869e3ed5e new constructors in FullOrthancDataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
173 CheckRoot();
fd5869e3ed5e new constructors in FullOrthancDataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
174 }
fd5869e3ed5e new constructors in FullOrthancDataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
175
fd5869e3ed5e new constructors in FullOrthancDataset
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
176
2280
2e7a8ce24be2 new constructor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2278
diff changeset
177 FullOrthancDataset::FullOrthancDataset(const Json::Value& root) :
2e7a8ce24be2 new constructor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2278
diff changeset
178 root_(root)
2e7a8ce24be2 new constructor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2278
diff changeset
179 {
2e7a8ce24be2 new constructor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2278
diff changeset
180 CheckRoot();
2e7a8ce24be2 new constructor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2278
diff changeset
181 }
2e7a8ce24be2 new constructor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2278
diff changeset
182
2e7a8ce24be2 new constructor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2278
diff changeset
183
2179
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 bool FullOrthancDataset::GetStringValue(std::string& result,
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 const DicomPath& path) const
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 {
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 const Json::Value* value = LookupPath(path);
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 if (value == NULL)
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 {
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 return false;
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 }
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 else
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 {
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 return GetStringInternal(result, *value);
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 }
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 }
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 bool FullOrthancDataset::GetSequenceSize(size_t& size,
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 const DicomPath& path) const
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 {
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 const Json::Value* sequence = LookupPath(path);
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 if (sequence == NULL)
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 {
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 return false;
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 }
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 else
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 {
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211 size = GetSequenceContent(*sequence).size();
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 return true;
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 }
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 }
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 }