MeVisLab Toolbox Reference
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{
77
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 public:
104 virtual ~Source(){};
105
106 void readX(std::string &value);
107
113
117 virtual void readX(void *data, boost::uint32_t size) = 0;
118
119 virtual void rewind()=0;
120 };
121
124 public:
152 virtual void serializeX(Sink &sink) const = 0;
153
155 virtual ~Serializable(){}
156 };
157
160 public:
166 virtual void deserializeX(Source &source) = 0;
167
169 virtual ~Deserializable(){}
170 };
171
173 template<typename T>
175 public:
176 virtual ~SerializerIntf(){}
177
182 virtual void serializeX(Sink &sink, const T &value) = 0;
183 };
184
186 template<typename T>
188 public:
190
195 virtual T deserializeX(Source &source) = 0;
196 };
197}
198
199#endif
200
201
#define DCMTREE_EXPORT
@ T
Interface which 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, which can be used to deserialize objects without a default constructor.
virtual T deserializeX(Source &source)=0
Deserializes an object.
Interface which 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, which 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 type of next serialized value into the stream.
@ TC_UNSIGNED_LONG_LONG
unsigned long
@ TC_UNSIGNED_SHORT
unsigned short