45 #ifndef TEUCHOS_SERIALIZATION_TRAITS_HPP 46 #define TEUCHOS_SERIALIZATION_TRAITS_HPP 51 #ifdef HAVE_TEUCHOS_QD 52 #include <qd/dd_real.h> 53 #include <qd/qd_real.h> 67 static inline T
notDefined() {
return(T::this_type_is_missing_a_specialization());}
124 template <
typename Ordinal,
typename T>
135 static const bool supportsDirectSerialization =
false;
192 (void)count; (void)buffer;
217 (void)count; (void)buffer; (void)bytes; (void)charBuffer;
223 const char charBuffer[]) {
224 (void)bytes; (void)charBuffer;
245 const char charBuffer[],
249 (void)bytes; (void)charBuffer; (void)count; (void)buffer;
270 template <
typename Ordinal,
typename T>
305 template <
typename Ordinal,
typename T>
308 static const bool supportsDirectSerialization =
true;
311 {
return sizeof(T)*count; }
313 {
return reinterpret_cast<char*
>(ptr); }
315 {
return reinterpret_cast<const char*
>(ptr); }
317 {
return count/
sizeof(T); }
319 {
return reinterpret_cast<T*
>(ptr); }
321 {
return reinterpret_cast<const T*
>(ptr); }
324 {
return fromCountToDirectBytes(count); }
326 const Ordinal count,
const T buffer[],
const Ordinal bytes,
char charBuffer[]
332 const char *_buffer = convertToCharPtr(buffer);
333 std::copy(_buffer,_buffer+bytes,charBuffer);
336 const char charBuffer[])
337 {
return fromDirectBytesToCount(bytes); }
339 const Ordinal bytes,
const char charBuffer[],
const Ordinal count, T buffer[]
345 char *_buffer = convertToCharPtr(buffer);
346 std::copy(charBuffer,charBuffer+bytes,_buffer);
355 template<
typename Ordinal>
360 template<
typename Ordinal>
365 template<
typename Ordinal>
370 template<
typename Ordinal>
375 template<
typename Ordinal>
380 template<
typename Ordinal>
385 template<
typename Ordinal>
390 template<
typename Ordinal>
395 template<
typename Ordinal>
400 template<
typename Ordinal>
405 template<
typename Ordinal>
411 template<
typename Ordinal,
typename P1,
typename P2>
416 #ifdef HAVE_TEUCHOS_QD 417 template<
typename Ordinal>
422 template<
typename Ordinal>
428 #ifdef HAVE_TEUCHOS_COMPLEX 430 template<
typename Ordinal>
435 template<
typename Ordinal>
440 #endif // HAVE_TEUCHOS_COMPLEX 442 #if defined(HAVE_TEUCHOS_LONG_LONG_INT) 449 template<
typename Ordinal>
459 template<
typename Ordinal>
468 #elif SIZE_MAX > ULONG_MAX 477 template<
typename Ordinal>
482 template<
typename Ordinal>
487 #endif // HAVE_TEUCHOS_LONG_LONG_INT 491 #endif // TEUCHOS_SERIALIZATION_TRAITS_HPP Serialization traits for objects that support direct serialization.
static char * convertToCharPtr(T *ptr)
Convert the pointer type to char*.
static void serialize(const Ordinal count, const T buffer[], const Ordinal bytes, char charBuffer[])
static Ordinal fromCountToIndirectBytes(const Ordinal count, const T buffer[])
static const char * convertToCharPtr(const T *ptr)
Convert the pointer type to const char*.
static Ordinal fromCountToDirectBytes(const Ordinal count)
static T notDefined()
This function should not compile if there is an attempt to instantiate!
static void deserialize(const Ordinal bytes, const char charBuffer[], const Ordinal count, T buffer[])
static Ordinal fromCountToIndirectBytes(const Ordinal count, const T buffer[])
Return the number of bytes for count objects.
Teuchos header file which uses auto-configuration information to include necessary C++ headers...
static void deserialize(const Ordinal bytes, const char charBuffer[], const Ordinal count, T buffer[])
Deserialize from an indirect char[] buffer.
Serialization class for types T that use value semantics.
static Ordinal fromIndirectBytesToCount(const Ordinal bytes, const char charBuffer[])
Return the number of objects for bytes of storage.
static T * convertFromCharPtr(char *ptr)
static T * convertFromCharPtr(char *ptr)
Convert the pointer type from char*.
static char * convertToCharPtr(T *ptr)
static const T * convertFromCharPtr(const char *ptr)
Convert the pointer type from char*.
static const char * convertToCharPtr(const T *ptr)
static const T * convertFromCharPtr(const char *ptr)
static Ordinal fromIndirectBytesToCount(const Ordinal bytes, const char charBuffer[])
Report an error if a specialization of SerializationTraits is missing.
Serialization traits class for types T that use value semantics.
static Ordinal fromDirectBytesToCount(const Ordinal count)
static Ordinal fromDirectBytesToCount(const Ordinal bytes)
Return the number of objects for bytes of storage.
static void serialize(const Ordinal count, const T buffer[], const Ordinal bytes, char charBuffer[])
Serialize to an indirect char[] buffer.
#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...
static Ordinal fromCountToDirectBytes(const Ordinal count)
Return the number of bytes for count objects.