diff options
Diffstat (limited to 'src/serialization/binary_utils.h')
-rw-r--r-- | src/serialization/binary_utils.h | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/src/serialization/binary_utils.h b/src/serialization/binary_utils.h index 3b1db3e48..f2cfadd4e 100644 --- a/src/serialization/binary_utils.h +++ b/src/serialization/binary_utils.h @@ -34,23 +34,26 @@ #include "binary_archive.h" namespace serialization { + /*! creates a new archive with the passed blob and serializes it into v + */ + template <class T> + bool parse_binary(const std::string &blob, T &v) + { + std::istringstream istr(blob); + binary_archive<false> iar(istr); + return ::serialization::serialize(iar, v); + } -template <class T> -bool parse_binary(const std::string &blob, T &v) -{ - std::istringstream istr(blob); - binary_archive<false> iar(istr); - return ::serialization::serialize(iar, v); -} - -template<class T> -bool dump_binary(T& v, std::string& blob) -{ - std::stringstream ostr; - binary_archive<true> oar(ostr); - bool success = ::serialization::serialize(oar, v); - blob = ostr.str(); - return success && ostr.good(); -}; + /*! dumps the data in v into the blob string + */ + template<class T> + bool dump_binary(T& v, std::string& blob) + { + std::stringstream ostr; + binary_archive<true> oar(ostr); + bool success = ::serialization::serialize(oar, v); + blob = ostr.str(); + return success && ostr.good(); + }; -} // namespace serialization +} |