/* * Generates a hash value by reversing the matchLength least significant digits, * ignoring non-digits and zeroes at the end of the number. Returns error if no phone * digits are supplied. * \param phoneNumberString A descriptor containing a phone number. * \param matchLength The number of digits from the right of the phone number to use. * \param numPhoneDigits The number of digits found in the phone number string. * \param error Qt error code.* * \return An integer representation of the phone number string in reverse. */ TInt32 CntFilterDetail::TMatch::createHash( const TDesC& phoneNumberString, TInt matchLength, TInt& numPhoneDigits) { TInt phoneNumberLength = phoneNumberString.Length(); TInt startIndex = 0; if (phoneNumberLength > matchLength) { startIndex = phoneNumberLength - matchLength; } numPhoneDigits = 0; TUint reversedDigits = 0; TInt mult = 1; for (TInt chrIndex = startIndex; (numPhoneDigits < matchLength) && (chrIndex < phoneNumberLength); chrIndex++) { TChar chr = phoneNumberString[chrIndex]; if (chr.IsDigit()) { reversedDigits += (chr.GetNumericValue()) * mult; mult = mult * 10; ++numPhoneDigits; } } return reversedDigits ; }
/** Generates a hash value by reversing the aMatchLength least significant digits, ignoring non-digits and zeroes at the end of the number. Asserts if no phone digits are supplied. @param aPhoneNumberString A descriptor containing a phone number. @param aMatchLength The number of digits from the right of the phone number to use. @param aNumPhoneDigits The number of digits found in the phone number string. @return An integer representation of the phone number string in reverse. */ TInt32 CPplCommAddrTable::TMatch::CreateHashL(const TDesC& aPhoneNumberString, TInt aMatchLength, TInt& aNumPhoneDigits) { TInt phoneNumberLength = aPhoneNumberString.Length(); __ASSERT_DEBUG(phoneNumberLength > 0, User::Leave(KErrNotSupported) ); TInt startIndex = 0; if (phoneNumberLength > aMatchLength) { startIndex = phoneNumberLength - aMatchLength; } aNumPhoneDigits = 0; TUint reversedDigits = 0; TInt mult = 1; for (TInt chrIndex = startIndex; (aNumPhoneDigits < aMatchLength) && (chrIndex < phoneNumberLength); chrIndex++) { TChar chr = aPhoneNumberString[chrIndex]; if (chr.IsDigit() ) { reversedDigits += (chr.GetNumericValue() ) * mult; mult = mult * 10; ++aNumPhoneDigits; } } return reversedDigits ; }
TUint TInputManager::GetCipher(TChar aChar) { TUint value; switch(aChar) { case 'a': value = 10; break; case 'b': value = 11; break; case 'c': value = 12; break; case 'd': value = 13; break; case 'e': value = 14; break; case 'f': value = 15; break; default: value = aChar.GetNumericValue(); } return value; }
void CTestDtmfObserver::HandleDTMFEvent( const MCCEDtmfObserver::TCCEDtmfEvent aEvent, const TInt aError, const TChar aTone ) { TEvent newEvent; newEvent.iCallID = 0; // not a call specific event newEvent.iEventType = CEventStorage::EDtmfEvent; newEvent.iEventID = aEvent; newEvent.iParam1 = aError; newEvent.iParam2 = aTone.GetNumericValue(); // If TChar is empty, set param2 to zero if ( newEvent.iParam2 == KErrNotFound ) { newEvent.iParam2 = 0; } iEventStorage->StoreEvent( newEvent ); }
void CActiveConsole::ProcessKeyPressL(TChar aChar) { if (aChar == EKeyEscape) { PRINT(_L("CActiveConsole: ESC key pressed -> stopping active scheduler...\n")); CActiveScheduler::Stop(); return; } aChar.UpperCase(); if (iCmdGetValue != 0 && aChar == '\r') { if (iLastChar == 'K') { iValue *= iGetHexValue ? 0x400 : 1000; } if (iLastChar == 'M') { iValue *= iGetHexValue ? 0x10000 : 1000000; } PRINT1(_L("CActiveConsole: Value %d\n"),iValue); ProcessValue(); } if (iCmdGetValue != 0 ) { if (iGetHexValue) { if (aChar.IsDigit()) { iValue = iValue * 16 + aChar.GetNumericValue(); } else { if (aChar.IsHexDigit()) { iValue = iValue * 16 + (TUint)aChar - 'A' + 10; } else { if (aChar != 'K' && aChar != 'M') { PRINT(_L("Illegal hexadecimal character - Enter command\n")); iCmdGetValue = 0; } } } } else { if (aChar.IsDigit()) { iValue = iValue * 10 + aChar.GetNumericValue(); } else { if ((aChar == 'X') && (iLastChar == '0') && (iValue == 0)) iGetHexValue = ETrue; else { if (aChar != 'K' && aChar != 'M') { test.Printf(_L("Illegal decimal character - Enter command\n")); iCmdGetValue = 0; } } } } } else { switch (aChar) { case 'F' : TESTNEXT(_L("Flushing Cache")); test_KErrNone(DPTest::FlushCache()); ShowMemoryUse(); iPrompt = ETrue; break; case 'I' : CacheSize(0,0); ShowMemoryUse(); iPrompt = ETrue; break; case 'Q' : gQuiet = ETrue; iPrompt = ETrue; break; case 'V' : gQuiet = EFalse; iPrompt = ETrue; break; case '?' : ShowHelp(); break; case '=' : iCmdGetValue = iLastChar; iGetHexValue = EFalse; iValue = 0; break; default : if (aChar.IsDigit()) { if (iLastChar == 'R') { if (aChar.GetNumericValue() < (TInt)gNextChunk) { ReadChunk (&gChunk[aChar.GetNumericValue()]); } else { for (TUint i = 0; i < gNextChunk; i++) ReadChunk (&gChunk[i]); } iPrompt = ETrue; } if (iLastChar == 'W') { if (aChar.GetNumericValue() < (TInt)gNextChunk) { WriteChunk (&gChunk[aChar.GetNumericValue()]); } else { for (TUint i = 0; i < gNextChunk; i++) WriteChunk (&gChunk[i]); } iPrompt = ETrue; } if (iLastChar == 'M') { if (aChar.GetNumericValue() == 0) { iActions = (TUint16)(iPeriod < KFlushQuietLimit ? EFlushQuiet : EFlush); } else { iActions = (TUint16)(aChar.GetNumericValue() << 4); } iPrompt = ETrue; } } break; } } iLastChar = aChar; GetCharacter(); return; }