mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-23 00:02:38 -05:00
src/core/numericformats: avoid potential one-definition-rule violation
This commit is contained in:
parent
3220819a2b
commit
e7d6063d3a
@ -21,21 +21,24 @@
|
||||
#include <locale>
|
||||
#include <iomanip>
|
||||
|
||||
struct formatter : std::numpunct<wchar_t>
|
||||
namespace QgsBasicNumericFormat_ns
|
||||
{
|
||||
formatter( QChar thousands, bool showThousands, QChar decimal )
|
||||
: mThousands( thousands.unicode() )
|
||||
, mDecimal( decimal.unicode() )
|
||||
, mShowThousands( showThousands )
|
||||
{}
|
||||
wchar_t do_decimal_point() const override { return mDecimal; }
|
||||
wchar_t do_thousands_sep() const override { return mThousands; }
|
||||
std::string do_grouping() const override { return mShowThousands ? "\3" : "\0"; }
|
||||
struct formatter : std::numpunct<wchar_t>
|
||||
{
|
||||
formatter( QChar thousands, bool showThousands, QChar decimal )
|
||||
: mThousands( thousands.unicode() )
|
||||
, mDecimal( decimal.unicode() )
|
||||
, mShowThousands( showThousands )
|
||||
{}
|
||||
wchar_t do_decimal_point() const override { return mDecimal; }
|
||||
wchar_t do_thousands_sep() const override { return mThousands; }
|
||||
std::string do_grouping() const override { return mShowThousands ? "\3" : "\0"; }
|
||||
|
||||
wchar_t mThousands;
|
||||
wchar_t mDecimal;
|
||||
bool mShowThousands = true;
|
||||
};
|
||||
wchar_t mThousands;
|
||||
wchar_t mDecimal;
|
||||
bool mShowThousands = true;
|
||||
};
|
||||
}
|
||||
|
||||
QgsBasicNumericFormat::QgsBasicNumericFormat()
|
||||
{
|
||||
@ -60,7 +63,7 @@ QString QgsBasicNumericFormat::formatDouble( double value, const QgsNumericForma
|
||||
{
|
||||
const QChar decimal = mDecimalSeparator.isNull() ? context.decimalSeparator() : mDecimalSeparator;
|
||||
std::basic_stringstream<wchar_t> os;
|
||||
os.imbue( std::locale( os.getloc(), new formatter( mThousandsSeparator.isNull() ? context.thousandsSeparator() : mThousandsSeparator,
|
||||
os.imbue( std::locale( os.getloc(), new QgsBasicNumericFormat_ns::formatter( mThousandsSeparator.isNull() ? context.thousandsSeparator() : mThousandsSeparator,
|
||||
mShowThousandsSeparator,
|
||||
decimal ) ) );
|
||||
|
||||
|
@ -24,21 +24,24 @@
|
||||
#include <iomanip>
|
||||
|
||||
///@cond PRIVATE
|
||||
struct formatter : std::numpunct<wchar_t>
|
||||
namespace QgsGeographicCoordinateNumericFormat_ns
|
||||
{
|
||||
formatter( QChar thousands, bool showThousands, QChar decimal )
|
||||
: mThousands( thousands.unicode() )
|
||||
, mDecimal( decimal.unicode() )
|
||||
, mShowThousands( showThousands )
|
||||
{}
|
||||
wchar_t do_decimal_point() const override { return mDecimal; }
|
||||
wchar_t do_thousands_sep() const override { return mThousands; }
|
||||
std::string do_grouping() const override { return mShowThousands ? "\3" : "\0"; }
|
||||
struct formatter : std::numpunct<wchar_t>
|
||||
{
|
||||
formatter( QChar thousands, bool showThousands, QChar decimal )
|
||||
: mThousands( thousands.unicode() )
|
||||
, mDecimal( decimal.unicode() )
|
||||
, mShowThousands( showThousands )
|
||||
{}
|
||||
wchar_t do_decimal_point() const override { return mDecimal; }
|
||||
wchar_t do_thousands_sep() const override { return mThousands; }
|
||||
std::string do_grouping() const override { return mShowThousands ? "\3" : "\0"; }
|
||||
|
||||
wchar_t mThousands;
|
||||
wchar_t mDecimal;
|
||||
bool mShowThousands = true;
|
||||
};
|
||||
wchar_t mThousands;
|
||||
wchar_t mDecimal;
|
||||
bool mShowThousands = true;
|
||||
};
|
||||
}
|
||||
///@endcond
|
||||
|
||||
QgsGeographicCoordinateNumericFormat::QgsGeographicCoordinateNumericFormat()
|
||||
@ -69,7 +72,7 @@ QString QgsGeographicCoordinateNumericFormat::formatDouble( double value, const
|
||||
{
|
||||
const QChar decimal = decimalSeparator().isNull() ? context.decimalSeparator() : decimalSeparator();
|
||||
std::basic_stringstream<wchar_t> os;
|
||||
os.imbue( std::locale( os.getloc(), new formatter( thousandsSeparator().isNull() ? context.thousandsSeparator() : thousandsSeparator(),
|
||||
os.imbue( std::locale( os.getloc(), new QgsGeographicCoordinateNumericFormat_ns::formatter( thousandsSeparator().isNull() ? context.thousandsSeparator() : thousandsSeparator(),
|
||||
false,
|
||||
decimal ) ) );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user