adding pretty print
This commit is contained in:
parent
57e1d60257
commit
5a0f996333
2 changed files with 17 additions and 0 deletions
|
|
@ -16,6 +16,7 @@ namespace fc
|
||||||
fc::string to_string( uint64_t );
|
fc::string to_string( uint64_t );
|
||||||
fc::string to_string( int64_t );
|
fc::string to_string( int64_t );
|
||||||
fc::string to_string( uint16_t );
|
fc::string to_string( uint16_t );
|
||||||
|
std::string to_pretty_string( int64_t );
|
||||||
inline fc::string to_string( int32_t v ) { return to_string( int64_t(v) ); }
|
inline fc::string to_string( int32_t v ) { return to_string( int64_t(v) ); }
|
||||||
inline fc::string to_string( uint32_t v ){ return to_string( uint64_t(v) ); }
|
inline fc::string to_string( uint32_t v ){ return to_string( uint64_t(v) ); }
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,28 @@
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <locale>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implemented with std::string for now.
|
* Implemented with std::string for now.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace fc {
|
namespace fc {
|
||||||
|
class comma_numpunct : public std::numpunct<char>
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
virtual char do_thousands_sep() const { return ','; }
|
||||||
|
virtual std::string do_grouping() const { return "\03"; }
|
||||||
|
};
|
||||||
|
|
||||||
|
std::string to_pretty_string( int64_t value )
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss.imbue( {std::locale(), new comma_numpunct} );
|
||||||
|
ss << std::fixed << value;
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef USE_FC_STRING
|
#ifdef USE_FC_STRING
|
||||||
string::string(const char* s, int l) :my(s,l){ }
|
string::string(const char* s, int l) :my(s,l){ }
|
||||||
string::string(){}
|
string::string(){}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue