本文整理汇总了C++中TPtr8::Right方法的典型用法代码示例。如果您正苦于以下问题:C++ TPtr8::Right方法的具体用法?C++ TPtr8::Right怎么用?C++ TPtr8::Right使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPtr8
的用法示例。
在下文中一共展示了TPtr8::Right方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: KTestMessageOneParamExpected
TInt CFloggerTest028_Sync_Static_Multiple2::DoTestCheckWriteL()
{
RFile logFile;
HBufC8* hBuffer;
TInt listfilesize,returnCode;
RFs fileSystem; //For file operation create a file system
TInt numSuccessful = 0;
User::LeaveIfError(fileSystem.Connect());
//Open the file in the read mode
User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
CleanupClosePushL(logFile);
User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
CleanupStack::PushL(hBuffer);
TPtr8 ptrString = hBuffer->Des(); //To access the buffer
// Read from position 0: start of file
User::LeaveIfError(returnCode = logFile.Read(ptrString));
// the test case writes 5 elements 100 times, but we only check these things:
// 1. that the long test message with one parameter is written 100 times
// 2. that the test message with one param is written 100 times
// 3. that the end of test message has been written
TPtrC8 ptrStringOffsetForSearching;
returnCode = ptrString.Find(KTestMessageOneParamExpected);
if (returnCode > 0)
{
numSuccessful++;
}
TInt newLength; // allow length to be watched during debugging
TInt loop;
ptrStringOffsetForSearching.Set(ptrString.Right((ptrString.Length()-returnCode)-KTestMessageOneParamExpected().Length()));
for (loop=0; loop < KMultipleWriteStressTimes; loop++)
{
returnCode = ptrStringOffsetForSearching.Find(KTestMessageOneParamExpected); //find the next occurance
if (returnCode > 0)
{
numSuccessful++;
}
newLength = ptrStringOffsetForSearching.Length() - returnCode - KTestMessageOneParamExpected().Length();
if (newLength < 0)
{
User::Leave(KErrUnknown);
}
ptrStringOffsetForSearching.Set(ptrStringOffsetForSearching.Right(newLength));
}
returnCode = ptrString.Find(KTestTooLongMessageOneParamExpected);
if (returnCode > 0)
{
numSuccessful++;
}
newLength = ptrString.Length()-returnCode-KTestTooLongMessageOneParamExpected().Length();
ptrStringOffsetForSearching.Set(ptrString.Right(newLength));
for (loop=0; loop < KMultipleWriteStressTimes; loop++)
{
returnCode = ptrStringOffsetForSearching.Find(KTestTooLongMessageOneParamExpected); //find the next occurance
if (returnCode > 0)
{
numSuccessful++;
}
if (loop < (KMultipleWriteStressTimes - 1))
{
newLength = ptrStringOffsetForSearching.Length() - returnCode - KTestTooLongMessageOneParamExpected().Length();
if (newLength < 0)
{
User::Leave(KErrUnknown);
}
ptrStringOffsetForSearching.Set(ptrStringOffsetForSearching.Right(newLength));
}
}
returnCode = ptrString.Find(KTestEndMessage8);
if (returnCode > 0)
{
numSuccessful++;
}
CleanupStack::PopAndDestroy(hBuffer);
CleanupStack::PopAndDestroy(); //logFile
//.........这里部分代码省略.........
示例2:
TInt CFloggerTest028_Sync_ConMultiple::DoTestCheckWriteL()
{
RFile logFile;
HBufC8* hBuffer;
TInt listfilesize,returnCode;
RFs fileSystem; //For file operation create a file system
TInt numSuccessful = 0;
User::LeaveIfError(fileSystem.Connect());
//Open the file in the read mode
User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
CleanupClosePushL(logFile);
User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
CleanupStack::PushL(hBuffer);
TPtr8 ptrString = hBuffer->Des(); //To access the buffer
// Read from position 0: start of file
User::LeaveIfError(returnCode = logFile.Read(ptrString));
returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
//from the file
if (returnCode > 0)
{
numSuccessful++;
}
returnCode = ptrString.Find(KTestMessageOneParamExpected);
if (returnCode > 0)
{
numSuccessful++;
}
TPtrC8 ptrStringOffsetForSearching = ptrString.Right((ptrString.Length()-returnCode)-KTestMessageOneParamExpected().Length());
returnCode = ptrStringOffsetForSearching.Find(KTestMessageOneParamExpected); //find the next occurance
if (returnCode > 0)
{
numSuccessful++;
}
returnCode = ptrString.Find(KTestTooLongExpectedMessage);
if (returnCode > 0)
{
numSuccessful++;
}
returnCode = ptrString.Find(KTestTooLongMessageOneParamExpected);
if (returnCode > 0)
{
numSuccessful++;
}
// we don't check that all the binary data is there - just that the file is nice and long
if ( listfilesize > K1KilobyteOfDataSize)
{
numSuccessful++;
}
CleanupStack::PopAndDestroy(hBuffer);
CleanupStack::PopAndDestroy(); //logFile
if ( numSuccessful == 6 )
return KErrNone;
else
return KErrUnknown;
}