本文整理汇总了C++中TPtrC::LocateF方法的典型用法代码示例。如果您正苦于以下问题:C++ TPtrC::LocateF方法的具体用法?C++ TPtrC::LocateF怎么用?C++ TPtrC::LocateF使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPtrC
的用法示例。
在下文中一共展示了TPtrC::LocateF方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsAdaptiveFindMatchClassic
inline TBool IsAdaptiveFindMatchClassic( const TDesC& aItemString, const TDesC& aSearchText )
{
TPtrC itemptr = aItemString;
TPtrC searchptr = aSearchText;
TBool match = EFalse;
for(;;)
{
// Loop invariant: itemptr is next character from ' ' or '-'
// Loop invariant: seachptr is at beginning of searched item
TInt val = MyFindC(itemptr,searchptr);
if (val == 0)
{
match = ETrue;
break;
}
if (val != KErrNotFound && IsFindWordSeparator(itemptr[val-1]))
{
match = ETrue;
break;
}
// find the word separator characters from list item
TInt spacepos = itemptr.LocateF(TChar(' '));
TInt minuspos = itemptr.LocateF(TChar('-'));
TInt tabpos = itemptr.LocateF(TChar('\t'));
if (spacepos != KErrNotFound)
{
itemptr.Set(itemptr.Mid(spacepos+1));
}
else if (minuspos != KErrNotFound)
{
itemptr.Set(itemptr.Mid(minuspos+1));
}
else if (tabpos != KErrNotFound)
{
itemptr.Set(itemptr.Mid(tabpos+1));
}
else
{
match = EFalse;
break;
}
if (itemptr.Length() == 0)
{
match = EFalse;
break;
}
}
return match;
}
示例2: ExtractNextToken
TInt CSwisExpressionEnvironment::ExtractNextToken(TPtrC& aTokenString, TPtrC& aParseString)
{
TInt separatorPosition = aParseString.LocateF(',');
// Check that a separator was located within the parse string
if(separatorPosition == KErrNotFound || separatorPosition > aParseString.Length()-1)
{
return KErrNotFound;
}
// Set the extracted token string and remove the token from the parse string
aTokenString.Set(aParseString.Left(separatorPosition));
aParseString.Set(aParseString.Mid(separatorPosition+1));
return KErrNone;
}
示例3: SearchMailAddressL
/**
Search algorithm for searching e-mail addresses
@param aText Text that will be parsed
@return ETrue if any EMail items were found else returns EFalse
@leave KErrNone, if successful; otherwise one of the other system-wide error codes.
@panic ETulPanicDescriptorLength in debug build if item's position
and/or length is out of the document's range.
*/
TBool CTulAddressStringTokenizer::SearchMailAddressL( const TDesC& aText )
{
TInt searchStart = 0;
TInt searchResult = 0;
const TInt end = aText.Length(); // end of document
do
{
TPtrC segment = aText.Right( end - searchStart );
searchResult = segment.LocateF('@');
if (searchResult != KErrNotFound)
{ // @ found
// There should be valid characters (not a period) before and after the @ character
if ( searchResult == 0 // first char
|| (searchResult >= segment.Length() - 1) // last char
|| !(IsValidEmailChar(segment[searchResult - 1]))
|| !(IsValidEmailHostChar(segment[searchResult + 1]))
|| segment[searchResult - 1] == '.'
|| segment[searchResult + 1] == '.'
)
{
searchStart += searchResult + 1;
continue;
}
TBool wasPeriod = EFalse; // To prevent sequential periods
// Get TLex from the pointer to get a better API for parsing
TLexMark startPos;
TLexMark endPos;
TLex token = segment;
// Go to searchResult and un-get until the beginning of e-mail address is reached
token.Inc( searchResult );
token.Mark();
do
{
token.UnGet();
if ( token.Peek() == '.' )
{ // If it was a period
if (wasPeriod) // and if the former was also -> break
break;
else // else mark that this one was a period
wasPeriod = ETrue;
}
else
wasPeriod = EFalse;
}
while (token.Offset() > 0 && IsValidEmailChar(token.Peek()));
if (token.Offset() != 0 || !IsValidEmailChar(token.Peek()))
token.Inc();
// Get rid of periods from the start of address
// Does it have to start with a number or char(abc...).
// If it does, the loop should check that it gets rid of all special chars also.
while (token.Peek() == '.')
token.Inc();
token.Mark( startPos ); // Mark the beginning of address
token.UnGetToMark();
wasPeriod = EFalse;
do // Go forward until a nonvalid character
{
token.Inc();
if ( token.Peek() == '.' )
{ // If it was a period
if ( wasPeriod ) // and if the former was also -> break
break;
else // else mark that this one was a period
wasPeriod = ETrue;
}
else
wasPeriod = EFalse;
}
while ( !token.Eos() && IsValidEmailHostChar( token.Peek() ) );
// If address ends with a period take it away
token.UnGet();
if (token.Peek() != '.')
token.Inc();
token.Mark( endPos ); // Mark the beginning of address
// Append the found string to the array
__ASSERT_DEBUG( searchStart + token.MarkedOffset( startPos )
+ token.MarkedOffset( endPos )
- token.MarkedOffset( startPos ) <= aText.Length(),
Panic(ETulPanicDescriptorLength) );
AddItemL( searchStart + token.MarkedOffset( startPos ),
//.........这里部分代码省略.........