45#ifndef TEUCHOS_SERIALIZATION_TRAITS_HPP
46#define TEUCHOS_SERIALIZATION_TRAITS_HPP
52#ifdef HAVE_TEUCHOSCORE_QUADMATH
57#include <qd/dd_real.h>
58#include <qd/qd_real.h>
72 static inline T
notDefined() {
return(T::this_type_is_missing_a_specialization());}
129template <
typename Ordinal,
typename T>
197 (void)count; (void)buffer;
222 (void)count; (void)buffer; (void)bytes; (void)charBuffer;
228 const char charBuffer[]) {
229 (void)bytes; (void)charBuffer;
250 const char charBuffer[],
254 (void)bytes; (void)charBuffer; (void)count; (void)buffer;
275template <
typename Ordinal,
typename T>
310template <
typename Ordinal,
typename T>
313 static const bool supportsDirectSerialization =
true;
315 static Ordinal fromCountToDirectBytes(
const Ordinal count)
316 {
return sizeof(T)*count; }
317 static char* convertToCharPtr( T*
ptr )
318 {
return reinterpret_cast<char*
>(
ptr); }
319 static const char* convertToCharPtr(
const T*
ptr )
320 {
return reinterpret_cast<const char*
>(
ptr); }
321 static Ordinal fromDirectBytesToCount(
const Ordinal count)
322 {
return count/
sizeof(T); }
323 static T* convertFromCharPtr(
char*
ptr )
324 {
return reinterpret_cast<T*
>(
ptr); }
325 static const T* convertFromCharPtr(
const char*
ptr )
326 {
return reinterpret_cast<const T*
>(
ptr); }
328 static Ordinal fromCountToIndirectBytes(
const Ordinal count,
const T buffer[])
329 {
return fromCountToDirectBytes(count); }
330 static void serialize(
331 const Ordinal count,
const T buffer[],
const Ordinal bytes,
char charBuffer[]
339 const char *_buffer = convertToCharPtr(buffer);
340 std::copy(_buffer,_buffer+bytes,charBuffer);
342 static Ordinal fromIndirectBytesToCount(
const Ordinal bytes,
343 const char charBuffer[])
344 {
return fromDirectBytesToCount(bytes); }
345 static void deserialize(
346 const Ordinal bytes,
const char charBuffer[],
const Ordinal count, T buffer[]
352 char *_buffer = convertToCharPtr(buffer);
353 std::copy(charBuffer,charBuffer+bytes,_buffer);
362template<
typename Ordinal>
367template<
typename Ordinal>
368class SerializationTraits<Ordinal,signed char>
369 :
public DirectSerializationTraits<Ordinal,signed char>
372template<
typename Ordinal>
377template<
typename Ordinal>
382template<
typename Ordinal>
387template<
typename Ordinal>
392template<
typename Ordinal>
397template<
typename Ordinal>
402template<
typename Ordinal>
407template<
typename Ordinal>
412template<
typename Ordinal>
417#ifdef HAVE_TEUCHOS_LONG_DOUBLE
418template<
typename Ordinal>
426template<
typename Ordinal,
typename P1,
typename P2>
431#ifdef HAVE_TEUCHOSCORE_QUADMATH
432template<
typename Ordinal>
438#ifdef HAVE_TEUCHOS_QD
439template<
typename Ordinal>
444template<
typename Ordinal>
450#ifdef HAVE_TEUCHOS_COMPLEX
452template<
typename Ordinal>
457template<
typename Ordinal>
469template<
typename Ordinal>
479template<
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!