Mercurial > hg > orthanc
annotate OrthancFramework/Sources/DicomFormat/DicomValue.cpp @ 5853:4d932683049d get-scu tip
very first implementation of C-Get SCU
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Tue, 29 Oct 2024 17:25:49 +0100 |
parents | f7adfb22e20e |
children |
rev | line source |
---|---|
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
5640
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5323
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * 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
|
10 * 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
|
11 * 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
|
12 * the License, or (at your option) any later version. |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * This program is distributed in the hope that it will be useful, but |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * WITHOUT ANY WARRANTY; without even the implied warranty of |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * 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
|
17 * Lesser General Public License for more details. |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * |
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
|
19 * 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
|
20 * 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
|
21 * <http://www.gnu.org/licenses/>. |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 **/ |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 #include "../PrecompiledHeaders.h" |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 #include "DicomValue.h" |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 #include "../OrthancException.h" |
2863
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
29 #include "../SerializationToolbox.h" |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 #include "../Toolbox.h" |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
32 #include <boost/lexical_cast.hpp> |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
33 |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 namespace Orthanc |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 { |
4297 | 36 DicomValue::DicomValue() : |
4296
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
37 type_(Type_Null) |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
38 { |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
39 } |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
40 |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
41 |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
42 DicomValue::DicomValue(const DicomValue& other) : |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 type_(other.type_), |
5044
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
44 content_(other.content_), |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
45 sequenceJson_(other.sequenceJson_) |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 { |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 } |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 DicomValue::DicomValue(const std::string& content, |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 bool isBinary) : |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 type_(isBinary ? Type_Binary : Type_String), |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 content_(content) |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 { |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 } |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 DicomValue::DicomValue(const char* data, |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 size_t size, |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 bool isBinary) : |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 type_(isBinary ? Type_Binary : Type_String) |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 { |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 content_.assign(data, size); |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 } |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 |
5044
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
66 DicomValue::DicomValue(const Json::Value& value) : |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
67 type_(Type_SequenceAsJson), |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
68 sequenceJson_(value) |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
69 { |
5323
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
70 if (value.type() != Json::arrayValue) |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
71 { |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
72 throw OrthancException(ErrorCode_BadParameterType); |
138e9d0c08c1
added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
73 } |
5044
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
74 } |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 const std::string& DicomValue::GetContent() const |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 { |
5044
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
78 if (type_ == Type_Null || type_ == Type_SequenceAsJson) |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 { |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 throw OrthancException(ErrorCode_BadParameterType); |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 } |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 else |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 { |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 return content_; |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 } |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 } |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 |
5044
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
88 const Json::Value& DicomValue::GetSequenceContent() const |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
89 { |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
90 if (type_ != Type_SequenceAsJson) |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
91 { |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
92 throw OrthancException(ErrorCode_BadParameterType); |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
93 } |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
94 else |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
95 { |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
96 return sequenceJson_; |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
97 } |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
98 } |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
99 |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
100 |
4296
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
101 bool DicomValue::IsNull() const |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
102 { |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
103 return type_ == Type_Null; |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
104 } |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
105 |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
106 bool DicomValue::IsBinary() const |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
107 { |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
108 return type_ == Type_Binary; |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
109 } |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
110 |
5044
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
111 bool DicomValue::IsString() const |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
112 { |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
113 return type_ == Type_String; |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
114 } |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
115 |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
116 bool DicomValue::IsSequence() const |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
117 { |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
118 return type_ == Type_SequenceAsJson; |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
119 } |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 DicomValue* DicomValue::Clone() const |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 { |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 return new DicomValue(*this); |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 } |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 |
2139 | 127 #if ORTHANC_ENABLE_BASE64 == 1 |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 void DicomValue::FormatDataUriScheme(std::string& target, |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 const std::string& mime) const |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 { |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 Toolbox::EncodeBase64(target, GetContent()); |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 target.insert(0, "data:" + mime + ";base64,"); |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 } |
4304 | 134 |
135 void DicomValue::FormatDataUriScheme(std::string& target) const | |
136 { | |
137 FormatDataUriScheme(target, MIME_BINARY); | |
138 } | |
1761
f4286d99ee0a
fix sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
139 #endif |
f4286d99ee0a
fix sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
140 |
4775
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
141 bool DicomValue::ParseInteger32(int32_t& result) const |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
142 { |
5044
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
143 if (!IsString()) |
4775
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
144 { |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
145 return false; |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
146 } |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
147 else |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
148 { |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
149 return SerializationToolbox::ParseInteger32(result, GetContent()); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
150 } |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
151 } |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
152 |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
153 bool DicomValue::ParseInteger64(int64_t& result) const |
3519
fc26659493b6
added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents:
3060
diff
changeset
|
154 { |
5044
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
155 if (!IsString()) |
4775
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
156 { |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
157 return false; |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
158 } |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
159 else |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
160 { |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
161 return SerializationToolbox::ParseInteger64(result, GetContent()); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
162 } |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
163 } |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
164 |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
165 bool DicomValue::ParseUnsignedInteger32(uint32_t& result) const |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
166 { |
5044
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
167 if (!IsString()) |
4775
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
168 { |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
169 return false; |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
170 } |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
171 else |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
172 { |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
173 return SerializationToolbox::ParseUnsignedInteger32(result, GetContent()); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
174 } |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
175 } |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
176 |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
177 bool DicomValue::ParseUnsignedInteger64(uint64_t& result) const |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
178 { |
5044
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
179 if (!IsString()) |
3519
fc26659493b6
added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents:
3060
diff
changeset
|
180 { |
fc26659493b6
added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents:
3060
diff
changeset
|
181 return false; |
fc26659493b6
added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents:
3060
diff
changeset
|
182 } |
4775
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
183 else |
3519
fc26659493b6
added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents:
3060
diff
changeset
|
184 { |
4775
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
185 return SerializationToolbox::ParseUnsignedInteger64(result, GetContent()); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
186 } |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
187 } |
3519
fc26659493b6
added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents:
3060
diff
changeset
|
188 |
4775
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
189 bool DicomValue::ParseFloat(float& result) const |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
190 { |
5044
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
191 if (!IsString()) |
3519
fc26659493b6
added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents:
3060
diff
changeset
|
192 { |
fc26659493b6
added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents:
3060
diff
changeset
|
193 return false; |
fc26659493b6
added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents:
3060
diff
changeset
|
194 } |
4775
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
195 else |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
196 { |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
197 return SerializationToolbox::ParseFloat(result, GetContent()); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
198 } |
3519
fc26659493b6
added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents:
3060
diff
changeset
|
199 } |
fc26659493b6
added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents:
3060
diff
changeset
|
200 |
4775
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
201 bool DicomValue::ParseDouble(double& result) const |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
202 { |
5044
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
203 if (!IsString()) |
4775
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
204 { |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
205 return false; |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
206 } |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
207 else |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
208 { |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
209 return SerializationToolbox::ParseDouble(result, GetContent()); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
210 } |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
211 } |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
212 |
4775
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
213 bool DicomValue::ParseFirstFloat(float& result) const |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
214 { |
5044
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
215 if (!IsString()) |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
216 { |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
217 return false; |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
218 } |
4775
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
219 else |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
220 { |
4775
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
221 return SerializationToolbox::ParseFirstFloat(result, GetContent()); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
222 } |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
223 } |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
224 |
4775
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
225 bool DicomValue::ParseFirstUnsignedInteger(unsigned int& result) const |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
226 { |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
227 uint64_t value; |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
228 |
5044
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
229 if (!IsString()) |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
230 { |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
231 return false; |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
232 } |
4775
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
233 else if (SerializationToolbox::ParseFirstUnsignedInteger64(value, GetContent())) |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
234 { |
4775
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
235 result = static_cast<unsigned int>(value); |
add0337b928a
refactoring parsing of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
236 return (static_cast<uint64_t>(result) == value); // Check no overflow |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
237 } |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
238 else |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
239 { |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
240 return false; |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
241 } |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
242 } |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
243 |
2412
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
244 bool DicomValue::CopyToString(std::string& result, |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
245 bool allowBinary) const |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
246 { |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
247 if (IsNull()) |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
248 { |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
249 return false; |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
250 } |
5044
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
251 else if (IsSequence()) |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
252 { |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
253 return false; |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
254 } |
2412
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
255 else if (IsBinary() && !allowBinary) |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
256 { |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
257 return false; |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
258 } |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
259 else |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
260 { |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
261 result.assign(content_); |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
262 return true; |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
263 } |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
264 } |
2863
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
265 |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
266 |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
267 static const char* KEY_TYPE = "Type"; |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
268 static const char* KEY_CONTENT = "Content"; |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
269 |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
270 void DicomValue::Serialize(Json::Value& target) const |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
271 { |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
272 target = Json::objectValue; |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
273 |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
274 switch (type_) |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
275 { |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
276 case Type_Null: |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
277 target[KEY_TYPE] = "Null"; |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
278 break; |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
279 |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
280 case Type_String: |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
281 target[KEY_TYPE] = "String"; |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
282 target[KEY_CONTENT] = content_; |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
283 break; |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
284 |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
285 case Type_Binary: |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
286 { |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
287 target[KEY_TYPE] = "Binary"; |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
288 |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
289 std::string base64; |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
290 Toolbox::EncodeBase64(base64, content_); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
291 target[KEY_CONTENT] = base64; |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
292 break; |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
293 } |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
294 |
5044
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
295 case Type_SequenceAsJson: |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
296 { |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
297 throw OrthancException(ErrorCode_NotImplemented); |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
298 } |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
299 |
2863
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
300 default: |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
301 throw OrthancException(ErrorCode_InternalError); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
302 } |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
303 } |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
304 |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
305 void DicomValue::Unserialize(const Json::Value& source) |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
306 { |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
307 std::string type = SerializationToolbox::ReadString(source, KEY_TYPE); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
308 |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
309 if (type == "Null") |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
310 { |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
311 type_ = Type_Null; |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
312 content_.clear(); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
313 } |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
314 else if (type == "String") |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
315 { |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
316 type_ = Type_String; |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
317 content_ = SerializationToolbox::ReadString(source, KEY_CONTENT); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
318 } |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
319 else if (type == "Binary") |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
320 { |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
321 type_ = Type_Binary; |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
322 |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
323 const std::string base64 =SerializationToolbox::ReadString(source, KEY_CONTENT); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
324 Toolbox::DecodeBase64(content_, base64); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
325 } |
5044
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
326 else if (type == "Sequence") |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
327 { |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
328 throw OrthancException(ErrorCode_NotImplemented); |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
329 } |
2863
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
330 else |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
331 { |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
332 throw OrthancException(ErrorCode_BadFileFormat); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
333 } |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
334 } |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
335 } |