Mercurial > hg > orthanc
annotate Core/DicomFormat/DicomValue.h @ 2668:d26dd081df97 jobs
saving jobs engine on exit
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 08 Jun 2018 18:08:48 +0200 |
parents | 878b59270859 |
children | da12ba232119 |
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 |
2447
878b59270859
upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2417
diff
changeset
|
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU General Public License as | |
9 * published by the Free Software Foundation, either version 3 of the | |
10 * License, or (at your option) any later version. | |
136 | 11 * |
12 * In addition, as a special exception, the copyright holders of this | |
13 * program give permission to link the code of its release with the | |
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
15 * that use the same license as the "OpenSSL" library), and distribute | |
16 * the linked executables. You must obey the GNU General Public License | |
17 * in all respects for all of the code used other than "OpenSSL". If you | |
18 * modify file(s) with this exception, you may extend this exception to | |
19 * your version of the file(s), but you are not obligated to do so. If | |
20 * you do not wish to do so, delete this exception statement from your | |
21 * version. If you delete this exception statement from all source files | |
22 * in the program, then also delete it here. | |
0 | 23 * |
24 * This program is distributed in the hope that it will be useful, but | |
25 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
27 * General Public License for more details. | |
28 * | |
29 * You should have received a copy of the GNU General Public License | |
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
31 **/ | |
32 | |
33 | |
34 #pragma once | |
35 | |
2417 | 36 #include <stdint.h> |
0 | 37 #include <string> |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
38 #include <boost/noncopyable.hpp> |
0 | 39 |
2138 | 40 #if !defined(ORTHANC_ENABLE_BASE64) |
41 # error The macro ORTHANC_ENABLE_BASE64 must be defined | |
42 #endif | |
43 | |
44 | |
59 | 45 namespace Orthanc |
0 | 46 { |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
47 class DicomValue : public boost::noncopyable |
0 | 48 { |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
49 private: |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
50 enum Type |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
51 { |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
52 Type_Null, |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
53 Type_String, |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
54 Type_Binary |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
55 }; |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
56 |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
57 Type type_; |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
58 std::string content_; |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
59 |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
60 DicomValue(const DicomValue& other); |
0 | 61 |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
62 public: |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
63 DicomValue() : type_(Type_Null) |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
64 { |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
65 } |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
66 |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
67 DicomValue(const std::string& content, |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
68 bool isBinary); |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
69 |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
70 DicomValue(const char* data, |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
71 size_t size, |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
72 bool isBinary); |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
73 |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
74 const std::string& GetContent() const; |
0 | 75 |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
76 bool IsNull() const |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
77 { |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
78 return type_ == Type_Null; |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
79 } |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
80 |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
81 bool IsBinary() const |
0 | 82 { |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
83 return type_ == Type_Binary; |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
84 } |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
85 |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
86 DicomValue* Clone() const; |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
87 |
2138 | 88 #if ORTHANC_ENABLE_BASE64 == 1 |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
89 void FormatDataUriScheme(std::string& target, |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
90 const std::string& mime) const; |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
91 |
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
92 void FormatDataUriScheme(std::string& target) const |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
93 { |
1738
15a788a63846
DicomToJsonFlags_IncludeBinary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
94 FormatDataUriScheme(target, "application/octet-stream"); |
0 | 95 } |
1761
f4286d99ee0a
fix sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1738
diff
changeset
|
96 #endif |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
97 |
2412
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
98 bool CopyToString(std::string& result, |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
99 bool allowBinary) const; |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
100 |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
101 bool ParseInteger32(int32_t& result) const; |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
102 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
103 bool ParseInteger64(int64_t& result) const; |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
104 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
105 bool ParseUnsignedInteger32(uint32_t& result) const; |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
106 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
107 bool ParseUnsignedInteger64(uint64_t& result) const; |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
108 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
109 bool ParseFloat(float& result) const; |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
110 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
111 bool ParseDouble(double& result) const; |
0 | 112 }; |
113 } |