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" );
205 serializeX( sink,
static_cast<boost::uint32_t
>( value.size() ) );
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" );
241 serializeX( sink,
static_cast<boost::uint32_t
>( value.size() ) );
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" );
279 serializeX( sink,
static_cast<boost::uint32_t
>( value.size() ) );
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 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.
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 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>.
boost::graph_traits< ml_graph_ptr >::vertex_descriptor source(graph_traits< ml_graph_ptr >::edge_descriptor e, const ml_graph_ptr)
Returns the vertex descriptor for u of the edge (u,v) represented by e.