annotate OrthancFramework/Sources/SerializationToolbox.cpp @ 4596:2b64cc3cea99

added OrthancPluginContentType_DicomUntilPixelData
author Alain Mazy <am@osimis.io>
date Wed, 17 Mar 2021 15:31:26 +0100
parents f4dbdb2dcba6
children add0337b928a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
4437
d9473bd5ed43 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
8 * modify it under the terms of the GNU Lesser General Public License
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
10 * the License, or (at your option) any later version.
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
15 * Lesser General Public License for more details.
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
18 * License along with this program. If not, see
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
19 * <http://www.gnu.org/licenses/>.
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #include "PrecompiledHeaders.h"
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "SerializationToolbox.h"
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include "OrthancException.h"
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2966
diff changeset
28 #if ORTHANC_ENABLE_DCMTK == 1
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2966
diff changeset
29 # include "DicomParsing/FromDcmtkBridge.h"
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2966
diff changeset
30 #endif
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2966
diff changeset
31
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 namespace Orthanc
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 {
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
34 static bool ParseTagInternal(DicomTag& tag,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
35 const char* name)
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 {
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2966
diff changeset
37 #if ORTHANC_ENABLE_DCMTK == 1
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
38 try
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
39 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
40 tag = FromDcmtkBridge::ParseTag(name);
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
41 return true;
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
42 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
43 catch (OrthancException&)
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
44 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
45 return false;
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
46 }
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2966
diff changeset
47 #else
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
48 return DicomTag::ParseHexadecimal(tag, name);
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2966
diff changeset
49 #endif
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
50 }
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2966
diff changeset
51
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2966
diff changeset
52
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
53 std::string SerializationToolbox::ReadString(const Json::Value& value,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
54 const std::string& field)
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
55 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
56 if (value.type() != Json::objectValue ||
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
57 !value.isMember(field.c_str()) ||
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
58 value[field.c_str()].type() != Json::stringValue)
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 {
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
60 throw OrthancException(ErrorCode_BadFileFormat,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
61 "String value expected in field: " + field);
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 }
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
63 else
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
64 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
65 return value[field.c_str()].asString();
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
66 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
67 }
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
70 int SerializationToolbox::ReadInteger(const Json::Value& value,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
71 const std::string& field)
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
72 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
73 if (value.type() != Json::objectValue ||
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
74 !value.isMember(field.c_str()) ||
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
75 (value[field.c_str()].type() != Json::intValue &&
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
76 value[field.c_str()].type() != Json::uintValue))
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 {
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
78 throw OrthancException(ErrorCode_BadFileFormat,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
79 "Integer value expected in field: " + field);
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 }
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
81 else
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
82 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
83 return value[field.c_str()].asInt();
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
84 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
85 }
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
88 int SerializationToolbox::ReadInteger(const Json::Value& value,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
89 const std::string& field,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
90 int defaultValue)
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
91 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
92 if (value.isMember(field.c_str()))
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
93 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
94 return ReadInteger(value, field);
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
95 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
96 else
3870
09798f2b985f added a Timeout argument to every DICOM command + 'TargetAet' not mandatory anymore in /retrieve
Alain Mazy <alain@mazy.be>
parents: 3641
diff changeset
97 {
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
98 return defaultValue;
3870
09798f2b985f added a Timeout argument to every DICOM command + 'TargetAet' not mandatory anymore in /retrieve
Alain Mazy <alain@mazy.be>
parents: 3641
diff changeset
99 }
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
100 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
101
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
102
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
103 unsigned int SerializationToolbox::ReadUnsignedInteger(const Json::Value& value,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
104 const std::string& field)
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
105 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
106 int tmp = ReadInteger(value, field);
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
107
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
108 if (tmp < 0)
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
109 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
110 throw OrthancException(ErrorCode_BadFileFormat,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
111 "Unsigned integer value expected in field: " + field);
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
112 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
113 else
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
114 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
115 return static_cast<unsigned int>(tmp);
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
116 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
117 }
3870
09798f2b985f added a Timeout argument to every DICOM command + 'TargetAet' not mandatory anymore in /retrieve
Alain Mazy <alain@mazy.be>
parents: 3641
diff changeset
118
09798f2b985f added a Timeout argument to every DICOM command + 'TargetAet' not mandatory anymore in /retrieve
Alain Mazy <alain@mazy.be>
parents: 3641
diff changeset
119
4451
f4dbdb2dcba6 new configuration option "MaximumPduLength" to tune the maximum PDU length
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
120 unsigned int SerializationToolbox::ReadUnsignedInteger(const Json::Value& value,
f4dbdb2dcba6 new configuration option "MaximumPduLength" to tune the maximum PDU length
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
121 const std::string& field,
f4dbdb2dcba6 new configuration option "MaximumPduLength" to tune the maximum PDU length
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
122 unsigned int defaultValue)
f4dbdb2dcba6 new configuration option "MaximumPduLength" to tune the maximum PDU length
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
123 {
f4dbdb2dcba6 new configuration option "MaximumPduLength" to tune the maximum PDU length
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
124 if (value.isMember(field.c_str()))
f4dbdb2dcba6 new configuration option "MaximumPduLength" to tune the maximum PDU length
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
125 {
f4dbdb2dcba6 new configuration option "MaximumPduLength" to tune the maximum PDU length
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
126 return ReadUnsignedInteger(value, field);
f4dbdb2dcba6 new configuration option "MaximumPduLength" to tune the maximum PDU length
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
127 }
f4dbdb2dcba6 new configuration option "MaximumPduLength" to tune the maximum PDU length
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
128 else
f4dbdb2dcba6 new configuration option "MaximumPduLength" to tune the maximum PDU length
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
129 {
f4dbdb2dcba6 new configuration option "MaximumPduLength" to tune the maximum PDU length
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
130 return defaultValue;
f4dbdb2dcba6 new configuration option "MaximumPduLength" to tune the maximum PDU length
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
131 }
f4dbdb2dcba6 new configuration option "MaximumPduLength" to tune the maximum PDU length
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
132 }
f4dbdb2dcba6 new configuration option "MaximumPduLength" to tune the maximum PDU length
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
133
f4dbdb2dcba6 new configuration option "MaximumPduLength" to tune the maximum PDU length
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
134
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
135 bool SerializationToolbox::ReadBoolean(const Json::Value& value,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
136 const std::string& field)
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
137 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
138 if (value.type() != Json::objectValue ||
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
139 !value.isMember(field.c_str()) ||
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
140 value[field.c_str()].type() != Json::booleanValue)
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 {
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
142 throw OrthancException(ErrorCode_BadFileFormat,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
143 "Boolean value expected in field: " + field);
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
144 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
145 else
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
146 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
147 return value[field.c_str()].asBool();
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
148 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
149 }
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
151
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
152 void SerializationToolbox::ReadArrayOfStrings(std::vector<std::string>& target,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
153 const Json::Value& value,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
154 const std::string& field)
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
155 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
156 if (value.type() != Json::objectValue ||
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
157 !value.isMember(field.c_str()) ||
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
158 value[field.c_str()].type() != Json::arrayValue)
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
159 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
160 throw OrthancException(ErrorCode_BadFileFormat,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
161 "List of strings expected in field: " + field);
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 }
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
164 const Json::Value& arr = value[field.c_str()];
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
166 target.resize(arr.size());
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
167
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
168 for (Json::Value::ArrayIndex i = 0; i < arr.size(); i++)
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 {
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
170 if (arr[i].type() != Json::stringValue)
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 {
2966
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
172 throw OrthancException(ErrorCode_BadFileFormat,
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
173 "List of strings expected in field: " + field);
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 }
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
175 else
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 {
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
177 target[i] = arr[i].asString();
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 }
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 }
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
180 }
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
183 void SerializationToolbox::ReadListOfStrings(std::list<std::string>& target,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
184 const Json::Value& value,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
185 const std::string& field)
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
186 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
187 std::vector<std::string> tmp;
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
188 ReadArrayOfStrings(tmp, value, field);
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
190 target.clear();
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
191 for (size_t i = 0; i < tmp.size(); i++)
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
192 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
193 target.push_back(tmp[i]);
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 }
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
195 }
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
198 void SerializationToolbox::ReadSetOfStrings(std::set<std::string>& target,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
199 const Json::Value& value,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
200 const std::string& field)
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
201 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
202 std::vector<std::string> tmp;
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
203 ReadArrayOfStrings(tmp, value, field);
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
204
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
205 target.clear();
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
206 for (size_t i = 0; i < tmp.size(); i++)
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 {
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
208 target.insert(tmp[i]);
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
209 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
210 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
211
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
213 void SerializationToolbox::ReadSetOfTags(std::set<DicomTag>& target,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
214 const Json::Value& value,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
215 const std::string& field)
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
216 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
217 if (value.type() != Json::objectValue ||
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
218 !value.isMember(field.c_str()) ||
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
219 value[field.c_str()].type() != Json::arrayValue)
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
220 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
221 throw OrthancException(ErrorCode_BadFileFormat,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
222 "Set of DICOM tags expected in field: " + field);
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 }
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
225 const Json::Value& arr = value[field.c_str()];
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
227 target.clear();
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
228
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
229 for (Json::Value::ArrayIndex i = 0; i < arr.size(); i++)
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2657
diff changeset
230 {
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
231 DicomTag tag(0, 0);
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
232
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
233 if (arr[i].type() != Json::stringValue ||
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
234 !ParseTagInternal(tag, arr[i].asCString()))
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2657
diff changeset
235 {
2966
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
236 throw OrthancException(ErrorCode_BadFileFormat,
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
237 "Set of DICOM tags expected in field: " + field);
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2657
diff changeset
238 }
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
239 else
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2657
diff changeset
240 {
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
241 target.insert(tag);
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2657
diff changeset
242 }
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2657
diff changeset
243 }
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
244 }
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2657
diff changeset
245
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2657
diff changeset
246
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
247 void SerializationToolbox::ReadMapOfStrings(std::map<std::string, std::string>& target,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
248 const Json::Value& value,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
249 const std::string& field)
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
250 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
251 if (value.type() != Json::objectValue ||
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
252 !value.isMember(field.c_str()) ||
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
253 value[field.c_str()].type() != Json::objectValue)
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2662
diff changeset
254 {
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
255 throw OrthancException(ErrorCode_BadFileFormat,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
256 "Associative array of strings to strings expected in field: " + field);
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
257 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
258
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
259 const Json::Value& source = value[field.c_str()];
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
260
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
261 target.clear();
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
262
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
263 Json::Value::Members members = source.getMemberNames();
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
264
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
265 for (size_t i = 0; i < members.size(); i++)
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
266 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
267 const Json::Value& tmp = source[members[i]];
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
268
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
269 if (tmp.type() != Json::stringValue)
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2662
diff changeset
270 {
2966
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
271 throw OrthancException(ErrorCode_BadFileFormat,
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
272 "Associative array of string to strings expected in field: " + field);
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2662
diff changeset
273 }
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
274 else
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2662
diff changeset
275 {
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
276 target[members[i]] = tmp.asString();
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2662
diff changeset
277 }
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2662
diff changeset
278 }
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
279 }
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2662
diff changeset
280
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2662
diff changeset
281
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
282 void SerializationToolbox::ReadMapOfTags(std::map<DicomTag, std::string>& target,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
283 const Json::Value& value,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
284 const std::string& field)
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
285 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
286 if (value.type() != Json::objectValue ||
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
287 !value.isMember(field.c_str()) ||
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
288 value[field.c_str()].type() != Json::objectValue)
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2662
diff changeset
289 {
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
290 throw OrthancException(ErrorCode_BadFileFormat,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
291 "Associative array of DICOM tags to strings expected in field: " + field);
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
292 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
293
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
294 const Json::Value& source = value[field.c_str()];
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
295
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
296 target.clear();
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
297
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
298 Json::Value::Members members = source.getMemberNames();
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
299
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
300 for (size_t i = 0; i < members.size(); i++)
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
301 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
302 const Json::Value& tmp = source[members[i]];
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
303
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
304 DicomTag tag(0, 0);
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
305
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
306 if (!ParseTagInternal(tag, members[i].c_str()) ||
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
307 tmp.type() != Json::stringValue)
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2662
diff changeset
308 {
2966
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
309 throw OrthancException(ErrorCode_BadFileFormat,
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
310 "Associative array of DICOM tags to strings expected in field: " + field);
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2662
diff changeset
311 }
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
312 else
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2657
diff changeset
313 {
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
314 target[tag] = tmp.asString();
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2662
diff changeset
315 }
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2662
diff changeset
316 }
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317 }
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
318
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
319
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
320 void SerializationToolbox::WriteArrayOfStrings(Json::Value& target,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
321 const std::vector<std::string>& values,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
322 const std::string& field)
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
323 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
324 if (target.type() != Json::objectValue ||
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
325 target.isMember(field.c_str()))
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
326 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
327 throw OrthancException(ErrorCode_BadFileFormat);
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
328 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
329
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
330 Json::Value& value = target[field];
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
331
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
332 value = Json::arrayValue;
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
333 for (size_t i = 0; i < values.size(); i++)
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
334 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
335 value.append(values[i]);
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
336 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
337 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
338
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
339
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
340 void SerializationToolbox::WriteListOfStrings(Json::Value& target,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
341 const std::list<std::string>& values,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
342 const std::string& field)
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
343 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
344 if (target.type() != Json::objectValue ||
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
345 target.isMember(field.c_str()))
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
346 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
347 throw OrthancException(ErrorCode_BadFileFormat);
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
348 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
349
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
350 Json::Value& value = target[field];
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
351
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
352 value = Json::arrayValue;
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
353
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
354 for (std::list<std::string>::const_iterator it = values.begin();
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
355 it != values.end(); ++it)
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
356 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
357 value.append(*it);
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
358 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
359 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
360
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
361
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
362 void SerializationToolbox::WriteSetOfStrings(Json::Value& target,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
363 const std::set<std::string>& values,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
364 const std::string& field)
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
365 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
366 if (target.type() != Json::objectValue ||
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
367 target.isMember(field.c_str()))
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
368 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
369 throw OrthancException(ErrorCode_BadFileFormat);
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
370 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
371
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
372 Json::Value& value = target[field];
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
373
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
374 value = Json::arrayValue;
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
375
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
376 for (std::set<std::string>::const_iterator it = values.begin();
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
377 it != values.end(); ++it)
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
378 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
379 value.append(*it);
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
380 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
381 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
382
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
383
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
384 void SerializationToolbox::WriteSetOfTags(Json::Value& target,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
385 const std::set<DicomTag>& tags,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
386 const std::string& field)
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
387 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
388 if (target.type() != Json::objectValue ||
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
389 target.isMember(field.c_str()))
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
390 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
391 throw OrthancException(ErrorCode_BadFileFormat);
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
392 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
393
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
394 Json::Value& value = target[field];
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
395
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
396 value = Json::arrayValue;
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
397
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
398 for (std::set<DicomTag>::const_iterator it = tags.begin();
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
399 it != tags.end(); ++it)
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
400 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
401 value.append(it->Format());
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
402 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
403 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
404
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
405
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
406 void SerializationToolbox::WriteMapOfStrings(Json::Value& target,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
407 const std::map<std::string, std::string>& values,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
408 const std::string& field)
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
409 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
410 if (target.type() != Json::objectValue ||
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
411 target.isMember(field.c_str()))
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
412 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
413 throw OrthancException(ErrorCode_BadFileFormat);
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
414 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
415
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
416 Json::Value& value = target[field];
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
417
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
418 value = Json::objectValue;
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
419
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
420 for (std::map<std::string, std::string>::const_iterator
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
421 it = values.begin(); it != values.end(); ++it)
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
422 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
423 value[it->first] = it->second;
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
424 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
425 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
426
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
427
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
428 void SerializationToolbox::WriteMapOfTags(Json::Value& target,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
429 const std::map<DicomTag, std::string>& values,
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
430 const std::string& field)
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
431 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
432 if (target.type() != Json::objectValue ||
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
433 target.isMember(field.c_str()))
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
434 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
435 throw OrthancException(ErrorCode_BadFileFormat);
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
436 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
437
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
438 Json::Value& value = target[field];
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
439
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
440 value = Json::objectValue;
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
441
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
442 for (std::map<DicomTag, std::string>::const_iterator
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
443 it = values.begin(); it != values.end(); ++it)
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
444 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
445 value[it->first.Format()] = it->second;
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
446 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
447 }
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
448 }