33 #include <boost/shared_ptr.hpp>
37 #include "rsb/rsbexports.h"
52 if (!std::numeric_limits<T>::is_iec559) {
53 throw std::runtime_error(
"This converter only works on platforms"
55 " values in IEC 559 format which does not"
56 " seem to the case on this platform"
58 " std::numeric_limits<>::is_iec559");
66 assert(data.first == this->getDataType());
69 boost::shared_ptr<T> number = boost::static_pointer_cast<T>(data.second);
70 wire.resize(
sizeof(T));
71 for (
unsigned int i = 0; i <
sizeof(T); ++i) {
72 wire[i] = ((
char*) number.get())[i];
78 const std::string& wire) {
80 assert(wire.size() ==
sizeof(T));
83 boost::shared_ptr<T> number(
new T(0));
84 for (
unsigned int i = 0; i <
sizeof(T); ++i) {
85 ((
char*) number.get())[i] = wire[i];
90 typedef boost::shared_ptr< FloatingPointConverter<T> >
Ptr;
FloatingPointConverter(const std::string &wireSchema)
std::pair< std::string, boost::shared_ptr< void > > AnnotatedData
A combination of data type and the actual data.
Base class for floating point type converters.
virtual std::string getWireSchema() const
Returns the name of the wire schema this converter can (de)serialize from/to.
Converter for double type.
std::string serialize(const AnnotatedData &data, std::string &wire)
Serialized the given domain object to the wire.
AnnotatedData deserialize(const std::string &wireSchema, const std::string &wire)
Deserializes a domain object from a wire type.
virtual ~FloatingPointConverter()
Converter for float type.
virtual std::string getDataType() const
Returns the name of the data type this converter is applicable for.
boost::shared_ptr< FloatingPointConverter< T > > Ptr