30 #include <boost/cstdint.hpp>
36 using namespace boost;
41 const string Uint32Converter::WIRE_SCHEMA =
"uint32";
43 Uint32Converter::Uint32Converter() :
51 assert(data.first == this->getDataType());
53 boost::shared_ptr<uint32_t> number = boost::static_pointer_cast<uint32_t>(data.second);
55 for (uint32_t i = 0; i < 4; ++i) {
56 wire[i] = (
unsigned char) ((*number & (0xfful << (i * 8ul))) >> (i * 8ul));
64 assert(wire.size() == 4);
66 boost::shared_ptr<uint32_t> number(
new uint32_t(0));
67 for (uint32_t i = 0; i < 4; ++i) {
68 *number |= ((uint32_t) ((
unsigned char) wire[i]) << (i * 8ul));
std::pair< std::string, boost::shared_ptr< void > > AnnotatedData
A combination of data type and the actual data.
AnnotatedData deserialize(const std::string &wireSchema, const std::string &wire)
Deserializes a domain object from a wire type.
virtual ~Uint32Converter()
static const std::string WIRE_SCHEMA
virtual std::string getDataType() const
Returns the name of the data type this converter is applicable for.
std::string serialize(const AnnotatedData &data, std::string &wire)
Serialized the given domain object to the wire.