39 const string BoolConverter::WIRE_SCHEMA =
"bool";
41 BoolConverter::BoolConverter() :
49 assert(data.first == this->getDataType());
51 boost::shared_ptr<bool> s
52 = boost::static_pointer_cast<
bool>(data.second);
54 wire[0] = ((*s) ? 1 : 0);
62 if (wire.size() == 1 && wire[0] == 0) {
63 return make_pair(
getDataType(), boost::shared_ptr<bool>(
new bool(
false)));
64 }
else if (wire.size() == 1 && wire[0] == 1) {
65 return make_pair(
getDataType(), boost::shared_ptr<bool>(
new bool(
true)));
67 throw runtime_error(
"Invalid encoding for bool.");
std::pair< std::string, boost::shared_ptr< void > > AnnotatedData
A combination of data type and the actual data.
static const std::string WIRE_SCHEMA
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.
std::string serialize(const AnnotatedData &data, std::string &wire)
Serialized the given domain object to the wire.