31 #include <boost/cstdint.hpp> 32 #include <boost/shared_ptr.hpp> 36 #include "rsb/rsbexports.h" 57 assert(data.first == this->getDataType());
60 boost::shared_ptr<T> number = boost::static_pointer_cast<T>(data.second);
61 wire.resize(
sizeof(T));
62 for (
unsigned int i = 0; i <
sizeof(T); ++i) {
63 wire[i] = (
unsigned char) (*number >> (i * 8ull));
69 const std::string& wire) {
71 assert(wire.size() ==
sizeof(T));
73 boost::shared_ptr<T> number(
new T(0));
74 for (
unsigned int i = 0; i <
sizeof(T); ++i) {
75 *number |= ((T) ((
unsigned char) wire[i]) << (i * 8ull));
80 typedef boost::shared_ptr< IntegerConverter<T> >
Ptr;
std::pair< std::string, boost::shared_ptr< void > > AnnotatedData
A combination of data type and the actual data.
virtual ~IntegerConverter()
Converter for boost::uint64_t.
boost::shared_ptr< IntegerConverter< T > > Ptr
virtual std::string getWireSchema() const
Returns the name of the wire schema this converter can (de)serialize from/to.
IntegerConverter(const std::string &wireSchema)
std::string serialize(const AnnotatedData &data, std::string &wire)
Serialized the given domain object to the wire.
Converter for boost::int32_t.
virtual std::string getDataType() const
Returns the name of the data type this converter is applicable for.
AnnotatedData deserialize(const std::string &wireSchema, const std::string &wire)
Deserializes a domain object from a wire type.
Converter for boost::uint32_t.
Base class for integer type converters.
Converter for boost::int64_t.