//****************************************************************************** // RCF - Remote Call Framework // Copyright (c) 2005 - 2007. All rights reserved. // Consult your license for conditions of use. // Developed by Jarl Lindrud. // Contact: jlindrud@hotmail.com . //****************************************************************************** #ifndef INCLUDE_SF_SERIALIZEFUNDAMENTAL_HPP #define INCLUDE_SF_SERIALIZEFUNDAMENTAL_HPP #include #include #include #include #include namespace SF { // serialize fundamental types template inline void serializeFundamental(SF::Archive &ar, T &t, const unsigned int, unsigned int count = 1) { typedef typename RCF::RemoveCv::type U; BOOST_STATIC_ASSERT( RCF::IsFundamental::value ); U *pu = const_cast(&t); void *pvt = pu; if (ar.isRead()) { I_Encoding &encoding = dynamic_cast(ar.getStream())->getEncoding(); DataPtr data; dynamic_cast(ar.getStream())->get(data); if (count > 1 && count != encoding.getCount(data,typeid(U)) ) { // static array size mismatch RCF_THROW(RCF::Exception(RCF::SfError_DataFormat))(typeid(U).name())(count)(encoding.getCount(data,typeid(T))); } encoding.toObject(data, pvt, typeid(T), count ); } else if (ar.isWrite()) { I_Encoding &encoding = dynamic_cast(ar.getStream())->getEncoding(); DataPtr data; encoding.toData(data, pvt, typeid(U), count ); dynamic_cast(ar.getStream())->put(data); } } } // namespace SF #endif // ! INCLUDE_SF_SERIALIZEFUNDAMENTAL_HPP