13#ifndef TEUCHOS_SERIALIZATION_TRAITS_HPP
14#define TEUCHOS_SERIALIZATION_TRAITS_HPP
20#ifdef HAVE_TEUCHOSCORE_QUADMATH
25#include <qd/dd_real.h>
26#include <qd/qd_real.h>
40 static inline T
notDefined() {
return(T::this_type_is_missing_a_specialization());}
97template <
typename Ordinal,
typename T>
165 (void)count; (void)buffer;
190 (void)count; (void)buffer; (void)bytes; (void)charBuffer;
196 const char charBuffer[]) {
197 (void)bytes; (void)charBuffer;
218 const char charBuffer[],
222 (void)bytes; (void)charBuffer; (void)count; (void)buffer;
243template <
typename Ordinal,
typename T>
278template <
typename Ordinal,
typename T>
281 static const bool supportsDirectSerialization =
true;
283 static Ordinal fromCountToDirectBytes(
const Ordinal count)
284 {
return sizeof(T)*count; }
285 static char* convertToCharPtr( T*
ptr )
286 {
return reinterpret_cast<char*
>(
ptr); }
287 static const char* convertToCharPtr(
const T*
ptr )
288 {
return reinterpret_cast<const char*
>(
ptr); }
289 static Ordinal fromDirectBytesToCount(
const Ordinal count)
290 {
return count/
sizeof(T); }
291 static T* convertFromCharPtr(
char*
ptr )
292 {
return reinterpret_cast<T*
>(
ptr); }
293 static const T* convertFromCharPtr(
const char*
ptr )
294 {
return reinterpret_cast<const T*
>(
ptr); }
296 static Ordinal fromCountToIndirectBytes(
const Ordinal count,
const T buffer[])
297 {
return fromCountToDirectBytes(count); }
298 static void serialize(
299 const Ordinal count,
const T buffer[],
const Ordinal bytes,
char charBuffer[]
307 const char *_buffer = convertToCharPtr(buffer);
308 std::copy(_buffer,_buffer+bytes,charBuffer);
310 static Ordinal fromIndirectBytesToCount(
const Ordinal bytes,
311 const char charBuffer[])
312 {
return fromDirectBytesToCount(bytes); }
313 static void deserialize(
314 const Ordinal bytes,
const char charBuffer[],
const Ordinal count, T buffer[]
320 char *_buffer = convertToCharPtr(buffer);
321 std::copy(charBuffer,charBuffer+bytes,_buffer);
330template<
typename Ordinal>
335template<
typename Ordinal>
336class SerializationTraits<Ordinal,signed char>
337 :
public DirectSerializationTraits<Ordinal,signed char>
340template<
typename Ordinal>
345template<
typename Ordinal>
350template<
typename Ordinal>
355template<
typename Ordinal>
360template<
typename Ordinal>
365template<
typename Ordinal>
370template<
typename Ordinal>
375template<
typename Ordinal>
380template<
typename Ordinal>
385#ifdef HAVE_TEUCHOS_LONG_DOUBLE
386template<
typename Ordinal>
394template<
typename Ordinal,
typename P1,
typename P2>
399#ifdef HAVE_TEUCHOSCORE_QUADMATH
400template<
typename Ordinal>
406#ifdef HAVE_TEUCHOS_QD
407template<
typename Ordinal>
412template<
typename Ordinal>
418#ifdef HAVE_TEUCHOS_COMPLEX
420template<
typename Ordinal>
425template<
typename Ordinal>
437template<
typename Ordinal>
447template<
typename Ordinal>
Teuchos header file which uses auto-configuration information to include necessary C++ headers.
Standard test and throw macros.
Serialization traits for objects that support direct serialization.
Ptr< T > ptr(T *p)
Create a pointer to an object from a raw pointer.
Serialization traits class for types T that use value semantics.
static const bool supportsDirectSerialization
Whether the type T supports direct serialization.
static void serialize(const Ordinal count, const T buffer[], const Ordinal bytes, char charBuffer[])
Serialize to an indirect char[] buffer.
static Ordinal fromIndirectBytesToCount(const Ordinal bytes, const char charBuffer[])
Return the number of objects for bytes of storage.
static Ordinal fromCountToDirectBytes(const Ordinal count)
Return the number of bytes for count objects.
static Ordinal fromDirectBytesToCount(const Ordinal bytes)
Return the number of objects for bytes of storage.
static void deserialize(const Ordinal bytes, const char charBuffer[], const Ordinal count, T buffer[])
Deserialize from an indirect char[] buffer.
static char * convertToCharPtr(T *ptr)
Convert the pointer type to char*.
static T * convertFromCharPtr(char *ptr)
Convert the pointer type from char*.
static const char * convertToCharPtr(const T *ptr)
Convert the pointer type to const char*.
static const T * convertFromCharPtr(const char *ptr)
Convert the pointer type from char*.
static Ordinal fromCountToIndirectBytes(const Ordinal count, const T buffer[])
Return the number of bytes for count objects.
Serialization class for types T that use value semantics.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
This macro is designed to be a short version of TEUCHOS_TEST_FOR_EXCEPTION() that is easier to call.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
Report an error if a specialization of SerializationTraits is missing.
static T notDefined()
This function should not compile if there is an attempt to instantiate!