本文整理汇总了C++中TPtrC8::Match方法的典型用法代码示例。如果您正苦于以下问题:C++ TPtrC8::Match方法的具体用法?C++ TPtrC8::Match怎么用?C++ TPtrC8::Match使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPtrC8
的用法示例。
在下文中一共展示了TPtrC8::Match方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Match
TBool CExampleResolver::Match(const TDesC8& aImplementationType,
const TDesC8& aMatchType,
TBool aUseWildcards) const
{
TInt matchPos = KErrNotFound;
_LIT8(dataSeparator, "||");
const TInt separatorLength = dataSeparator().Length();
// Look for the section separator marker '||'
TInt separatorPos = aImplementationType.Find(dataSeparator);
if(separatorPos == KErrNotFound)
{
// Match against the whole string
if(aUseWildcards)
matchPos = aImplementationType.Match(aMatchType);
else
matchPos = aImplementationType.Compare(aMatchType);
}
else
{
// Find the first section, up to the separator
TPtrC8 dataSection = aImplementationType.Left(separatorPos);
TPtrC8 remainingData = aImplementationType.Mid(separatorPos + separatorLength);
// Match against each section in turn
while(separatorPos != KErrNotFound)
{
// Search this section
if(aUseWildcards)
matchPos = dataSection.Match(aMatchType);
else
matchPos = dataSection.Compare(aMatchType);
// If we found it then no need to continue, so return
if(matchPos != KErrNotFound)
return ETrue;
// Move on to the next section
separatorPos = remainingData.Find(dataSeparator);
if(separatorPos != KErrNotFound)
{
dataSection.Set(remainingData.Left(separatorPos));
remainingData.Set(remainingData.Mid(separatorPos + separatorLength));
}
else
dataSection.Set(remainingData);
}
// Check the final part
if(aUseWildcards)
matchPos = dataSection.Match(aMatchType);
else
matchPos = dataSection.Compare(aMatchType);
}
return matchPos != KErrNotFound;
}
示例2: ConstructL
/**
ConstructL()
Parses a .txt file and creates Arrays of fields and there values
@param aFileName
Name of the file to be parsed.
*/
EXPORT_C void CT_MsgUtilsConfigFileParserUtility::ConstructL(const TDesC& aFileName)
{
RFs fileServerSession;
fileServerSession.Connect();
RFile file;
User::LeaveIfError(file.Open(fileServerSession, aFileName, EFileRead));
TInt eof = EFalse;
TInt fileOffset = 0;
TBuf8<KFileBufferSize> fileBuffer;
while (!eof)
{
fileBuffer.SetLength(0);
User::LeaveIfError(file.Read(fileOffset, fileBuffer, KFileBufferSize));
TInt read = fileBuffer.Length();
if (read < KFileBufferSize)
{
fileBuffer.Append('\n');
eof = ETrue;
}
TInt lineOverflow = fileBuffer.Locate('\n');
if ((lineOverflow == KErrNotFound) && (read == KFileBufferSize))
{
User::Leave(KErrOverflow);
}
TInt eol = EFalse;
while (!eol)
{
TInt lineFeedLocation = fileBuffer.Locate('\n');
if (lineFeedLocation == KErrNotFound)
{
eol = ETrue;
}
else
{
fileOffset += lineFeedLocation + 1;
TInt lineLength;
if ((lineFeedLocation != 0) && (fileBuffer[lineFeedLocation - 1] == '\r'))
{
lineLength = lineFeedLocation - 1;
}
else
{
lineLength = lineFeedLocation;
}
TPtrC8 line = fileBuffer.Left(lineLength);
TInt commentLocation = line.Match(KComment);
if (commentLocation != KErrNotFound)
{
TPtrC8 skipComment = line.Left(commentLocation);
line.Set(skipComment);
}
TInt seperatorLocation = line.Locate('=');
if (seperatorLocation != KErrNotFound)
{
if ((seperatorLocation == 0) || (seperatorLocation == line.Length() - 1))
{
seperatorLocation = KErrNotFound;
}
}
if (seperatorLocation != KErrNotFound)
{
TPtrC8 namePtr = line.Left(seperatorLocation);
HBufC8* nameBuf8 = HBufC8::NewL(namePtr.Length());
CleanupStack::PushL(nameBuf8);
TPtr8 name8 = nameBuf8->Des();
name8.Copy(namePtr);
name8.Trim();
HBufC* nameBuf16 = HBufC::NewL(namePtr.Length());
TPtr name16 = nameBuf16->Des();
name16.Copy(name8);
iName.Append(nameBuf16);
CleanupStack::PopAndDestroy(nameBuf8);
TPtrC8 contentPtr = line.Mid(seperatorLocation + 1);
HBufC8* contentBuf8 = HBufC8::NewL(contentPtr.Length());
//.........这里部分代码省略.........