41 #ifndef EPETRAEXT_PACKTRAITS_H 
   42 #define EPETRAEXT_PACKTRAITS_H 
   70   static size_t size( T 
const & 
object )
 
   71   { 
return object.packedByteCount(); }
 
   80   static void pack( T 
const & 
object, 
char * buf, 
size_t size, 
int & pos )
 
   81   { 
object.pack( buf, size, pos ); }
 
   90   static void unpack( T & 
object, 
char * buf, 
size_t size, 
int & pos )
 
   91   { 
object.unpack( buf, size, pos ); }
 
  100   static size_t size( std::string 
const & 
object )
 
  101   { 
return object.length() + 
sizeof(size_t); }
 
  103   static void pack( std::string 
const & 
object, 
char * buf, 
size_t size, 
int & pos )
 
  105     size_t len = 
object.length();
 
  106     std::memcpy( buf+pos, &len, 
sizeof(
size_t) );
 
  107     pos += 
sizeof(size_t);
 
  108     std::memcpy( buf+pos, 
object.c_str(), len );
 
  112   static void unpack( std::string & 
object, 
char * buf, 
size_t size, 
int & pos )
 
  115     std::memcpy( &len, buf+pos, 
sizeof(
size_t) );
 
  116     pos += 
sizeof(size_t);
 
  117     object = std::string( buf+pos, len );
 
  126 template <
typename T>
 
  129   static size_t size( std::vector<T> 
const & 
object )
 
  130   { 
return object.size() * 
sizeof(T) + 
sizeof(
size_t); }
 
  132   static void pack( std::vector<T> 
const & 
object, 
char * buf, 
size_t size, 
int & os )
 
  134     size_t len = 
object.size();
 
  135     std::memcpy( buf+pos, &len, 
sizeof(
size_t) );
 
  136     pos += 
sizeof(size_t);
 
  137     std::memcpy( buf+pos, &
object[0], len*
sizeof(T) );
 
  138     pos += len*
sizeof(T);
 
  141   static void unpack( std::vector<T> & 
object, 
char * buf, 
int size, 
int & pos )
 
  144     std::memcpy( &len, buf+pos, 
sizeof(
size_t) );
 
  145     pos += 
sizeof(size_t);
 
  147     std::memcpy( &
object[0], buf+pos, len*
sizeof(T) );
 
  148     pos += len*
sizeof(T);
 
Traits for packing and unpacking of data into char buffers for communication. 
 
static void pack(std::vector< T > const &object, char *buf, size_t size, int &os)
 
static void pack(std::string const &object, char *buf, size_t size, int &pos)
 
static void unpack(T &object, char *buf, size_t size, int &pos)
Unpacks object from char buffer. 
 
static void unpack(std::vector< T > &object, char *buf, int size, int &pos)
 
static size_t size(std::string const &object)
 
static size_t size(std::vector< T > const &object)
 
static void pack(T const &object, char *buf, size_t size, int &pos)
Packs object into char buffer. 
 
static size_t size(T const &object)
Returns size in byte necessary to pack datatype. 
 
static void unpack(std::string &object, char *buf, size_t size, int &pos)