annotate Core/SerializationToolbox.cpp @ 4033:0763630a42ef

removing HAS_EMBEDDED_RESOURCES
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 09 Jun 2020 21:45:54 +0200
parents 5d2348b39392
children
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
3640
94f4a18a79cc upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3128
diff changeset
5 * Copyright (C) 2017-2020 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
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * In addition, as a special exception, the copyright holders of this
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * program give permission to link the code of its release with the
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * the linked executables. You must obey the GNU General Public License
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * your version of the file(s), but you are not obligated to do so. If
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * you do not wish to do so, delete this exception statement from your
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * version. If you delete this exception statement from all source files
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 * in the program, then also delete it here.
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 *
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * This program is distributed in the hope that it will be useful, but
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * You should have received a copy of the GNU General Public License
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 **/
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #include "PrecompiledHeaders.h"
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #include "SerializationToolbox.h"
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #include "OrthancException.h"
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
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
39 #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
40 # 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
41 #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
42
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 namespace Orthanc
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 {
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
45 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
46 const char* name)
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 {
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
48 #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
49 try
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
50 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
51 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
52 return true;
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
53 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
54 catch (OrthancException&)
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 return false;
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
57 }
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
58 #else
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
59 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
60 #endif
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
61 }
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
62
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
63
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
64 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
65 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
66 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
67 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
68 !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
69 value[field.c_str()].type() != Json::stringValue)
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 {
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
71 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
72 "String value expected in field: " + field);
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 }
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
74 else
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
75 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
76 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
77 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
78 }
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
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 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
82 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
83 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
84 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
85 !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
86 (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
87 value[field.c_str()].type() != Json::uintValue))
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 {
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
89 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
90 "Integer value expected in field: " + field);
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 }
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
92 else
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 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
95 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
96 }
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
99 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
100 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
101 int defaultValue)
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 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
104 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
105 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
106 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
107 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
108 {
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
109 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
110 }
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
111 }
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
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
114 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
115 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
116 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
117 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
118
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
119 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
120 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
121 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
122 "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
123 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
124 else
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
125 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
126 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
127 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
128 }
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
129
09798f2b985f added a Timeout argument to every DICOM command + 'TargetAet' not mandatory anymore in /retrieve
Alain Mazy <alain@mazy.be>
parents: 3641
diff changeset
130
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
131 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
132 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
133 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
134 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
135 !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
136 value[field.c_str()].type() != Json::booleanValue)
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 {
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
138 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
139 "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
140 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
141 else
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
142 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
143 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
144 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
145 }
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
147
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
148 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
149 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
150 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
151 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
152 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
153 !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
154 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
155 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
156 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
157 "List of strings expected in field: " + field);
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 }
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
160 const Json::Value& arr = value[field.c_str()];
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
162 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
163
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
164 for (Json::Value::ArrayIndex i = 0; i < arr.size(); i++)
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 if (arr[i].type() != Json::stringValue)
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 {
2966
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
168 throw OrthancException(ErrorCode_BadFileFormat,
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
169 "List of strings expected in field: " + field);
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 }
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
171 else
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 {
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
173 target[i] = arr[i].asString();
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 }
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 }
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
176 }
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
179 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
180 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
181 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
182 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
183 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
184 ReadArrayOfStrings(tmp, value, field);
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
186 target.clear();
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
187 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
188 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
189 target.push_back(tmp[i]);
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 }
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
191 }
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
194 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
195 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
196 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
197 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
198 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
199 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
200
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
201 target.clear();
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
202 for (size_t i = 0; i < tmp.size(); i++)
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 {
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
204 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
205 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
206 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
207
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
209 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
210 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
211 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
212 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
213 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
214 !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
215 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
216 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
217 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
218 "Set of DICOM tags expected in field: " + field);
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 }
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
221 const Json::Value& arr = value[field.c_str()];
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
223 target.clear();
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
224
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
225 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
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 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
228
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
229 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
230 !ParseTagInternal(tag, arr[i].asCString()))
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2657
diff changeset
231 {
2966
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
232 throw OrthancException(ErrorCode_BadFileFormat,
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
233 "Set of DICOM tags expected in field: " + field);
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2657
diff changeset
234 }
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
235 else
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2657
diff changeset
236 {
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
237 target.insert(tag);
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2657
diff changeset
238 }
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2657
diff changeset
239 }
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
240 }
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2657
diff changeset
241
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2657
diff changeset
242
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
243 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
244 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
245 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
246 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
247 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
248 !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
249 value[field.c_str()].type() != Json::objectValue)
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2662
diff changeset
250 {
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
251 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
252 "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
253 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
254
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
255 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
256
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
257 target.clear();
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 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
260
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
261 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
262 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
263 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
264
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
265 if (tmp.type() != Json::stringValue)
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2662
diff changeset
266 {
2966
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
267 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
268 "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
269 }
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
270 else
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2662
diff changeset
271 {
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
272 target[members[i]] = tmp.asString();
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2662
diff changeset
273 }
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2662
diff changeset
274 }
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
275 }
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2662
diff changeset
276
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2662
diff changeset
277
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
278 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
279 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
280 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
281 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
282 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
283 !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
284 value[field.c_str()].type() != Json::objectValue)
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2662
diff changeset
285 {
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
286 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
287 "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
288 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
289
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
290 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
291
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
292 target.clear();
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 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
295
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
296 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
297 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
298 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
299
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
300 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
301
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
302 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
303 tmp.type() != Json::stringValue)
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2662
diff changeset
304 {
2966
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
305 throw OrthancException(ErrorCode_BadFileFormat,
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
306 "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
307 }
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
308 else
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2657
diff changeset
309 {
3991
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
310 target[tag] = tmp.asString();
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2662
diff changeset
311 }
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2662
diff changeset
312 }
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
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
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
315
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
316 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
317 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
318 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
319 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
320 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
321 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
322 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
323 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
324 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
325
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
326 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
327
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
328 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
329 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
330 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
331 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
332 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
333 }
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
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
336 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
337 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
338 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
339 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
340 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
341 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
342 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
343 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
344 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
345
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
346 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
347
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
348 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
349
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
350 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
351 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
352 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
353 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
354 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
355 }
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
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
358 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
359 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
360 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
361 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
362 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
363 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
364 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
365 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
366 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
367
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
368 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
369
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
370 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
371
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
372 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
373 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
374 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
375 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
376 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
377 }
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
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
380 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
381 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
382 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
383 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
384 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
385 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
386 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
387 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
388 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
389
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
390 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
391
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
392 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
393
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
394 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
395 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
396 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
397 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
398 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
399 }
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
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
402 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
403 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
404 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
405 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
406 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
407 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
408 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
409 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
410 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
411
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
412 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
413
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
414 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
415
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
416 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
417 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
418 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
419 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
420 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
421 }
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
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
424 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
425 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
426 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
427 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
428 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
429 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
430 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
431 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
432 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
433
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
434 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
435
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
436 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
437
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
438 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
439 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
440 {
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
441 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
442 }
5d2348b39392 turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
443 }
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
444 }