diff --git a/include/fc/array.hpp b/include/fc/array.hpp index 2796456..6a2053c 100644 --- a/include/fc/array.hpp +++ b/include/fc/array.hpp @@ -1,6 +1,7 @@ #pragma once #include #include +#include namespace fc { @@ -112,6 +113,14 @@ namespace fc { } + template struct get_typename< fc::array > + { + static const char* name() + { + static std::string _name = std::string("fc::array<")+std::string(fc::get_typename::name())+","+ fc::to_string(N) + ">"; + return _name.c_str(); + } + }; } #include @@ -127,3 +136,4 @@ namespace std } }; } + diff --git a/include/fc/crypto/elliptic.hpp b/include/fc/crypto/elliptic.hpp index 2fbec10..03502be 100644 --- a/include/fc/crypto/elliptic.hpp +++ b/include/fc/crypto/elliptic.hpp @@ -153,3 +153,7 @@ namespace fc { } // namespace raw } // namespace fc +#include + +FC_REFLECT_TYPENAME( fc::ecc::private_key ) +FC_REFLECT_TYPENAME( fc::ecc::public_key ) diff --git a/include/fc/crypto/sha256.hpp b/include/fc/crypto/sha256.hpp index 96194e0..ea7b17e 100644 --- a/include/fc/crypto/sha256.hpp +++ b/include/fc/crypto/sha256.hpp @@ -95,3 +95,5 @@ namespace std } }; } +#include +FC_REFLECT_TYPENAME( fc::sha256 ) diff --git a/include/fc/crypto/sha512.hpp b/include/fc/crypto/sha512.hpp index fe24a1b..3fa2352 100644 --- a/include/fc/crypto/sha512.hpp +++ b/include/fc/crypto/sha512.hpp @@ -72,3 +72,6 @@ class sha512 void from_variant( const variant& v, sha512& bi ); } // fc + +#include +FC_REFLECT_TYPENAME( fc::sha512 ) diff --git a/include/fc/io/raw.hpp b/include/fc/io/raw.hpp index 6468468..411de23 100644 --- a/include/fc/io/raw.hpp +++ b/include/fc/io/raw.hpp @@ -37,11 +37,11 @@ namespace fc { template inline void unpack( Stream& s, fc::time_point_sec& tp ) - { + { try { uint32_t sec; s.read( (char*)&sec, sizeof(sec) ); tp = fc::time_point() + fc::seconds(sec); - } + } FC_RETHROW_EXCEPTIONS( warn, "" ) } template inline void pack( Stream& s, const fc::time_point& tp ) @@ -52,11 +52,11 @@ namespace fc { template inline void unpack( Stream& s, fc::time_point& tp ) - { + { try { uint64_t usec; s.read( (char*)&usec, sizeof(usec) ); tp = fc::time_point() + fc::microseconds(usec); - } + } FC_RETHROW_EXCEPTIONS( warn, "" ) } template inline void pack( Stream& s, const fc::array& v) { @@ -64,9 +64,10 @@ namespace fc { } template - inline void unpack( Stream& s, fc::array& v) { + inline void unpack( Stream& s, fc::array& v) + { try { s.read((char*)&v.data[0],N*sizeof(T)); - } + } FC_RETHROW_EXCEPTIONS( warn, "fc::array", ("type",fc::get_typename::name())("length",N) ) } template inline void pack( Stream& s, const signed_int& v ) { uint32_t val = (v.value<<1) ^ (v.value>>31); @@ -119,10 +120,11 @@ namespace fc { } template - void unpack( Stream& s, fc::optional& v ) { + void unpack( Stream& s, fc::optional& v ) + { try { bool b; unpack( s, b ); if( b ) { v = T(); unpack( s, *v ); } - } + } FC_RETHROW_EXCEPTIONS( warn, "optional<${type}>", ("type",fc::get_typename::name() ) ) } // std::vector template inline void pack( Stream& s, const std::vector& value ) { @@ -177,9 +179,10 @@ namespace fc { :c(_c),s(_s){} template - inline void operator()( const char* name )const { + inline void operator()( const char* name )const + { try { raw::unpack( s, c.*p ); - } + } FC_RETHROW_EXCEPTIONS( warn, "Error unpacking field ${field}", ("field",name) ) } private: Class& c; Stream& s; @@ -371,9 +374,10 @@ namespace fc { fc::raw::detail::if_reflected< typename fc::reflector::is_defined >::pack(s,v); } template - inline void unpack( Stream& s, T& v ) { + inline void unpack( Stream& s, T& v ) + { try { fc::raw::detail::if_reflected< typename fc::reflector::is_defined >::unpack(s,v); - } + } FC_RETHROW_EXCEPTIONS( warn, "error unpacking ${type}", ("type",fc::get_typename::name() ) ) } template @@ -390,14 +394,15 @@ namespace fc { } template - inline T unpack( const std::vector& s ) { + inline T unpack( const std::vector& s ) + { try { T tmp; if( s.size() ) { datastream ds( s.data(), size_t(s.size()) ); raw::unpack(ds,tmp); } return tmp; - } + } FC_RETHROW_EXCEPTIONS( warn, "error unpacking ${type}", ("type",fc::get_typename::name() ) ) } template inline void pack( char* d, uint32_t s, const T& v ) { @@ -406,18 +411,21 @@ namespace fc { } template - inline T unpack( const char* d, uint32_t s ) { + inline T unpack( const char* d, uint32_t s ) + { try { T v; datastream ds( d, s ); raw::unpack(ds,v); return v; - } + } FC_RETHROW_EXCEPTIONS( warn, "error unpacking ${type}", ("type",fc::get_typename::name() ) ) } + template - inline void unpack( const char* d, uint32_t s, T& v ) { + inline void unpack( const char* d, uint32_t s, T& v ) + { try { datastream ds( d, s ); raw::unpack(ds,v); return v; - } + } FC_RETHROW_EXCEPTIONS( warn, "error unpacking ${type}", ("type",fc::get_typename::name() ) ) } } } // namespace fc::raw diff --git a/include/fc/time.hpp b/include/fc/time.hpp index 204d586..06d40e3 100644 --- a/include/fc/time.hpp +++ b/include/fc/time.hpp @@ -111,6 +111,10 @@ namespace fc { string get_approximate_relative_time_string(const time_point& event_time); } +#include +FC_REFLECT_TYPENAME( fc::time_point ) +FC_REFLECT_TYPENAME( fc::time_point_sec ) + #ifdef _MSC_VER #pragma warning (pop) #endif /// #ifdef _MSC_VER