13#ifndef DCM_TREE_SERIALIZATION_HELPER_H
14#define DCM_TREE_SERIALIZATION_HELPER_H
19#include <boost/shared_ptr.hpp>
29 #pragma warning (push)
30 #pragma warning (disable : 4018)
39 sink.writeX(&value,
sizeof(value));
46 source.readX(&value,
sizeof(value));
136 value =
static_cast<T>(
i);
165 value = boost::shared_ptr<T>(
new T());
179 template<
typename T,
typename U>
188 template<
typename T,
typename U>
197 template<
typename T,
typename U>
201 if ( std::numeric_limits<boost::uint32_t>::max() < value.size() )
203 throw DCMTree::Exception(
"DCMTree_Serialization::serializeX()",
"Value size too large for serialization" );
207 typename std::map<T,U>::const_iterator
mapEnd = value.end();
208 for(
typename std::map<T,U>::const_iterator
i = value.begin();
i !=
mapEnd;
i++)
216 template<
typename T,
typename U>
221 boost::uint32_t size;
224 for(
typename std::map<T,U>::size_type
i = 0;
i < size;
i++)
233 template<
typename T,
typename U>
237 if ( std::numeric_limits<boost::uint32_t>::max() < value.size() )
239 throw DCMTree::Exception(
"DCMTree_Serialization::serializeX()",
"Value size too large for serialization" );
243 typename std::multimap<T,U>::const_iterator
mapEnd = value.end();
244 for(
typename std::multimap<T,U>::const_iterator
i = value.begin();
i !=
mapEnd;
i++)
252 template<
typename T,
typename U>
257 boost::uint32_t size;
260 for(
typename std::multimap<T,U>::size_type
i = 0;
i < size;
i++)
266 value.insert(std::make_pair(t,u));
275 if ( std::numeric_limits<boost::uint32_t>::max() < value.size() )
277 throw DCMTree::Exception(
"DCMTree_Serialization::serializeX()",
"Value size too large for serialization" );
281 typename std::set<T>::const_iterator
setEnd = value.end();
282 for(
typename std::set<T>::const_iterator
i = value.begin();
i !=
setEnd;
i++)
294 boost::uint32_t size;
297 for(
typename std::set<T>::size_type
i = 0;
i < size;
i++)
313 if ( std::numeric_limits<std::uint32_t>::max() <
vl.size() )
315 throw DCMTree::Exception(
"DCMTree_Serialization::serializeX()",
"Value size too large for serialization" );
319 for(
auto i = 0u;
i <
vl.size(); ++
i )
333 boost::uint32_t count;
340 for( boost::uint32_t
i = 0;
i < count; ++
i)
390 #pragma warning (pop)
Exception class for DCMTree.
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.
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.
Interface of a data sink for the serialization of objects.
Interface of a data source for the deserialization of objects.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
void deserializePrimitiveX(Source &source, T &value)
Deserializes a primitive type like int, long.
void serializeX(Sink &sink, const DCMTree::TransferSyntax &syntax)
void serializeEnumX(Sink &sink, T value)
Serializes an enum.
bool deserialize(Source &source, T &value)
Adapts deserializeX to return an error code instead of throwing an exception.
void deserializeIntoNewX(Source &source, boost::shared_ptr< T > &value)
Deserializes boost::shared_ptr<T>.
void deserializeEnumX(Source &source, T &value)
Deserializes an enum.
bool serialize(Sink &sink, const T &value)
Adapts serializeX to return an error code instead of throwing an exception.
@ TC_MULTIMAP
std::multimap
void deserializeX(Source &source, DCMTree::TransferSyntax &syntax)
void serializePrimitiveX(Sink &sink, T value)
Serializes a primitive type like int, long.
void deserializeIntoExistingX(Source &source, boost::shared_ptr< T > value)
Deserializes boost::shared_ptr<T>.