本文整理汇总了C++中TChar::IsDigit方法的典型用法代码示例。如果您正苦于以下问题:C++ TChar::IsDigit方法的具体用法?C++ TChar::IsDigit怎么用?C++ TChar::IsDigit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TChar
的用法示例。
在下文中一共展示了TChar::IsDigit方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/*
* 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 ;
}
示例2:
/**
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 ;
}
示例3: IsTokenChar
// -----------------------------------------------------------------------------
// SdpUtil::IsTokenChar
// Checks if the character is a valid token character
// -----------------------------------------------------------------------------
//
TBool SdpUtil::IsTokenChar(
TChar aChar )
{
return ( ( aChar == '!')||
( aChar >= '#' && aChar <= '\'' ) ||
( aChar == '*' || aChar == '+' ) ||
( aChar == '-' || aChar == '.' ) ||
( aChar.IsDigit() ) ||
( aChar >= 'a' && aChar <= 'z' ) ||
( aChar >= 'A' && aChar <= 'Z' ) ||
( aChar >= '^' && aChar <= '~' ) );
}
示例4: SetFromStringL
/**
Initialize the counter with the numeric equivalent of the descriptor contents
This function is here to demonstrate reading from the client address space.
Note that in this example, the client and the server are part of the same process,
*/
void CCountServSession::SetFromStringL(const RMessage2& aMessage)
{
// length of passed descriptor (1st parameter passed from client)
TInt deslen = aMessage.GetDesLength(0);
// Passed data will be saved in this descriptor.
RBuf buffer;
// Max length set to the value of "deslen", but current length is zero
buffer.CreateL(deslen);
// Do the right cleanup if anything subsequently goes wrong
buffer.CleanupClosePushL();
// Copy the client's descriptor data into our buffer.
aMessage.ReadL(0,buffer,0);
// Now do a validation to make sure that the string only has digits
if (buffer.Length() == 0)
{
User::Leave(ENonNumericString);
}
TLex16 lexer;
lexer.Assign(buffer);
while (!lexer.Eos())
{
TChar thechar;
thechar = lexer.Peek();
if (!thechar.IsDigit())
{
User::Leave(ENonNumericString);
}
lexer.Inc();
}
// Convert to a simple TInt value.
lexer.Assign(buffer);
if (lexer.Val(iCount))
{
User::Leave(ENonNumericString);
}
// Clean up the memory acquired by the RBuf variable "buffer"
CleanupStack::PopAndDestroy();
}
示例5: ParseErrorCode
// ---------------------------------------------------------------------------
// CMceIceErrorTrigger::ParseErrorCode
// ---------------------------------------------------------------------------
//
TInt CMceIceErrorTrigger::ParseErrorCode() const
{
TInt errorCode( 0 );
TLex8 lex( Value() );
TChar ch = lex.Peek();
while ( !ch.IsDigit() && ch != '-' && !ch.Eos() )
{
lex.Get();
ch = lex.Peek();
}
if ( ch.Eos() )
{
errorCode = KErrNotFound;
}
else
{
lex.Val( errorCode );
}
RDebug::Print( _L("ICEPlugin Dummy: ParseErrorCode=%d" ), errorCode );
return errorCode;
}
示例6: ProcessBufferL
//.........这里部分代码省略.........
}
else
{
BufferAppendL(byte);
}
}
else
{
// Add to buffer
BufferAppendL(byte);
}
}
break;
case EIOStateWaitLF:
// After LF, this is end of line, finish!
if (byte=='\n')
{
// Remove everything from the buffer, we've finished
iReceive.Delete(0,pos+1);
// Reset bytes read count & complete
iBytesRead=0;
// Complete with KErrFoundEOL
DBG((LogText(_L8("CImapIO::ProcessBuffer: Complete in EIOStateWaitLF"))));
Complete(KErrFoundEOL);
return;
}
break;
case EIOStateLiteralLength:
// Digit?
if (byte.IsDigit())
{
// Add it to the total
iLiteralLength=(iLiteralLength*10)+(byte-(TChar)'0');
if (iLiteralLength <0)
User::Leave(KErrCorrupt);
}
else if (byte=='}')
{
// Need to skip CR, LF
iLiteralSkip=2;
iParserState=EIOStateLiteralSkip;
// Add the atom (with the length we know, but no data) to the
// structure now, so that the partial structure can be parsed.
iAtomStart=iBuffer->Length();
AddAtomL(iLiteralLength);
}
break;
case EIOStateLiteralSkip:
// Skipping...
if (--iLiteralSkip==0)
{
// Is literal 0 bytes long?
if (iLiteralLength==0)
{
// Nothing to follow
iParserState=EIOStateAtomWait;
}
else
{
// Non-empty literal: go into fetch state
示例7: ExtractRawNumber
/**
* Extracts the real phone number from a contacts phone number field.
* This method strips away any DTMF strings or extended services. An empty
* descriptor is returned in aRawNumber if the field doesn't have a valid phone
* number.
*
* @param aTextualNumber Descriptor containing a contacts model phone number field
* @param aRawNumber Descriptor to write the raw number to (loaned by caller)
*/
void CContactDefaultPhoneNumberParser::ExtractRawNumber(const TDesC& aTextualNumber, TDes& aRawNumber)
{
aRawNumber.Zero();
TInt length = aTextualNumber.Length();
if (length==0)
{
return;
}
TPtrC numberPtr( aTextualNumber );
TUint firstChar = numberPtr[0];
//gobble spaces
while (TChar(firstChar).IsSpace())
{
--length;
if (length==0)
{
return;
}
numberPtr.Set(numberPtr.Right(length));
firstChar = numberPtr[0];
}
// Get left hand side
if ( firstChar == KSymbolAsterisk || firstChar == KSymbolHash )
{
//Check if there is plus on first five chars:
TInt newStartPlace = numberPtr.Locate( KSymbolPlus );
if ( newStartPlace>=KPlusWithinChars || newStartPlace==KErrNotFound )
{
// There is always star or hash...
newStartPlace = Max( numberPtr.LocateReverse(KSymbolAsterisk ) ,numberPtr.LocateReverse( KSymbolHash) );
}
length = length - newStartPlace -1;
if ( length <= 0 )
{
return;
}
numberPtr.Set( numberPtr.Right( length ) );
firstChar = numberPtr[0];
}
//test condition to satisfy the removal of '(' the next if
//statement removes the '+' if needed
if ( firstChar == KSymbolOpenBrace )
{
length--;
numberPtr.Set( numberPtr.Right( length ) );
// This may be the only character in the descriptor so only access if
// 1 or more characters left.
if (length > 0 )
{
firstChar = numberPtr[0];
}
}
if ( firstChar == KSymbolPlus )
{
length--;
numberPtr.Set( numberPtr.Right( length ) );
}
if (length==0)
{
return;
}
// Find right hand side
TLex numberLexer( numberPtr );
for ( ; ; )
{
TChar nextChar = numberLexer.Peek();
if ( !nextChar )
{
break;
}
if ( nextChar.IsDigit() )
{
aRawNumber.Append( nextChar );
numberLexer.Inc();
}
else if ( nextChar == KSymbolAsterisk || nextChar == KSymbolHash )
{
aRawNumber.Zero();
return;
//.........这里部分代码省略.........
示例8: ProcessKeyPressL
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;
//.........这里部分代码省略.........
示例9: ParseL
EXPORT_C CSTBencode* CSTBencode::ParseL(const TDesC8& aBuffer)
{
TBencodeParserState parserState = EParsingInProgress;
TLex8 lex(aBuffer);
TChar c;
TBool itemParsed = EFalse; // state flag, used to indicate that a bencoded
// item has been parsed
//TBool keyOnStack = EFalse; // used to indicate that there is a dictionary entry key on the stack
CSTSimpleStack<CSTBencode>* parserStack =
new (ELeave) CSTSimpleStack<CSTBencode>;
CleanupStack::PushL(parserStack);
while ( (c = lex.Peek()) &&
(parserState == EParsingInProgress))
{
// bencoded string
if (c.IsDigit())
{
TInt stringLength = 0;
if ((lex.Val(stringLength) == KErrNone) && (stringLength >= 0))
{
while (c && (c != ':'))
c = lex.Get();
if (!c || ((lex.Offset() + stringLength) > aBuffer.Length()))
{
parserState = EParsingFailed;
continue;
}
lex.Mark();
lex.Inc(stringLength);
CSTBencodedString* string = CSTBencodedString::NewLC(lex.MarkedToken());
parserStack->PushL(string);
CleanupStack::Pop();
c = lex.Peek();
itemParsed = ETrue;
}
else
{
parserState = EParsingFailed;
continue;
}
}
else
// bencoded integer
if (c == 'i')
{
lex.Inc();
TInt64 value = 0;
if (lex.Val(value) == KErrNone)
{
c = lex.Peek();
while (c && (c != 'e'))
{
lex.Inc();
c = lex.Peek();
}
if (c == 'e')
{
CSTBencodedInteger* bencodedInteger =
new (ELeave) CSTBencodedInteger(value);
CleanupStack::PushL(bencodedInteger);
parserStack->PushL(bencodedInteger);
CleanupStack::Pop(); // bencodedInteger
}
}
else
{
parserState = EParsingFailed;
continue;
}
}
else
// bencoded list
if (c == 'l')
{
lex.Inc();
CSTBencodedList* bencodedList =
new (ELeave) CSTBencodedList;
CleanupStack::PushL(bencodedList);
parserStack->PushL(bencodedList);
CleanupStack::Pop(); // bencodedList
}
else
//.........这里部分代码省略.........