Changeset 115 for trunk/Utilities/ShowHresult/NotifyIconWindow.h
- Timestamp:
- Sep 5, 2012, 3:23:55 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Utilities/ShowHresult/NotifyIconWindow.h
r108 r115 385 385 } 386 386 } 387 static BOOL IsDecimal(TCHAR nCharacter) throw() 388 { 389 return _tcschr(_T("0123456789"), nCharacter) != NULL; 390 } 391 static BOOL IsDecimal(const TCHAR* pszCharacters, SIZE_T nCount) throw() 392 { 393 for(SIZE_T nIndex = 0; nIndex < nCount; nIndex++) 394 if(!IsDecimal(pszCharacters[nIndex])) 395 return FALSE; 396 return TRUE; 397 } 398 static BOOL IsDecimal(const TCHAR* pszCharacters) throw() 399 { 400 return IsDecimal(pszCharacters, _tcslen(pszCharacters)); 401 } 402 static BOOL IsHexadecimal(TCHAR nCharacter) throw() 403 { 404 return _tcschr(_T("0123456789ABCDEFabcdef"), nCharacter) != NULL; 405 } 406 static BOOL IsHexadecimal(const TCHAR* pszCharacters, SIZE_T nCount) throw() 407 { 408 for(SIZE_T nIndex = 0; nIndex < nCount; nIndex++) 409 if(!IsHexadecimal(pszCharacters[nIndex])) 410 return FALSE; 411 return TRUE; 412 } 413 static BOOL IsHexadecimal(const TCHAR* pszCharacters) throw() 414 { 415 return IsHexadecimal(pszCharacters, _tcslen(pszCharacters)); 416 } 387 417 BOOL Process(LPCTSTR pszText) 388 418 { … … 392 422 CString sText = pszText; 393 423 sText.Trim(); 424 #pragma region Delete Trailing L (as in 0x00000000L) 394 425 if(!sText.IsEmpty() && _tcschr(_T("Ll"), sText[sText.GetLength() - 1])) 395 426 sText.Delete(sText.GetLength() - 1); 427 #pragma endregion 428 #pragma region Unquote Single Quote 429 if(sText.GetLength() > 2 && sText[0] == _T('\'') && sText[sText.GetLength() - 1] == _T('\'')) 430 { 431 sText = sText.Mid(1, sText.GetLength() - 2); 432 sText.Trim(); 433 } 434 #pragma endregion 396 435 if(sText.IsEmpty()) 397 436 return FALSE; 398 437 LONGLONG nLongLongResult; 438 #pragma region Hexadecimal 399 439 if(_tcsnicmp(sText, _T("0x"), 2) == 0) 400 440 { 401 SIZE_T nIndex = 2; 402 for(; nIndex < (SIZE_T) sText.GetLength(); nIndex++) 403 if(!_tcschr(_T("0123456789ABCDEFabcdef"), sText[nIndex])) 404 return FALSE; 441 if(!IsHexadecimal((LPCTSTR) sText + 2)) 442 return FALSE; 405 443 if(!StrToInt64Ex(sText, STIF_SUPPORT_HEX, &nLongLongResult)) 406 444 return FALSE; 407 445 } else 446 #pragma endregion 447 #pragma region Integer 408 448 { 409 449 SIZE_T nIndex = 0; 410 450 if(sText[0] == _T('-')) 411 451 nIndex++; 412 for(; nIndex < (SIZE_T) sText.GetLength(); nIndex++) 413 if(!_tcschr(_T("0123456789"), sText[nIndex])) 452 if(!IsDecimal((LPCTSTR) sText + nIndex)) 453 { 454 #pragma region Eight Characater Long Hexadecimal without Prefix 455 if(sText.GetLength() == nIndex + 8 && IsHexadecimal((LPCTSTR) sText + nIndex)) 456 { 457 sText.Insert(0, _T("0x")); 458 if(!StrToInt64Ex(sText, STIF_SUPPORT_HEX, &nLongLongResult)) 459 return FALSE; 460 } else 461 #pragma endregion 414 462 return FALSE; 415 nLongLongResult = _ttoi64(sText); 463 } else 464 nLongLongResult = _ttoi64(sText); 465 if(nIndex) 466 nLongLongResult = -nLongLongResult; 416 467 } 468 #pragma endregion 417 469 const LONG nHighLongLongResult = (LONG) (nLongLongResult >> 32); 418 470 if(!nLongLongResult || nHighLongLongResult > 0 || nHighLongLongResult < -1)
Note: See TracChangeset
for help on using the changeset viewer.