本文整理汇总了C++中TPtrC8::LocateReverse方法的典型用法代码示例。如果您正苦于以下问题:C++ TPtrC8::LocateReverse方法的具体用法?C++ TPtrC8::LocateReverse怎么用?C++ TPtrC8::LocateReverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPtrC8
的用法示例。
在下文中一共展示了TPtrC8::LocateReverse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadNewVersionFileL
TInt CVersionFileReader::ReadNewVersionFileL(const TDesC& versionFile)
{
iNewVersionArray->Reset();
class RFs& fs = CCoeEnv::Static()->FsSession();
class RFile file;
TInt ret = file.Open(fs, versionFile,
EFileStreamText | EFileRead);
if(ret != KErrNone) {
/* Could not open file, return the error code */
return ret;
}
HBufC8* line = HBufC8::NewLC(40);
TInt pos = -1;
file.Seek(ESeekStart, pos);
TPtr8 pLine = line->Des();
ret = file.Read(pLine);
if(line->Length() == 0) {
// Empty file
file.Close();
return KErrEof;
}
file.Close();
// The file contains a string that should match this regex:
// [0-9]+\.[0-9]+\.[0-9]\+:[0-9]+\.[0-9]+\.[0-9]\+:[0-9]\+
// The string is separated into three parts by ':'.
// The first part is the application version
// The second part is the resource version
// The third part is the mlfw version.
const TChar colon = ':';
const TChar dot = '.';
while(line->Length() > 0) {
if(line->Locate(colon) != KErrNotFound) {
TPtrC8 part = line->Left(line->Locate(colon));
TPtrC8 version = part.Left(part.LocateReverse(dot));
TPtrC8 misc = part.Right(part.Length() - part.LocateReverse(dot) - 1);
iNewVersionArray->AppendL(part);
iNewVersionArray->AppendL(version);
iNewVersionArray->AppendL(misc);
line->Des().CopyF(line->Right(line->Length() - line->Locate(colon) - 1));
} else {
iNewVersionArray->AppendL(*line);
break;
}
}
CleanupStack::PopAndDestroy(line);
return 0;
}