comparison lphobos/std/string.d @ 473:373489eeaf90

Applied downs' lphobos update
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Mon, 04 Aug 2008 19:28:49 +0200
parents 288fe1029e1f
children bdb3627265eb
comparison
equal deleted inserted replaced
472:15c804b6ce77 473:373489eeaf90
3441 { 3441 {
3442 return isNumeric(_arguments, _argptr); 3442 return isNumeric(_arguments, _argptr);
3443 } 3443 }
3444 3444
3445 /// Check only the first parameter, all others will be ignored. 3445 /// Check only the first parameter, all others will be ignored.
3446 bool isNumeric(TypeInfo[] _arguments, va_list _argptr) 3446 bool isNumeric(TypeInfo[] _args, va_list _ptr)
3447 { 3447 {
3448 char[] s = ""; 3448 char[] s = "";
3449 wchar[] ws = ""; 3449 wchar[] ws = "";
3450 dchar[] ds = ""; 3450 dchar[] ds = "";
3451 3451
3452 //writefln("isNumeric(...) called!"); 3452 //writefln("isNumeric(...) called!");
3453 if (_arguments.length == 0) 3453 if (_args.length == 0)
3454 return false; 3454 return false;
3455 3455
3456 if (_arguments[0] == typeid(char[])) 3456 if (_args[0] == typeid(char[]))
3457 return isNumeric(va_arg!(char[])(_argptr)); 3457 return isNumeric(va_arg!(char[])(_ptr));
3458 else if (_arguments[0] == typeid(wchar[])) 3458 else if (_args[0] == typeid(wchar[]))
3459 return isNumeric(std.utf.toUTF8(va_arg!(wchar[])(_argptr))); 3459 return isNumeric(std.utf.toUTF8(va_arg!(wchar[])(_ptr)));
3460 else if (_arguments[0] == typeid(dchar[])) 3460 else if (_args[0] == typeid(dchar[]))
3461 return isNumeric(std.utf.toUTF8(va_arg!(dchar[])(_argptr))); 3461 return isNumeric(std.utf.toUTF8(va_arg!(dchar[])(_ptr)));
3462 else if (_arguments[0] == typeid(real)) 3462 else if (_args[0] == typeid(real))
3463 return true; 3463 return true;
3464 else if (_arguments[0] == typeid(double)) 3464 else if (_args[0] == typeid(double))
3465 return true; 3465 return true;
3466 else if (_arguments[0] == typeid(float)) 3466 else if (_args[0] == typeid(float))
3467 return true; 3467 return true;
3468 else if (_arguments[0] == typeid(ulong)) 3468 else if (_args[0] == typeid(ulong))
3469 return true; 3469 return true;
3470 else if (_arguments[0] == typeid(long)) 3470 else if (_args[0] == typeid(long))
3471 return true; 3471 return true;
3472 else if (_arguments[0] == typeid(uint)) 3472 else if (_args[0] == typeid(uint))
3473 return true; 3473 return true;
3474 else if (_arguments[0] == typeid(int)) 3474 else if (_args[0] == typeid(int))
3475 return true; 3475 return true;
3476 else if (_arguments[0] == typeid(ushort)) 3476 else if (_args[0] == typeid(ushort))
3477 return true; 3477 return true;
3478 else if (_arguments[0] == typeid(short)) 3478 else if (_args[0] == typeid(short))
3479 return true; 3479 return true;
3480 else if (_arguments[0] == typeid(ubyte)) 3480 else if (_args[0] == typeid(ubyte))
3481 { 3481 {
3482 s.length = 1; 3482 s.length = 1;
3483 s[0]= va_arg!(ubyte)(_argptr); 3483 s[0]= va_arg!(ubyte)(_ptr);
3484 return isNumeric(cast(char[])s); 3484 return isNumeric(cast(char[])s);
3485 } 3485 }
3486 else if (_arguments[0] == typeid(byte)) 3486 else if (_args[0] == typeid(byte))
3487 { 3487 {
3488 s.length = 1; 3488 s.length = 1;
3489 s[0] = va_arg!(byte)(_argptr); 3489 s[0] = va_arg!(byte)(_ptr);
3490 return isNumeric(cast(char[])s); 3490 return isNumeric(cast(char[])s);
3491 } 3491 }
3492 else if (_arguments[0] == typeid(ireal)) 3492 else if (_args[0] == typeid(ireal))
3493 return true; 3493 return true;
3494 else if (_arguments[0] == typeid(idouble)) 3494 else if (_args[0] == typeid(idouble))
3495 return true; 3495 return true;
3496 else if (_arguments[0] == typeid(ifloat)) 3496 else if (_args[0] == typeid(ifloat))
3497 return true; 3497 return true;
3498 else if (_arguments[0] == typeid(creal)) 3498 else if (_args[0] == typeid(creal))
3499 return true; 3499 return true;
3500 else if (_arguments[0] == typeid(cdouble)) 3500 else if (_args[0] == typeid(cdouble))
3501 return true; 3501 return true;
3502 else if (_arguments[0] == typeid(cfloat)) 3502 else if (_args[0] == typeid(cfloat))
3503 return true; 3503 return true;
3504 else if (_arguments[0] == typeid(char)) 3504 else if (_args[0] == typeid(char))
3505 { 3505 {
3506 s.length = 1; 3506 s.length = 1;
3507 s[0] = va_arg!(char)(_argptr); 3507 s[0] = va_arg!(char)(_ptr);
3508 return isNumeric(s); 3508 return isNumeric(s);
3509 } 3509 }
3510 else if (_arguments[0] == typeid(wchar)) 3510 else if (_args[0] == typeid(wchar))
3511 { 3511 {
3512 ws.length = 1; 3512 ws.length = 1;
3513 ws[0] = va_arg!(wchar)(_argptr); 3513 ws[0] = va_arg!(wchar)(_ptr);
3514 return isNumeric(std.utf.toUTF8(ws)); 3514 return isNumeric(std.utf.toUTF8(ws));
3515 } 3515 }
3516 else if (_arguments[0] == typeid(dchar)) 3516 else if (_args[0] == typeid(dchar))
3517 { 3517 {
3518 ds.length = 1; 3518 ds.length = 1;
3519 ds[0] = va_arg!(dchar)(_argptr); 3519 ds[0] = va_arg!(dchar)(_ptr);
3520 return isNumeric(std.utf.toUTF8(ds)); 3520 return isNumeric(std.utf.toUTF8(ds));
3521 } 3521 }
3522 //else if (_arguments[0] == typeid(cent)) 3522 //else if (_args[0] == typeid(cent))
3523 // return true; 3523 // return true;
3524 //else if (_arguments[0] == typeid(ucent)) 3524 //else if (_args[0] == typeid(ucent))
3525 // return true; 3525 // return true;
3526 else 3526 else
3527 return false; 3527 return false;
3528 } 3528 }
3529 3529