annotate Resources/Orthanc/Stone/FullOrthancDataset.cpp @ 314:9dc7f1e8716d

reverse the order of the "sizes" field in the IIIF manifest
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 14 Aug 2024 15:52:13 +0200
parents 0683312e21ba
children 196d0e18afa0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
196
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
312
0683312e21ba updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 309
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
0683312e21ba updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 309
diff changeset
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium
309
7020852a8fa9 updated year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 283
diff changeset
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
196
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 *
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * This program is free software: you can redistribute it and/or
212
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 196
diff changeset
10 * modify it under the terms of the GNU Lesser General Public License
196
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * as published by the Free Software Foundation, either version 3 of
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * the License, or (at your option) any later version.
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 *
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful, but
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
212
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 196
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 196
diff changeset
17 * Lesser General Public License for more details.
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 196
diff changeset
18 *
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 196
diff changeset
19 * You should have received a copy of the GNU Lesser General Public
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 196
diff changeset
20 * License along with this program. If not, see
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 196
diff changeset
21 * <http://www.gnu.org/licenses/>.
196
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 **/
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include "FullOrthancDataset.h"
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #include <OrthancException.h>
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 #include <stdio.h>
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 #include <cassert>
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 namespace OrthancStone
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 {
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 static const Json::Value* AccessTag(const Json::Value& dataset,
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 const Orthanc::DicomTag& tag)
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 {
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 if (dataset.type() != Json::objectValue)
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 {
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 }
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 char name[16];
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 sprintf(name, "%04x,%04x", tag.GetGroup(), tag.GetElement());
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 if (!dataset.isMember(name))
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 {
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 return NULL;
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 }
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 const Json::Value& value = dataset[name];
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 if (value.type() != Json::objectValue ||
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 !value.isMember("Name") ||
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 !value.isMember("Type") ||
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 !value.isMember("Value") ||
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 value["Name"].type() != Json::stringValue ||
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 value["Type"].type() != Json::stringValue)
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 {
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 }
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 return &value;
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 }
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 static const Json::Value& GetSequenceContent(const Json::Value& sequence)
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 {
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 assert(sequence.type() == Json::objectValue);
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 assert(sequence.isMember("Type"));
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 assert(sequence.isMember("Value"));
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 const Json::Value& value = sequence["Value"];
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 if (sequence["Type"].asString() != "Sequence" ||
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 value.type() != Json::arrayValue)
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 {
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 }
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 else
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 {
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 return value;
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 }
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 }
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 static bool GetStringInternal(std::string& result,
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 const Json::Value& tag)
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 {
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 assert(tag.type() == Json::objectValue);
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 assert(tag.isMember("Type"));
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 assert(tag.isMember("Value"));
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 const Json::Value& value = tag["Value"];
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 if (tag["Type"].asString() != "String" ||
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 value.type() != Json::stringValue)
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 {
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 }
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 else
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 {
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 result = value.asString();
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 return true;
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 }
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 }
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106
239
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
107 const Json::Value* FullOrthancDataset::LookupPath(const Orthanc::DicomPath& path) const
196
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 {
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 const Json::Value* content = &root_;
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 for (unsigned int depth = 0; depth < path.GetPrefixLength(); depth++)
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 {
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 const Json::Value* sequence = AccessTag(*content, path.GetPrefixTag(depth));
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 if (sequence == NULL)
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 {
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 return NULL;
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 }
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 const Json::Value& nextContent = GetSequenceContent(*sequence);
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 size_t index = path.GetPrefixIndex(depth);
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 if (index >= nextContent.size())
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 {
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 return NULL;
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 }
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 else
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 {
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 content = &nextContent[static_cast<Json::Value::ArrayIndex>(index)];
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 }
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 }
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 return AccessTag(*content, path.GetFinalTag());
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 }
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 void FullOrthancDataset::CheckRoot() const
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 {
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 if (root_.type() != Json::objectValue)
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 {
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 }
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 }
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 FullOrthancDataset::FullOrthancDataset(IOrthancConnection& orthanc,
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 const std::string& uri)
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 {
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 IOrthancConnection::RestApiGet(root_, orthanc, uri);
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 CheckRoot();
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 }
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 FullOrthancDataset::FullOrthancDataset(const std::string& content)
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 {
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 IOrthancConnection::ParseJson(root_, content);
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 CheckRoot();
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 }
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 FullOrthancDataset::FullOrthancDataset(const void* content,
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 size_t size)
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 {
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 IOrthancConnection::ParseJson(root_, content, size);
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 CheckRoot();
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 }
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 FullOrthancDataset::FullOrthancDataset(const Json::Value& root) :
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 root_(root)
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 {
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 CheckRoot();
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 }
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 bool FullOrthancDataset::GetStringValue(std::string& result,
239
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
176 const Orthanc::DicomPath& path) const
196
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 {
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 const Json::Value* value = LookupPath(path);
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 if (value == NULL)
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 {
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 return false;
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 }
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 else
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 {
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 return GetStringInternal(result, *value);
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 }
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188 }
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 bool FullOrthancDataset::GetSequenceSize(size_t& size,
239
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
192 const Orthanc::DicomPath& path) const
196
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 {
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 const Json::Value* sequence = LookupPath(path);
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 if (sequence == NULL)
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 {
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 return false;
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 }
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 else
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 {
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 size = GetSequenceContent(*sequence).size();
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 return true;
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 }
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 }
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 }