Mercurial > hg > orthanc
annotate OrthancFramework/Sources/DicomFormat/DicomValue.h @ 5640:f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 30 May 2024 21:19:57 +0200 |
parents | 48b8dae6dc77 |
children |
rev | line source |
---|---|
0 | 1 /** |
59 | 2 * Orthanc - A Lightweight, RESTful DICOM Store |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
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:
5185
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
0 | 8 * |
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. |
136 | 13 * |
0 | 14 * This program is distributed in the hope that it will be useful, but |
15 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
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. |
0 | 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/>. |
0 | 22 **/ |
23 | |
24 | |
25 #pragma once | |
26 | |
2905
ae20fccdd867
refactoring mime types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
27 #include "../Enumerations.h" |
ae20fccdd867
refactoring mime types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
28 |
2417 | 29 #include <stdint.h> |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
30 #include <boost/noncopyable.hpp> |
2863
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
31 #include <json/value.h> |
0 | 32 |
2138 | 33 #if !defined(ORTHANC_ENABLE_BASE64) |
34 # error The macro ORTHANC_ENABLE_BASE64 must be defined | |
35 #endif | |
36 | |
37 | |
59 | 38 namespace Orthanc |
0 | 39 { |
3992
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3690
diff
changeset
|
40 class ORTHANC_PUBLIC DicomValue : public boost::noncopyable |
0 | 41 { |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
42 private: |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
43 enum Type |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
44 { |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
45 Type_Null, |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
46 Type_String, |
5044
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
47 Type_Binary, |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
48 Type_SequenceAsJson |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
49 }; |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
50 |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
51 Type type_; |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
52 std::string content_; |
5044
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
53 Json::Value sequenceJson_; |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
54 |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
55 DicomValue(const DicomValue& other); |
0 | 56 |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
57 public: |
4296
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
58 DicomValue(); |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
59 |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
60 DicomValue(const std::string& content, |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
61 bool isBinary); |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
62 |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
63 DicomValue(const char* data, |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
64 size_t size, |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
65 bool isBinary); |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
66 |
5050 | 67 explicit DicomValue(const Json::Value& value); |
5044
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
68 |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
69 const std::string& GetContent() const; |
0 | 70 |
5044
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
71 const Json::Value& GetSequenceContent() const; |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
72 |
4296
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
73 bool IsNull() const; |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
74 |
4296
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
75 bool IsBinary() const; |
5044
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
76 |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
77 bool IsString() const; |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
78 |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
79 bool IsSequence() const; |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
80 |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
81 DicomValue* Clone() const; |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
82 |
2138 | 83 #if ORTHANC_ENABLE_BASE64 == 1 |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
84 void FormatDataUriScheme(std::string& target, |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
85 const std::string& mime) const; |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
86 |
4304 | 87 void FormatDataUriScheme(std::string& target) const; |
1761
f4286d99ee0a
fix sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
88 #endif |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
89 |
2412
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
90 bool CopyToString(std::string& result, |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
91 bool allowBinary) const; |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
92 |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
93 bool ParseInteger32(int32_t& result) const; |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
94 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
95 bool ParseInteger64(int64_t& result) const; |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
96 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
97 bool ParseUnsignedInteger32(uint32_t& result) const; |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
98 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
99 bool ParseUnsignedInteger64(uint64_t& result) const; |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
100 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
101 bool ParseFloat(float& result) const; |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
102 |
2863
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
103 bool ParseDouble(double& result) const; |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
104 |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
105 bool ParseFirstFloat(float& result) const; |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
106 |
3519
fc26659493b6
added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents:
3060
diff
changeset
|
107 bool ParseFirstUnsignedInteger(unsigned int& result) const; |
fc26659493b6
added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents:
3060
diff
changeset
|
108 |
2863
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
109 void Serialize(Json::Value& target) const; |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
110 |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
111 void Unserialize(const Json::Value& source); |
0 | 112 }; |
113 } |