From 81c0290568df3b8ed058b7181206dcc4467379de Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Sat, 21 Sep 2013 22:48:50 -0400 Subject: [PATCH] raw pack of fc::path --- include/fc/crypto/ripemd160.hpp | 1 + include/fc/crypto/sha256.hpp | 8 ++++++++ include/fc/io/raw.hpp | 14 ++++++++++++++ include/fc/io/raw_fwd.hpp | 4 ++++ 4 files changed, 27 insertions(+) diff --git a/include/fc/crypto/ripemd160.hpp b/include/fc/crypto/ripemd160.hpp index fa84df6..9816fe4 100644 --- a/include/fc/crypto/ripemd160.hpp +++ b/include/fc/crypto/ripemd160.hpp @@ -73,6 +73,7 @@ class ripemd160 void from_variant( const variant& v, ripemd160& bi ); typedef ripemd160 uint160_t; + typedef ripemd160 uint160; } // namespace fc diff --git a/include/fc/crypto/sha256.hpp b/include/fc/crypto/sha256.hpp index 3343236..be46f8b 100644 --- a/include/fc/crypto/sha256.hpp +++ b/include/fc/crypto/sha256.hpp @@ -61,6 +61,14 @@ class sha256 friend bool operator >= ( const sha256& h1, const sha256& h2 ); friend bool operator > ( const sha256& h1, const sha256& h2 ); friend bool operator < ( const sha256& h1, const sha256& h2 ); + + uint32_t pop_count() + { + return __builtin_popcountll(_hash[0]) + + __builtin_popcountll(_hash[1]) + + __builtin_popcountll(_hash[2]) + + __builtin_popcountll(_hash[3]); + } uint64_t _hash[4]; }; diff --git a/include/fc/io/raw.hpp b/include/fc/io/raw.hpp index 65511d1..7c84cd6 100644 --- a/include/fc/io/raw.hpp +++ b/include/fc/io/raw.hpp @@ -7,12 +7,26 @@ #include #include #include +#include #include #define MAX_ARRAY_ALLOC_SIZE (1024*1024*10) namespace fc { namespace raw { + template + inline void pack( Stream& s, const fc::path& tp ) + { + fc::raw::pack( s, tp.generic_string() ); + } + + template + inline void unpack( Stream& s, fc::path& tp ) + { + std::string p; + fc::raw::unpack( s, p ); + tp = p; + } template inline void pack( Stream& s, const fc::time_point_sec& tp ) diff --git a/include/fc/io/raw_fwd.hpp b/include/fc/io/raw_fwd.hpp index 0e7f088..741fe13 100644 --- a/include/fc/io/raw_fwd.hpp +++ b/include/fc/io/raw_fwd.hpp @@ -11,6 +11,7 @@ namespace fc { class time_point_sec; class variant; class variant_object; + class path; template class enum_type; namespace ecc { class public_key; class private_key; } @@ -29,6 +30,9 @@ namespace fc { template inline void pack( Stream& s, const variant& v ); template inline void unpack( Stream& s, variant& v ); + template inline void pack( Stream& s, const path& v ); + template inline void unpack( Stream& s, path& v ); + template void unpack( Stream& s, fc::optional& v ); template void pack( Stream& s, const fc::optional& v );