本文整理汇总了C++中TChar类的典型用法代码示例。如果您正苦于以下问题:C++ TChar类的具体用法?C++ TChar怎么用?C++ TChar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TChar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: __ASSERT_DEBUG
/**
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: LOGTEXT
void CATBase::ParseBufferLC()
//
// Parses buffer
//
/**
* This function is currently not used by the Etel regression test harness.
*/ {
LOGTEXT(_S8("CATBase Parse the Buffer List"));
iBuffer.Set(iIo->GetRxBufferLC(iBufferMarker));
TInt pos=iBuffer.FindF(KOKString);
if(pos==KErrNotFound)
{
LOGTEXT(_S8("CATBase Error - Cannot find OK'"));
User::Leave(pos);
}
// Place everything before the OK into buffer
iBuffer.Set(iBuffer.Left(pos));
TLex8 yyLex(iBuffer);
TChar peek;
// Look for '=' sign and move seeker cursor to the right of it if it exists
pos=iBuffer.Find(_L8("="));
if (pos!=KErrNotFound)
{
yyLex.Inc(pos+1);
}
// Move cursor past any spaces or open brackets
yyLex.SkipSpace();
peek=yyLex.Peek();
if ((TUint)peek=='(' || (TUint)peek=='[' || (TUint)peek=='{')
yyLex.Inc();
yyLex.SkipSpace();
peek = yyLex.Peek();
do
{
// Search for the next character that is not a comma, and mark it. Keep looking at
// subsequent characters until it is a space,comma,closing bracket or end of string.
// Store the string (between marked character and current character) as an item in
// an array of CATParamListEntry object pointers.
if (peek!=',')
{
yyLex.Mark();
do
{
yyLex.Inc();
peek=yyLex.Peek();
}
while (peek!=',' && !peek.IsSpace() && peek!=')'&& peek!=']'&& peek!='}' && !yyLex.Eos());
CATParamListEntry* aParamListEntry = new (ELeave) CATParamListEntry(yyLex.MarkedToken());
iRxResults.AddLast(*aParamListEntry);
}
// Move cursor to the next non-space character, and end the loop if it is a closing
// bracket or the end of the buffer.
yyLex.Inc();
yyLex.SkipSpace();
peek = yyLex.Peek();
}
while (!yyLex.Eos() && peek!=')'&& peek!=']'&& peek!='}');
}
示例4: Eat
TBool TfrLex::Eat( TLex& aLex, const TChar aChar )
{
TLexMark unget;
if ( aChar.IsSpace() )
{
// A space character requires its own logic = go over
// the other space characters - x gets the next char.
TChar x;
aLex.Mark(unget);
while ( x = aLex.Get(), x.IsSpace() && x != aChar )
{};
if ( x == aChar )
return ETrue;
}
else
{
// For other, non-space, characters: skip spaces and
// get the next character x.
aLex.SkipSpace();
aLex.Mark(unget);
if ( aLex.Get() == aChar )
return ETrue;
}
// The character wasn't there, unget to the start point.
aLex.UnGetToMark(unget);
return EFalse;
}
示例5: offset
TBool CTestConfig::IsAtStartOfNewLine(const TDesC8& aSource, const TLex8& aLex, TBool aIgnoreSpaces) const
{
TInt offset(aLex.MarkedOffset());
__ASSERT_ALWAYS(offset != 0, User::Invariant());
TChar ch = NULL;
if (aIgnoreSpaces)
{
while (offset--)
{
ch = aSource[offset];
if (ch == KScriptLFChar || ch == KScriptCRChar || !ch.IsSpace())
break;
}
}
else
ch = aSource[offset-1];
TBool ret(EFalse);
if (offset <= 0)
ret = ETrue;
else
ret = (ch == KScriptLFChar || ch == KScriptCRChar);
return ret;
}
示例6: OstTraceFunctionEntry0
// ---------------------------------------------------------------------------------
// CUpnpTmFilteredAppList::RemoveWhiteSpace
// Method is used to remove leading and trailing whitespaces from the descriptor's data
// @param aData Descriptor's data from which whitespaces have to be removed
// @return Returns the descriptor having no white spaces
// ---------------------------------------------------------------------------------
//
const TDesC8& CUpnpTmFilteredAppList::RemoveWhiteSpace( TPtrC8& aData )
{
OstTraceFunctionEntry0( CUPNPTMFILTEREDAPPLIST_REMOVEWHITESPACE_ENTRY );
// Removes the leading white spaces
TInt length = aData.Length();
TInt i = 0;
TBool done = EFalse;
while( !done && i < length )
{
TChar current = aData[i];
done = !current.IsSpace();
if( !done )
++i;
}
aData.Set(aData.Mid(i)); /* aData now does not have any white space character
ahead of its actual data */
// Removes the trailing white spaces
length = aData.Length();
i = 0;
done = EFalse;
while( !done && i < length )
{
TChar current = aData[(length-1) - i];
done = !current.IsSpace();
if( !done )
++i;
}
aData.Set(aData.Left(aData.Length() - i)); /* aData now does not have any white space character
following the actual data */
OstTraceFunctionExit0( CUPNPTMFILTEREDAPPLIST_REMOVEWHITESPACE_EXIT );
return aData;
}
示例7: VA_START
void CDTSYLogger::WriteFormat(TRefByValue<const TDesC8> aFmt,...)
{
TBuf8<KGenericBufferSize> buf;
VA_LIST list;
VA_START(list,aFmt);
buf.FormatList(aFmt,list);
TChar tmpchar;
for(TInt i=0;i<buf.Length();i++)
{
tmpchar=buf[i];
if(!((tmpchar.IsPrint()) || (tmpchar=='\n') || (tmpchar=='\r') || (tmpchar=='\t')))
buf[i]='.';
}
#ifdef __EXE__
CDTSYLogger* context=aScriptLoggerContext;
#else
CDTSYLogger* context=(CDTSYLogger*) Dll::Tls();
#endif
if(context==NULL)
{
TRAPD(ret,context=CDTSYLogger::NewL());
if (ret==KErrNone)
{
#ifdef __EXE__
aScriptLoggerContext=context;
#else
Dll::SetTls(context);
#endif
}
else return;
}
if(context->iValid)
context->WriteRecord(buf);
}
示例8:
/**
Strip out any non-digit characters before we convert the phone number to an
integer.
@param aText Phone number which on return will have any non-digit characters
removed.
*/
void CPplCommAddrTable::TMatch::StripOutNonDigitChars(TDes& aText)
{
for(TInt chrPos = 0; chrPos < aText.Length(); ++chrPos)
{
TChar chr = aText[chrPos];
if (!chr.IsDigit() )
{
aText.Delete(chrPos, 1);
--chrPos;
}
}
}
示例9: while
/**
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();
}
示例10: UpdateNextCharsL
// -----------------------------------------------------------------------------
// For Devanagari AS
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
inline void UpdateNextCharsL( HBufC*& aNextChars, const TDesC& aItemString )
{
TChar searchChar = aItemString[0];
//Check if this is an Indic special ligature
if ( IsIndicConsonant(searchChar) && aItemString.Length() > 2
&& IsSpecialIndicLigature(aItemString)
&& KErrNotFound == (*aNextChars).Find(aItemString.Mid(0,3)) )
{
//Check if we have enough space for 3 more characters
if( aNextChars->Des().Length() >= aNextChars->Des().MaxLength()-3 )
{
aNextChars = aNextChars->ReAllocL( aNextChars->Des().MaxLength()+10 );
}
aNextChars->Des().Append( aItemString.Mid(0,3) );
}
else
{
//check if this is an Indic combined Char
if ( IsIndicCombinedChar(searchChar) )
{
searchChar = RemoveIndicNukta( searchChar );
}
//Now update the nextChars string
TInt strLength = aNextChars->Length();
for ( TInt i(0); i < strLength ; ++i )
{
if ( IsSpecialIndicLigature( (*aNextChars).Mid( i ) ) )
{
//As aItemString is not a special ligature (checked above)
//we can move directly to the 3rd character from here
i+=2;
}
else if ( searchChar.GetUpperCase() == (*aNextChars)[i] ||
searchChar.GetLowerCase() == (*aNextChars)[i] )
{
//already exists - do nothing
return;
}
//else continue the loop
}
//So this character is not yet in the list of nextChars.
if ( aNextChars->Des().Length() == aNextChars->Des().MaxLength() )
{
aNextChars = aNextChars->ReAllocL( aNextChars->Des().MaxLength()+10 );
}
aNextChars->Des().Append( searchChar );
}
}
示例11: IsPrintable
// -----------------------------------------------------------------------------
// TSTSCharacterSetConverter::IsPrintable
// checks if the given character is allowed in PrintableString
// -----------------------------------------------------------------------------
//
TBool TSTSCharacterSetConverter::IsPrintable(
const TChar& aValue) const
{
if (aValue > 128) // non-ascii characters are not allowed
{
return EFalse;
}
if (aValue.IsAlphaDigit()) // A-Z,a-z,0-9 are allowed
{
return ETrue;
}
switch (aValue) // some other characters are also allowed
{
case(' '):
case('\''):
case('('):
case(')'):
case('+'):
case(','):
case('-'):
case('.'):
case('/'):
case(':'):
case('='):
case('?'):
{
return ETrue;
}
default:
{
return EFalse;
}
}
}
示例12: CharIsDtmf
TBool CATDtmfVts::CharIsDtmf(const TChar& aDtmfChar)
{
LOGTEXT(_L8("[Ltsy CallControl] Starting CATDtmfVts::IsDtmf()"));
TUint uC = aDtmfChar.GetUpperCase();
switch(uC)
{
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case 'A':
case 'B':
case 'C':
case 'D':
case '*':
case '#':
return ETrue;
}
return EFalse;
}
示例13: CheckOIDL
// -----------------------------------------------------------------------------
// CSTSCredentialManager::CheckOIDL
// Checks if given OID is formatted correctly
// -----------------------------------------------------------------------------
void CSTSCredentialManager::CheckOIDL(const TDesC& aOID)
{
TInt oidLength = aOID.Length();
if (oidLength == 0)
{
// empty oid is illegal
User::Leave(KErrArgument);
}
for (TInt i = 0; i < oidLength; i++)
{
TChar oidChar = aOID[ i ];
if (!oidChar.IsAlphaDigit())
{
if ((oidChar != KSTSDot) && (oidChar != KSTSLine))
{
User::Leave(KErrArgument);
}
}
}
}
示例14: ProcessKeyPressL
void CActiveConsole::ProcessKeyPressL(TChar aChar)
{
if (aChar == EKeyEscape)
{
PRINT(_L("CActiveConsole: ESC key pressed -> stopping active scheduler...\n"));
gAbort = ETrue;
CActiveScheduler::Stop();
return;
}
aChar.UpperCase();
GetCharacter();
}
示例15: Normalize
// -----------------------------------------------------------------------------
// TMSAudioDtmfTonePlayer::Normalize
// Lowers case for chars and if its '*','+', or 'w' sets it to asterisk
// char ('*').
// -----------------------------------------------------------------------------
//
void TMSAudioDtmfTonePlayer::Normalize(TChar& tone)
{
TRACE_PRN_FN_ENT;
tone.LowerCase();
TPtrC ast(KPhoneTone_Asterisk);
if (ast.Locate(tone) != KErrNotFound)
{
tone = ast[0];
}
TRACE_PRN_FN_EXT;
}