Added STR to std::string conversion.

This commit is contained in:
Takatoshi Kondo 2014-03-04 15:14:11 +09:00
parent 59d994ea5f
commit c08439ff41

View File

@ -26,8 +26,17 @@ namespace msgpack {
inline std::string& operator>> (object const& o, std::string& v) inline std::string& operator>> (object const& o, std::string& v)
{ {
if(o.type != type::BIN) { throw type_error(); } switch (o.type) {
v.assign(o.via.bin.ptr, o.via.bin.size); case type::BIN:
v.assign(o.via.bin.ptr, o.via.bin.size);
break;
case type::STR:
v.assign(o.via.str.ptr, o.via.str.size);
break;
default:
throw type_error();
break;
}
return v; return v;
} }