Marshaller.cpp 835 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "castor/tape/aggregator/Marshaller.hpp"

#include <arpa/inet.h>
#include <string.h>


//------------------------------------------------------------------------------
// marshallString
//------------------------------------------------------------------------------
char* castor::tape::aggregator::Marshaller::marshallString(char *const ptr,
  const char *const value) throw() {

  strcpy(ptr, value);

  return ptr + strlen(value) + 1;
}


//------------------------------------------------------------------------------
// unmarshallInt32
//------------------------------------------------------------------------------
char* castor::tape::aggregator::Marshaller::unmarshallUint32(char *const ptr,
  uint32_t &value) throw() {

  value = htonl(value);

  memcpy(ptr, &value, sizeof(value));

  return ptr + sizeof(value);
}