MeVisLab Toolbox Reference
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, ie.
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 {
49 SDM_makeCopy, // copy the data into the value
50 SDM_takeOwnership // the value takes the ownership of the data
51 };
52
53 public:
56
60 Value (const unsigned int &size);
61
67 Value (const unsigned int &size,const unsigned char *data);
68
73 Value (const Value &other);
74
77
80
86
91
96
100 void purge();
101
105 unsigned int size() const;
106
110 const unsigned char *data() const;
111
115 unsigned char *data();
116
120 boost::shared_array<unsigned char> sharedData() const;
121
125 void setSize (const unsigned int &size);
126
131 void setData (const unsigned int &size,const unsigned char *data);
132
139 void setData (const unsigned int &size, unsigned char *data,
140 SetDataMode setDataMode = SDM_makeCopy);
141
145 void setData (const std::string &value);
146
150 bool isNull() const;
151
155 void fromStream (std::istream &in);
156
160 void toStream (std::ostream &out) const;
161
162 void serializeX (DCMTree_Serialization::Sink &sink) const override;
163 void deserializeX (DCMTree_Serialization::Source &source) override;
164
165 private:
169 void allocate (const unsigned int &size);
170
171 boost::shared_array<unsigned char> _data;
172 unsigned int _size;
173 unsigned int _buffersize;
174 };
175
177
178 inline std::ostream &operator << (std::ostream &out,const Value &v)
179 {
180 v.toStream (out);
181 return out;
182 }
183
184 inline std::istream &operator >> (std::istream &in,Value &v)
185 {
186 v.fromStream (in);
187 return in;
188 }
189}
190
191#endif
192
193
#define DCMTREE_EXPORT
Class to store tag-values.
Value(const Value &other)
make a deep-copy of other to this uses operator=
Value(Value &&) noexcept=default
Value(const unsigned int &size)
create a value with the given size in bytes
Value(const unsigned int &size, const unsigned char *data)
create a value with the given size in bytes and memcpy data to it the given data remains owned by the...
void fromStream(std::istream &in)
extract this instance from the given stream
Interface which provides a method to deserialize an object.
Interface which 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:215
class to dump a DCMTree dicom message into a human readable file this class could be used as a starte...
std::vector< Value > ValueVector
Forward declaration for the boost::mutex class.
STL namespace.