Mercurial > hg > orthanc
comparison Core/DicomFormat/DicomValue.h @ 1738:15a788a63846
DicomToJsonFlags_IncludeBinary
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 22 Oct 2015 09:28:08 +0200 |
parents | ec66a16aa398 |
children | f4286d99ee0a |
comparison
equal
deleted
inserted
replaced
1737:ec66a16aa398 | 1738:15a788a63846 |
---|---|
30 **/ | 30 **/ |
31 | 31 |
32 | 32 |
33 #pragma once | 33 #pragma once |
34 | 34 |
35 #include "../OrthancException.h" | |
36 | |
37 #include <string> | 35 #include <string> |
38 #include <boost/noncopyable.hpp> | 36 #include <boost/noncopyable.hpp> |
39 | 37 |
40 namespace Orthanc | 38 namespace Orthanc |
41 { | 39 { |
50 }; | 48 }; |
51 | 49 |
52 Type type_; | 50 Type type_; |
53 std::string content_; | 51 std::string content_; |
54 | 52 |
55 DicomValue(const DicomValue& other) : | 53 DicomValue(const DicomValue& other); |
56 type_(other.type_), | |
57 content_(other.content_) | |
58 { | |
59 } | |
60 | 54 |
61 public: | 55 public: |
62 DicomValue() : type_(Type_Null) | 56 DicomValue() : type_(Type_Null) |
63 { | 57 { |
64 } | 58 } |
65 | 59 |
66 DicomValue(const std::string& content, | 60 DicomValue(const std::string& content, |
67 bool isBinary) : | 61 bool isBinary); |
68 type_(isBinary ? Type_Binary : Type_String), | |
69 content_(content) | |
70 { | |
71 } | |
72 | 62 |
73 DicomValue(const char* data, | 63 DicomValue(const char* data, |
74 size_t size, | 64 size_t size, |
75 bool isBinary) : | 65 bool isBinary); |
76 type_(isBinary ? Type_Binary : Type_String) | |
77 { | |
78 content_.assign(data, size); | |
79 } | |
80 | 66 |
81 const std::string& GetContent() const | 67 const std::string& GetContent() const; |
82 { | |
83 if (type_ == Type_Null) | |
84 { | |
85 throw OrthancException(ErrorCode_BadParameterType); | |
86 } | |
87 else | |
88 { | |
89 return content_; | |
90 } | |
91 } | |
92 | 68 |
93 bool IsNull() const | 69 bool IsNull() const |
94 { | 70 { |
95 return type_ == Type_Null; | 71 return type_ == Type_Null; |
96 } | 72 } |
98 bool IsBinary() const | 74 bool IsBinary() const |
99 { | 75 { |
100 return type_ == Type_Binary; | 76 return type_ == Type_Binary; |
101 } | 77 } |
102 | 78 |
103 DicomValue* Clone() const | 79 DicomValue* Clone() const; |
80 | |
81 void FormatDataUriScheme(std::string& target, | |
82 const std::string& mime) const; | |
83 | |
84 void FormatDataUriScheme(std::string& target) const | |
104 { | 85 { |
105 return new DicomValue(*this); | 86 FormatDataUriScheme(target, "application/octet-stream"); |
106 } | 87 } |
107 }; | 88 }; |
108 } | 89 } |