29 #include <boost/cstdint.hpp>
31 #include <rosetta/api.h>
34 #include "rsb/rsbexports.h"
46 template <
typename Mechanism,
57 deserialize(
const std::string& wireType,
const std::string& wire);
62 template <
typename Mechanism,
65 Converter<std::string> (rsc::runtime::typeName<Type>(),
66 rsc::runtime::typeName<Mechanism>()
67 +
":" + rsc::runtime::typeName<Type>()) {
70 template <
typename Mechanism,
75 template <
typename Mechanism,
79 std::string& wireData) {
80 assert(data.first == getDataType());
82 boost::shared_ptr<Type>
object = boost::static_pointer_cast<Type>(data.second);
83 boost::uint64_t size = rosetta::packedSize<Mechanism>(*object);
84 wireData.resize(size);
86 std::vector<unsigned char> temp(size);
87 rosetta::pack<Mechanism>(*object, temp, 0, size);
88 memcpy((
void*) &wireData[0], (
void*) &temp[0], size);
90 return getWireSchema();
93 template <
typename Mechanism,
97 const std::string& wireData) {
98 assert(wireSchema == getWireSchema());
100 boost::shared_ptr<Type> result(
new Type());
102 std::vector<unsigned char> data(wireData.size());
103 memcpy((
void*) &data[0], (
void*) &wireData[0], wireData.size());
104 rosetta::unpack<Mechanism>(data, *result, 0, wireData.size());
106 return std::make_pair(getDataType(), result);