MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
DCMTree_Value.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13// Values are stored binary internaly, i.e.,
14// there is no implicit conversion taking place.
15// Data is converted if desired by DCMTree::Tag
16
17#ifndef DCM_TREE_VALUE_H
18#define DCM_TREE_VALUE_H
19
20#ifdef _MSC_VER
21#pragma warning(push)
22#pragma warning(disable : 4350)
23#endif
24
25#include <vector>
26
27#include <istream>
28#include <ostream>
29
30#include <boost/shared_array.hpp>
31
32#ifdef _MSC_VER
33#pragma warning(pop)
34#endif
35
36
37#include "DCMTree_Lib.h"
38#include "DCMTree_Defines.h"
39
40
41namespace DCMTree
42{
45 {
46 public:
48 SDM_makeCopy, // Copy the data into the value
49 SDM_takeOwnership // The value takes the ownership of the data
50 };
51
52 public:
55
59 Value(const unsigned int& size);
60
66 Value(const unsigned int& size, const unsigned char* data);
67
72 Value(const Value& other);
73
76
79
85
90
95
99 void purge();
100
104 unsigned int size() const;
105
109 const unsigned char* data() const;
110
114 unsigned char* data();
115
119 boost::shared_array<unsigned char> sharedData() const;
120
124 void setSize(const unsigned int& size);
125
130 void setData(const unsigned int& size, const unsigned char* data);
131
138 void setData(const unsigned int& size, unsigned char* data, SetDataMode setDataMode = SDM_makeCopy);
139
143 void setData(const std::string& value);
144
148 bool isNull() const;
149
153 void fromStream(std::istream& in);
154
158 void toStream(std::ostream& out) const;
159
160 void serializeX(DCMTree_Serialization::Sink& sink) const override;
161 void deserializeX(DCMTree_Serialization::Source& source) override;
162
163 private:
167 void allocate(const unsigned int& size);
168
169 boost::shared_array<unsigned char> _data;
170 unsigned int _size;
171 unsigned int _buffersize;
172 };
173
175
176 inline std::ostream& operator<<(std::ostream& out, const Value& v)
177 {
178 v.toStream(out);
179 return out;
180 }
181
182 inline std::istream& operator>>(std::istream& in, Value& v)
183 {
184 v.fromStream(in);
185 return in;
186 }
187} // namespace DCMTree
188
189#endif
#define DCMTREE_EXPORT
Class to store tag values.
Value()
Constructor.
Value(const Value &other)
Makes a deep copy of other to this.
Value(Value &&) noexcept=default
Value(const unsigned int &size)
Creates a value with the given size in bytes.
Value(const unsigned int &size, const unsigned char *data)
Creates a value with the given size in bytes and memcpy data to it.
void fromStream(std::istream &in)
Extracts this instance from the given stream.
Interface that provides a method to deserialize an object.
Interface that provides a method to serialize an object.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
std::istream & operator>>(std::istream &in, ml::Variant &variant)
Definition mlVariant.h:236
Class to dump a DCMTree DICOM message into a human-readable file.
std::vector< Value > ValueVector
Forward declaration for the boost::mutex class.
STL namespace.