Provide a simpler and safer version of qdtoa()
The new version returns a QString instead of a char * that has to be manually free()'d by the user. Also, it does away with most of the parameters so that we can replace the implementation with something saner without mapping all those modes between the implementations. Change-Id: I42ff95648e7955b9e74eb0f459a1fdedc1ad7efb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
52d5b27239
commit
bafbf3b872
|
|
@ -2614,4 +2614,14 @@ static char *_qdtoa( NEEDS_VOLATILE double d, int mode, int ndigits, int *decpt,
|
|||
return s0;
|
||||
}
|
||||
|
||||
QString qdtoa(qreal d, int *decpt, int *sign)
|
||||
{
|
||||
char *result = 0;
|
||||
char *constResult = 0;
|
||||
constResult = qdtoa(d, 0, 0, decpt, sign, 0, &result);
|
||||
const QString ret(QString::fromLatin1(result ? result : constResult));
|
||||
free(result);
|
||||
return ret;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ QT_BEGIN_NAMESPACE
|
|||
|
||||
QString qulltoa(qulonglong l, int base, const QChar _zero);
|
||||
QString qlltoa(qlonglong l, int base, const QChar zero);
|
||||
Q_CORE_EXPORT QString qdtoa(qreal d, int *decpt, int *sign);
|
||||
|
||||
enum PrecisionMode {
|
||||
PMDecimalDigits = 0x01,
|
||||
|
|
|
|||
Loading…
Reference in New Issue