diff --git a/include/fc/fixed_string.hpp b/include/fc/fixed_string.hpp index a91b651..3548cb0 100755 --- a/include/fc/fixed_string.hpp +++ b/include/fc/fixed_string.hpp @@ -121,11 +121,30 @@ namespace fc { left -= 1024; } s.read( buf, left ); + /* + s.seekp( s.tellp() + (size.value - sizeof(Storage)) ); + char tmp; + size.value -= sizeof(storage); + while( size.value ){ s.read( &tmp, 1 ); --size.value; } + */ + // s.skip( size.value - sizeof(Storage) ); } else { s.read( (char*)&u.data, size.value ); } } } + + /* + template + inline void pack( Stream& s, const boost::multiprecision::number& d ) { + s.write( (const char*)&d, sizeof(d) ); + } + + template + inline void unpack( Stream& s, boost::multiprecision::number& u ) { + s.read( (const char*)&u, sizeof(u) ); + } + */ } } diff --git a/include/fc/interprocess/container.hpp b/include/fc/interprocess/container.hpp index 7ede74b..7232be0 100755 --- a/include/fc/interprocess/container.hpp +++ b/include/fc/interprocess/container.hpp @@ -104,6 +104,8 @@ namespace fc { size_t r = fc::from_hex( str, d.data(), d.size() ); FC_ASSERT( r == d.size() ); } + // std::string b64 = base64_decode( var.as_string() ); + // vo = std::vector( b64.c_str(), b64.c_str() + b64.size() ); } namespace raw { diff --git a/include/fc/io/raw.hpp b/include/fc/io/raw.hpp index 2125865..29b69f0 100755 --- a/include/fc/io/raw.hpp +++ b/include/fc/io/raw.hpp @@ -667,6 +667,18 @@ namespace fc { return vec; } + template + inline std::vector pack( const T& v, Next... next ) { + datastream ps; + fc::raw::pack(ps,v,next...); + std::vector vec(ps.tellp()); + + if( vec.size() ) { + datastream ds( vec.data(), size_t(vec.size()) ); + fc::raw::pack(ds,v,next...); + } + return vec; + } template inline T unpack( const std::vector& s, uint32_t _max_depth ) diff --git a/include/fc/io/raw_fwd.hpp b/include/fc/io/raw_fwd.hpp index 42e955a..fb5cf48 100755 --- a/include/fc/io/raw_fwd.hpp +++ b/include/fc/io/raw_fwd.hpp @@ -62,9 +62,6 @@ namespace fc { template inline void pack( Stream& s, const std::map& value, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); template inline void unpack( Stream& s, std::map& value, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); - //template inline void pack( Stream& s, const flat_map& value, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); - //template inline void unpack( Stream& s, flat_map& value, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); - template inline void pack( Stream& s, const std::pair& value, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); template inline void unpack( Stream& s, std::pair& value, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); diff --git a/src/log/console_appender.cpp b/src/log/console_appender.cpp index af35564..98f1378 100755 --- a/src/log/console_appender.cpp +++ b/src/log/console_appender.cpp @@ -1,153 +1,153 @@ -#include -#include -#include -#include -#include -#include -#ifndef WIN32 -#include -#endif -#include -#define COLOR_CONSOLE 1 -#include "console_defines.h" -#include -#include -#include -#include -#include - - -namespace fc { - - class console_appender::impl { - public: - config cfg; - color::type lc[log_level::off+1]; -#ifdef WIN32 - HANDLE console_handle; -#endif - }; - - console_appender::console_appender( const variant& args ) - :my(new impl) - { - configure( args.as( FC_MAX_LOG_OBJECT_DEPTH ) ); - } - - console_appender::console_appender( const config& cfg ) - :my(new impl) - { - configure( cfg ); - } - console_appender::console_appender() - :my(new impl){} - - - void console_appender::configure( const config& console_appender_config ) - { try { -#ifdef WIN32 - my->console_handle = INVALID_HANDLE_VALUE; -#endif - my->cfg = console_appender_config; -#ifdef WIN32 - if (my->cfg.stream = stream::std_error) - my->console_handle = GetStdHandle(STD_ERROR_HANDLE); - else if (my->cfg.stream = stream::std_out) - my->console_handle = GetStdHandle(STD_OUTPUT_HANDLE); -#endif - - for( int i = 0; i < log_level::off+1; ++i ) - my->lc[i] = color::console_default; - for( auto itr = my->cfg.level_colors.begin(); itr != my->cfg.level_colors.end(); ++itr ) - my->lc[itr->level] = itr->color; - } FC_CAPTURE_AND_RETHROW( (console_appender_config) ) } - - console_appender::~console_appender() {} - - #ifdef WIN32 - static WORD - #else - static const char* - #endif - get_console_color(console_appender::color::type t ) { - switch( t ) { - case console_appender::color::red: return CONSOLE_RED; - case console_appender::color::green: return CONSOLE_GREEN; - case console_appender::color::brown: return CONSOLE_BROWN; - case console_appender::color::blue: return CONSOLE_BLUE; - case console_appender::color::magenta: return CONSOLE_MAGENTA; - case console_appender::color::cyan: return CONSOLE_CYAN; - case console_appender::color::white: return CONSOLE_WHITE; - case console_appender::color::console_default: - default: - return CONSOLE_DEFAULT; - } - } - - boost::mutex& log_mutex() { - static boost::mutex m; return m; - } - - void console_appender::log( const log_message& m ) { - - FILE* out = stream::std_error ? stderr : stdout; - - std::stringstream file_line; - file_line << m.get_context().get_file() <<":"<cfg.max_object_depth ); - line << message; - - fc::unique_lock lock(log_mutex()); - - print( line.str(), my->lc[m.get_context().get_log_level()] ); - - fprintf( out, "\n" ); - - if( my->cfg.flush ) fflush( out ); - } - - void console_appender::print( const std::string& text, color::type text_color ) - { - FILE* out = stream::std_error ? stderr : stdout; - - #ifdef WIN32 - if (my->console_handle != INVALID_HANDLE_VALUE) - SetConsoleTextAttribute(my->console_handle, get_console_color(text_color)); - #else - if(isatty(fileno(out))) fprintf( out, "\r%s", get_console_color( text_color ) ); - #endif - - if( text.size() ) - fprintf( out, "%s", text.c_str() ); - - #ifdef WIN32 - if (my->console_handle != INVALID_HANDLE_VALUE) - SetConsoleTextAttribute(my->console_handle, CONSOLE_DEFAULT); - #else - if(isatty(fileno(out))) fprintf( out, "\r%s", CONSOLE_DEFAULT ); - #endif - - if( my->cfg.flush ) fflush( out ); - } - -} +#include +#include +#include +#include +#include +#include +#ifndef WIN32 +#include +#endif +#include +#define COLOR_CONSOLE 1 +#include "console_defines.h" +#include +#include +#include +#include +#include + + +namespace fc { + + class console_appender::impl { + public: + config cfg; + color::type lc[log_level::off+1]; +#ifdef WIN32 + HANDLE console_handle; +#endif + }; + + console_appender::console_appender( const variant& args ) + :my(new impl) + { + configure( args.as( FC_MAX_LOG_OBJECT_DEPTH ) ); + } + + console_appender::console_appender( const config& cfg ) + :my(new impl) + { + configure( cfg ); + } + console_appender::console_appender() + :my(new impl){} + + + void console_appender::configure( const config& console_appender_config ) + { try { +#ifdef WIN32 + my->console_handle = INVALID_HANDLE_VALUE; +#endif + my->cfg = console_appender_config; +#ifdef WIN32 + if (my->cfg.stream = stream::std_error) + my->console_handle = GetStdHandle(STD_ERROR_HANDLE); + else if (my->cfg.stream = stream::std_out) + my->console_handle = GetStdHandle(STD_OUTPUT_HANDLE); +#endif + + for( int i = 0; i < log_level::off+1; ++i ) + my->lc[i] = color::console_default; + for( auto itr = my->cfg.level_colors.begin(); itr != my->cfg.level_colors.end(); ++itr ) + my->lc[itr->level] = itr->color; + } FC_CAPTURE_AND_RETHROW( (console_appender_config) ) } + + console_appender::~console_appender() {} + + #ifdef WIN32 + static WORD + #else + static const char* + #endif + get_console_color(console_appender::color::type t ) { + switch( t ) { + case console_appender::color::red: return CONSOLE_RED; + case console_appender::color::green: return CONSOLE_GREEN; + case console_appender::color::brown: return CONSOLE_BROWN; + case console_appender::color::blue: return CONSOLE_BLUE; + case console_appender::color::magenta: return CONSOLE_MAGENTA; + case console_appender::color::cyan: return CONSOLE_CYAN; + case console_appender::color::white: return CONSOLE_WHITE; + case console_appender::color::console_default: + default: + return CONSOLE_DEFAULT; + } + } + + boost::mutex& log_mutex() { + static boost::mutex m; return m; + } + + void console_appender::log( const log_message& m ) { + + FILE* out = stream::std_error ? stderr : stdout; + + std::stringstream file_line; + file_line << m.get_context().get_file() <<":"<cfg.max_object_depth ); + line << message; + + fc::unique_lock lock(log_mutex()); + + print( line.str(), my->lc[m.get_context().get_log_level()] ); + + fprintf( out, "\n" ); + + if( my->cfg.flush ) fflush( out ); + } + + void console_appender::print( const std::string& text, color::type text_color ) + { + FILE* out = stream::std_error ? stderr : stdout; + + #ifdef WIN32 + if (my->console_handle != INVALID_HANDLE_VALUE) + SetConsoleTextAttribute(my->console_handle, get_console_color(text_color)); + #else + if(isatty(fileno(out))) fprintf( out, "\r%s", get_console_color( text_color ) ); + #endif + + if( text.size() ) + fprintf( out, "%s", text.c_str() ); + + #ifdef WIN32 + if (my->console_handle != INVALID_HANDLE_VALUE) + SetConsoleTextAttribute(my->console_handle, CONSOLE_DEFAULT); + #else + if(isatty(fileno(out))) fprintf( out, "\r%s", CONSOLE_DEFAULT ); + #endif + + if( my->cfg.flush ) fflush( out ); + } + +} diff --git a/src/string.cpp b/src/string.cpp index 2432360..ffea42a 100755 --- a/src/string.cpp +++ b/src/string.cpp @@ -312,7 +312,6 @@ namespace fc { } return ss.str(); } - } // namespace fc