mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Show numbers with space as thousand separator
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaMemoryCleanup.h"
|
||||
#include "RiaStdStringTools.h"
|
||||
|
||||
#include "RigCaseCellResultsData.h"
|
||||
#include "RigEclipseResultInfo.h"
|
||||
@@ -399,9 +400,11 @@ std::pair<QString, QString> RiaMemoryCleanup::createMemoryReport()
|
||||
size_t memory = valueCount * sizeof( double );
|
||||
totalMemoryForCase += memory;
|
||||
|
||||
auto formattedValueCount = RiaStdStringTools::formatThousandGrouping( valueCount );
|
||||
|
||||
caseReport += QString( " %1 MB\tValue count %2, %3\n" )
|
||||
.arg( memory / 1024.0 / 1024.0, 0, 'f', 2 )
|
||||
.arg( valueCount )
|
||||
.arg( QString::fromStdString( formattedValueCount ) )
|
||||
.arg( QString::fromStdString( name ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,6 +138,26 @@ bool RiaStdStringTools::startsWithAlphabetic( const std::string& s )
|
||||
return isalpha( s[0] ) != 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::string RiaStdStringTools::formatThousandGrouping( long value )
|
||||
{
|
||||
class my_punct : public std::numpunct<char>
|
||||
{
|
||||
protected:
|
||||
virtual char do_decimal_point() const { return '.'; }
|
||||
virtual char do_thousands_sep() const { return ' '; }
|
||||
virtual std::string do_grouping() const { return std::string( "\3" ); }
|
||||
};
|
||||
|
||||
std::ostringstream os;
|
||||
os.imbue( std::locale( os.getloc(), new my_punct ) );
|
||||
fixed( os );
|
||||
os << value;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -43,6 +43,8 @@ public:
|
||||
static bool containsAlphabetic( const std::string& s );
|
||||
static bool startsWithAlphabetic( const std::string& s );
|
||||
|
||||
static std::string formatThousandGrouping( long value );
|
||||
|
||||
// Conversion using fastest known approach
|
||||
static bool toDouble( const std::string_view& s, double& value );
|
||||
static bool toInt( const std::string_view& s, int& value );
|
||||
|
||||
Reference in New Issue
Block a user