MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
DCMTree_Serialization.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#ifndef DCM_TREE_SERIALIZATION_H
14#define DCM_TREE_SERIALIZATION_H
15
16#ifdef _MSC_VER
17#pragma warning(push)
18#pragma warning(disable : 4350)
19#endif
20
21#include "DCMTree_Defines.h"
22#include <boost/cstdint.hpp>
23#include <boost/limits.hpp>
24#include <string>
25
26#ifdef _MSC_VER
27#pragma warning(pop)
28#endif
29
31{
76
79 {
80 public:
81 virtual ~Sink() {};
82
86 void writeX(const std::string& value);
87
92 {
93 boost::uint32_t c = static_cast<boost::uint32_t>(tc);
94 writeX(&c, sizeof(boost::uint32_t));
95 }
96
98 virtual void writeX(const void* data, boost::uint32_t size) = 0;
99 };
100
103 {
104 public:
105 virtual ~Source() {};
106
107 void readX(std::string& value);
108
114
118 virtual void readX(void* data, boost::uint32_t size) = 0;
119
120 virtual void rewind() = 0;
121 };
122
125 {
126 public:
154 virtual void serializeX(Sink& sink) const = 0;
155
158 {}
159 };
160
163 {
164 public:
170 virtual void deserializeX(Source& source) = 0;
171
174 {}
175 };
176
178 template <typename T> class SerializerIntf
179 {
180 public:
182 {}
183
188 virtual void serializeX(Sink& sink, const T& value) = 0;
189 };
190
192 template <typename T> class DeserializerIntf
193 {
194 public:
196 {}
197
202 virtual T deserializeX(Source& source) = 0;
203 };
204} // namespace DCMTree_Serialization
205
206#endif
#define DCMTREE_EXPORT
@ T
Interface that provides a method to deserialize an object.
virtual void deserializeX(Source &source)=0
Overwrites data of this object with data from source.
Interface of a class that can be used to deserialize objects without a default constructor.
virtual T deserializeX(Source &source)=0
Deserializes an object.
Interface that provides a method to serialize an object.
virtual void serializeX(Sink &sink) const =0
Writes data of this object to sink.
Interface of a class that can be used to serialize objects.
virtual void serializeX(Sink &sink, const T &value)=0
Serializes an object.
Interface of a data sink for the serialization of objects.
virtual void writeX(const void *data, boost::uint32_t size)=0
Writes a specified number of bytes.
void writeX(const std::string &value)
Writes a QString.
void writeTypeX(TypeCode tc)
Writes a TypeCode.
Interface of a data source for the deserialization of objects.
void readTypeX(TypeCode expected)
Reads a TypeCode.
void readX(std::string &value)
virtual void readX(void *data, boost::uint32_t size)=0
Reads a specified number of bytes.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
TypeCode
Used to encode the type of the next serialized value into the stream.
@ TC_UNSIGNED_LONG_LONG
unsigned long
@ TC_UNSIGNED_SHORT
unsigned short