26 static void copy(
unsigned const char* from,
unsigned char* dest,
27 const int size,
const int count);
35 static void tostream( std::string& s , T* t,
unsigned count ) {
38 bytlen = count *
sizeof( T ) ;
39 padlen = (bytlen + 3) & 0xfffffffc ;
42 unsigned index = s.size() ;
44 s.resize( s.size() + padlen ) ;
46 unsigned char* dest =
reinterpret_cast< unsigned char*
> ( & s[ index ] ) ;
47 unsigned char* from =
reinterpret_cast< unsigned char*
> ( t ) ;
51 Xdr::copy( from , dest ,
sizeof( T ) , count ) ;
61 static unsigned fromstream(
const std::string& s ,
unsigned position, T* t,
unsigned count ) {
66 unsigned bytlen, padlen;
67 bytlen = count *
sizeof( T ) ;
68 padlen = (bytlen + 3) & 0xfffffffc ;
71 unsigned const char* from =
reinterpret_cast< unsigned const char*
> ( & s[ position ] ) ;
72 unsigned char* dest =
reinterpret_cast< unsigned char*
> ( t ) ;
76 Xdr::copy( from , dest ,
sizeof( T ) , count ) ;
87 return position + padlen ;
95 static void tostream( std::string& s , std::string* strVal,
unsigned ) {
97 int strSize = (int) strVal->size() ;
100 bytlen = strSize +
sizeof( int ) ;
102 padlen = (bytlen + 3) & 0xfffffffc ;
104 unsigned index = s.size() ;
106 s.resize( index + padlen ) ;
111 unsigned char* dest =
reinterpret_cast< unsigned char*
> ( & s[ index ] ) ;
112 unsigned char* from =
reinterpret_cast< unsigned char*
> ( & strSize ) ;
114 Xdr::copy( from , dest ,
sizeof(
int ) , 1 ) ;
117 dest =
reinterpret_cast< unsigned char*
> ( & s[ index +
sizeof( int ) ] ) ;
118 from =
reinterpret_cast< unsigned char*
> ( & strVal->operator[](0) ) ;
133 static unsigned fromstream(
const std::string& s,
unsigned index,
134 std::string* strVal,
unsigned count ) {
142 unsigned const char* from =
reinterpret_cast< unsigned const char*
> ( & s[ index ] ) ;
143 unsigned char* dest =
reinterpret_cast< unsigned char*
> ( & strSize ) ;
145 Xdr::copy( from , dest ,
sizeof(
int ) , 1 ) ;
147 index +=
sizeof( int ) ;
150 unsigned bytlen, padlen;
152 padlen = (bytlen + 3) & 0xfffffffc ;
155 strVal->resize( strSize ) ;
157 from =
reinterpret_cast< unsigned const char*
> ( & s[ index ] ) ;
158 dest =
reinterpret_cast< unsigned char*
> ( & strVal->operator[](0) ) ;
168 return index + padlen ;
static void copy(unsigned const char *from, unsigned char *dest, const int size, const int count)
Copies the the data in XDR, i.e.
static unsigned fromstream(const std::string &s, unsigned index, std::string *strVal, unsigned count)
Specialization for strings - count is ignored and taken to be 1.
Definition: Xdr.hh:133
static unsigned fromstream(const std::string &s, unsigned position, T *t, unsigned count)
Read count objects of (simple) type t from the string/stream s at position.
Definition: Xdr.hh:61
static void tostream(std::string &s, T *t, unsigned count)
Writes count objects of (simple) type T to the string s in Xdr format.
Definition: Xdr.hh:35
static void tostream(std::string &s, std::string *strVal, unsigned)
Specialization for strings - count is ignored and taken to be 1.
Definition: Xdr.hh:95
Utility functions for DB streamer objects.
Definition: Xdr.hh:19