Add support for unsigned long long to wxNumberFormatter

This is necessary in order to deal with the numbers greater than
wxINT64_MAX that can't be represented in just long long.

It also allows to implement the intuitive handling of minus sign for the
unsigned numbers, i.e. not to accept it in FromString(), unlike the
standard functions which do (and parse -1 as 0xffff...fff).

Also extend the tests to check for more boundary cases.
This commit is contained in:
Vadim Zeitlin
2021-02-21 17:28:02 +01:00
parent 959d955a80
commit eb64202ad4
4 changed files with 95 additions and 0 deletions

View File

@@ -73,6 +73,7 @@ public:
//@{
static wxString ToString(long val, int flags = Style_WithThousandsSep);
static wxString ToString(long long val, int flags = Style_WithThousandsSep);
static wxString ToString(unsigned long long val, int flags = Style_WithThousandsSep);
//@}
/**
@@ -97,11 +98,18 @@ public:
success they return @true and store the result at the location pointed
to by @a val (which can't be @NULL), otherwise @false is returned.
Note that the overload taking unsigned long long value is only
available since wxWidgets 3.1.5. Also, unlike wxString::ToULongLong()
and the standard functions such as @c strtoul(), this overload does
@em not accept, i.e. returns @false, for the strings starting with the
minus sign.
@see wxString::ToLong(), wxString::ToDouble()
*/
//@{
static bool FromString(wxString s, long *val);
static bool FromString(wxString s, long long *val);
static bool FromString(wxString s, unsigned long long *val);
static bool FromString(wxString s, double *val);
//@}