changed: misc::OnlyDigit()
a comma is changed to a dot git-svn-id: svn://ttmath.org/publicrep/winix/trunk@835 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
07e8e0c63c
commit
67099d5d06
|
@ -262,9 +262,11 @@ void MaxSize(StringType & str, size_t max_size)
|
||||||
this method removing all characters from given string
|
this method removing all characters from given string
|
||||||
only digits are allowed and if allow_comma then one comma (or dot)
|
only digits are allowed and if allow_comma then one comma (or dot)
|
||||||
character is allowed
|
character is allowed
|
||||||
|
|
||||||
|
if change_to_dot is true then if a comma exists then it is changed to a dot
|
||||||
*/
|
*/
|
||||||
template<class StringType>
|
template<class StringType>
|
||||||
void OnlyDigit(StringType & s, bool allow_comma = true)
|
void OnlyDigit(StringType & s, bool allow_comma = true, bool change_to_dot = true)
|
||||||
{
|
{
|
||||||
typename StringType::size_type i;
|
typename StringType::size_type i;
|
||||||
bool was_comma = false;
|
bool was_comma = false;
|
||||||
|
@ -280,6 +282,9 @@ bool was_comma = false;
|
||||||
if( (s[i]>='0' && s[i]<='9') ||
|
if( (s[i]>='0' && s[i]<='9') ||
|
||||||
(allow_comma && !was_comma && (s[i]=='.' || s[i]==',')) )
|
(allow_comma && !was_comma && (s[i]=='.' || s[i]==',')) )
|
||||||
{
|
{
|
||||||
|
if( change_to_dot && s[i] == ',' )
|
||||||
|
s[i] = '.';
|
||||||
|
|
||||||
if( s[i]=='.' || s[i]==',' )
|
if( s[i]=='.' || s[i]==',' )
|
||||||
was_comma = true;
|
was_comma = true;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue