diff --git a/include/fc/io/raw.hpp b/include/fc/io/raw.hpp index 2268e3720..24aff5eca 100644 --- a/include/fc/io/raw.hpp +++ b/include/fc/io/raw.hpp @@ -143,6 +143,13 @@ namespace fc { fc::raw::pack( s, *v, _max_depth - 1 ); } + template + inline void pack( Stream& s, const std::shared_ptr& v, uint32_t _max_depth ) + { + FC_ASSERT( _max_depth > 0 ); + fc::raw::pack( s, *v, _max_depth - 1 ); + } + template inline void unpack( Stream& s, fc::array& v, uint32_t _max_depth ) { try { @@ -157,6 +164,15 @@ namespace fc { fc::raw::unpack( s, *v, _max_depth - 1 ); } FC_RETHROW_EXCEPTIONS( warn, "std::shared_ptr", ("type",fc::get_typename::name()) ) } + template + inline void unpack( Stream& s, std::shared_ptr& v, uint32_t _max_depth ) + { try { + FC_ASSERT( _max_depth > 0 ); + T tmp; + fc::raw::unpack( s, tmp, _max_depth - 1 ); + v = std::make_shared(std::move(tmp)); + } FC_RETHROW_EXCEPTIONS( warn, "std::shared_ptr", ("type",fc::get_typename::name()) ) } + template inline void pack( Stream& s, const unsigned_int& v, uint32_t _max_depth ) { uint64_t val = v.value; do { diff --git a/include/fc/io/raw_fwd.hpp b/include/fc/io/raw_fwd.hpp index 87a92084a..df807685f 100644 --- a/include/fc/io/raw_fwd.hpp +++ b/include/fc/io/raw_fwd.hpp @@ -126,6 +126,16 @@ namespace fc { template inline void pack( Stream& s, const fc::array& v, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); template inline void unpack( Stream& s, fc::array& v, uint32_t _max_depth=FC_PACK_MAX_DEPTH); + template inline void pack( Stream& s, const shared_ptr& v, + uint32_t _max_depth=FC_PACK_MAX_DEPTH ); + template inline void unpack( Stream& s, shared_ptr& v, + uint32_t _max_depth=FC_PACK_MAX_DEPTH ); + + template inline void pack( Stream& s, const shared_ptr& v, + uint32_t _max_depth=FC_PACK_MAX_DEPTH ); + template inline void unpack( Stream& s, shared_ptr& v, + uint32_t _max_depth=FC_PACK_MAX_DEPTH ); + template inline void pack( Stream& s, const bool& v, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); template inline void unpack( Stream& s, bool& v, uint32_t _max_depth=FC_PACK_MAX_DEPTH );