From c08439ff4161206a3b75d7181e5cad8a9549b447 Mon Sep 17 00:00:00 2001 From: Takatoshi Kondo Date: Tue, 4 Mar 2014 15:14:11 +0900 Subject: [PATCH] Added STR to std::string conversion. --- src/msgpack/type/string.hpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/msgpack/type/string.hpp b/src/msgpack/type/string.hpp index 836de2c6..d072d861 100644 --- a/src/msgpack/type/string.hpp +++ b/src/msgpack/type/string.hpp @@ -26,8 +26,17 @@ namespace msgpack { inline std::string& operator>> (object const& o, std::string& v) { - if(o.type != type::BIN) { throw type_error(); } - v.assign(o.via.bin.ptr, o.via.bin.size); + switch (o.type) { + 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; }