本文整理汇总了C++中TBuf::AppendFormat方法的典型用法代码示例。如果您正苦于以下问题:C++ TBuf::AppendFormat方法的具体用法?C++ TBuf::AppendFormat怎么用?C++ TBuf::AppendFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TBuf
的用法示例。
在下文中一共展示了TBuf::AppendFormat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetTestSecurityInfoL
void CPolicyTest::SetTestSecurityInfoL(TInt aSecureId, TInt aVendorId, TUint aCapSet, TRequestStatus& aStatus)
{
// Remove excluded capabilities
for (TInt i = 0 ; i < ECapability_Limit ; ++i)
{
if (iExcludedCaps.HasCapability(static_cast<TCapability>(i)))
{
aCapSet &= ~ (1 << i);
}
}
TBuf<128> commandLine;
commandLine.AppendFormat(_L("%S %08x "), iTestExe, aCapSet);
if (aSecureId)
{
commandLine.AppendFormat(_L("-SID %08x "), aSecureId);
}
if (aVendorId)
{
commandLine.AppendFormat(_L("-VID %08x "), aVendorId);
}
// commandLine.Append(KTestExeTmpPath);
iTestExeTmpNewPath = KTestPath;
iTestExeTmpNewPath.Append(*iTestExe);
commandLine.Append(iTestExeTmpNewPath);
TBuf<128> isetcapTmpNewPath1; //stores the value of commandline
TBuf<128> isetcapTmpNewPath; //stores the value of KsetCapexe2
isetcapTmpNewPath = KSetCapExe2;
isetcapTmpNewPath1= commandLine;
isetcapTmpNewPath.Append(isetcapTmpNewPath1);
RDebug::RawPrint(isetcapTmpNewPath);
StartProcessL(KSetCapExe, commandLine, aStatus);
}
示例2: ConstructL
void CMemSpyEngineActiveObject::ConstructL( CMemSpyEngine& /*aEngine*/ )
{
TBuf<256> item;
_LIT(KBasicFormat, "\t0x%08x\t\t");
item.Format( KBasicFormat, VTable() );
// Add modifiers
_LIT( KModifiers, "%d" );
_LIT( KBoxedCharFormat, " [%c]" );
item.AppendFormat( KModifiers, RequestStatusValue() );
if ( IsActive() )
{
item.AppendFormat( KBoxedCharFormat, 'A' );
}
if ( RequestIsPending() )
{
item.AppendFormat( KBoxedCharFormat, 'P' );
}
iCaption = item.AllocL();
// Listbox items
TPtrC value;
// Address
_LIT(KCaption1, "\tAddress\t\t0x%08x");
item.Format( KCaption1, iAddress );
AppendL( item );
// vTable
_LIT(KCaption2, "\tVTable\t\t0x%08x");
item.Format( KCaption2, iVTable );
AppendL( item );
//
_LIT(KCaption3, "\tStatus Value\t\t%d");
item.Format( KCaption3, iRequestStatusValue );
AppendL( item );
//
_LIT(KCaption5, "\tIs Active\t\t%S");
value.Set( YesNoValue( IsActive() ) );
item.Format( KCaption5, &value );
AppendL( item );
//
_LIT(KCaption6, "\tRequest Pending\t\t%S");
value.Set( YesNoValue( RequestIsPending() ) );
item.Format( KCaption6, &value );
AppendL( item );
//
_LIT(KCaption4, "\tPriority\t\t%d");
item.Format( KCaption4, iPriority );
AppendL( item );
}
示例3: LogTestStepTime
// Write and print the time result
TInt CTimerLogger::LogTestStepTime(TUint aOp, TInt aNum)
{
if (iTiming)
return KErrGeneral;
TBuf<100> buf;
switch (aOp)
{
case EOpCreate:
buf.Append(_L("Create - "));
break;
case EOpReplace:
buf.Append(_L("Replace - "));
break;
case EOpChgAttr:
buf.Append(_L("Change Attribute - "));
break;
case EOpRename:
buf.Append(_L("Rename - "));
break;
case EOpWrite:
buf.Append(_L("Write - "));
break;
case EOpResize:
buf.Append(_L("Resize - "));
break;
case EOpDelete:
buf.Append(_L("Delete - "));
break;
case EOpManyChanges:
buf.AppendFormat(_L("%d Changes on Single File - "), aNum);
break;
case EOpManyFiles:
buf.AppendFormat(_L("Small Changes on %d Files - "), aNum);
break;
case EOpCreateDir:
buf.Append(_L("Create(dir) - "));
break;
case EOpRenameDir:
buf.Append(_L("Rename(dir) - "));
break;
case EOpDeleteDir:
buf.Append(_L("Delete(dir) - "));
break;
case EOpMixed:
buf.AppendFormat(_L("%d Mixed Operations - "), aNum*18);
default:
break;
}
TReal time = (static_cast<TReal>(iTickNumber) * iTickPeriod) / iTimeScale;
buf.AppendFormat(_L("time: %d ms"), static_cast<TInt>(time));
return LogAndPrint(buf);
}
示例4: CompareArrays
//#pragma warning( disable : 4701 ) //local variable 'docPosError' may be used without having been initialized
TBool CLinePaginatorTest::CompareArrays()
{
TInt numPages=iCharsPerPage->Count();
TInt numTestPages=iTestChars->Count();
TInt numChars;
TInt numTestChars;
TBool pagesSame=EFalse;
TBuf8<128> text;
TInt prevDocPos=0;
TInt docPosError=0;
TBuf<256> buf;
if (numPages==numTestPages)
{
buf.AppendFormat(_L("Correct Number of Pages = %d\n"), numPages);
TESTPRINT(buf);
pagesSame=ETrue;
for (TInt i=0; i<numPages; i++)
{
numChars=(*iCharsPerPage)[i];
numTestChars=(*iTestChars)[i]-prevDocPos;
if(numChars!=numTestChars)
{
if (pagesSame)
docPosError=(*iTestChars)[i];
pagesSame=EFalse;
}
prevDocPos=(*iTestChars)[i];
}
if (pagesSame)
{
TESTPRINT(_L("Correct Number of Characters on Pages -- PASSED\n"));
}
else
{
TESTPRINT(_L("Incorrect Number of Characters on Pages -- FAILED\n"));
buf.Zero();
buf.AppendFormat(_L("First Error Occurs at Position = %d"), docPosError);
TESTPRINT(buf);
}
}
else
{
TESTPRINT(_L("Incorrect Number of Pages -- FAILED\n"));
buf.Zero();
buf.AppendFormat(_L("Number Calculated by LinePaginator = %d\n"), numPages);
buf.AppendFormat(_L("Number Contained in File = %d\n"), numTestPages);
TESTPRINT(buf);
}
iTestFile.Close();
return pagesSame;
}
示例5: WriteFileDataL
EXPORT_C void CMsvTestUtils::WriteFileDataL(TMsvId aId, const TFileName& aFileName, const TFileName& aLogFilepath, TBool aReplace)
{
TParse dirPath;
RFile attach;
dirPath.Set(aFileName, NULL, NULL);
TInt err = KErrNone;
if (attach.Open(iFs, dirPath.FullName(), KEntryAttNormal) != KErrNone)
return; // failed to find attachment
TFileName filename(aLogFilepath);
filename.Append(KFileNameFiles);
RFile file;
if (aReplace)
err = file.Replace(iFs, filename, EFileShareAny | EFileStreamText | EFileWrite);
else
err = file.Open(iFs, filename, EFileShareAny | EFileStreamText | EFileWrite);
if(err==KErrNotFound) // file does not exist - create it
err=file.Create(iFs, filename, EFileShareAny | EFileStreamText | EFileWrite);
TInt offset=0;
__ASSERT_ALWAYS(file.Seek(ESeekEnd, offset)==KErrNone, Panic(KErrGeneral));
TBuf<100> buf;
buf.Zero();
buf.AppendFormat(_L("\n*** %d *************** File Data ***************\n"), aId);
buf.AppendFormat(_L("Filename >>> "));
WriteToFileL(file, buf);
WriteToFileL(file, dirPath.NameAndExt());
WriteToFileL(file,_L("\n"));
HBufC8* buffer8 = HBufC8::NewLC(1024);
TPtr8 buf8 = buffer8->Des();
do {
attach.Read(buf8);
WriteToFileL(file, buf8);
} while (buf8.Length());
buf.Zero();
buf.AppendFormat(_L("\n********************* end of File ***********************\n"));
WriteToFileL(file, buf);
CleanupStack::PopAndDestroy(); // buffer8
attach.Close();
file.Close();
}
示例6: LogWriteNum
// ---------------------------------------------------------------------------
// Writes number to log.
// ---------------------------------------------------------------------------
//
void CKmdDebugLogger::LogWriteNum( TUint aNum )
{
const TInt KMaxNumLength( 20 );
TBuf<KMaxNumLength> buf;
buf.AppendFormat( _L("%u\n"), aNum ); // key Data byte2byte
LogWrite( buf );
}
示例7: TestStepResult
TVerdict CUloggerServerTest2Step::doTestStepL()
{
if (TestStepResult()==EPass)
{
TInt errors = 0;
errors += Test1L();//CULoggerSession::NewL
errors += Test2L();//CULoggerSession::NewLC
/*
* Method CULoggerSession::ServiceL cannot be tested here because it require
* of passing RMessage2 reference with valid RMessagePtr (IPC)
* If we are going to pass empty RMessage2 system will panic our process with
* User Panic 70.
* */
//display results
TBuf<128> res;
res.AppendFormat(_L("%d errors"), errors);
INFO_PRINTF1(_L("****Results****"));
INFO_PRINTF1(res);
if(errors == 0)
SetTestStepResult(EPass);
else
SetTestStepResult(EFail);
}
return TestStepResult();
}
示例8: WriteOutputFile
void CLinePaginatorTest::WriteOutputFile(TPageLine aLine)
{
TBuf<256> buf;
if (iTestPageBreak)
{
buf.AppendFormat(_L("%d\t%d\t%d\t%d\tBREAK\n"), aLine.iDocPos, aLine.iLineHeight, aLine.iKeepWithNext, aLine.iStartNewPage);
TESTPRINT(buf);
}
else
{
buf.Zero();
buf.AppendFormat(_L("%d\t%d\t%d\t%d\n"), aLine.iDocPos, aLine.iLineHeight, aLine.iKeepWithNext, aLine.iStartNewPage);
TESTPRINT(buf);
}
}
示例9: PrintHex
EXPORT_C void CTestUtils::PrintHex(const TDesC8& aDes)
{
TBuf<256> temp;
TInt pos = 0;
const TInt len = aDes.Length();
while (pos < len)
{
temp.Zero();
TPtrC8 ptr = aDes.Mid(pos, Min(KNumberOfHex, len - pos));
const TInt ptrLen = ptr.Length();
for (TInt i = 0; i < ptrLen; i++)
{
temp.AppendFormat(_L("%2.2x "), ptr[i]);
}
if (ptrLen < KNumberOfHex)
{
temp.AppendFill(' ', (KNumberOfHex - ptrLen) * 3);
}
TBuf<KNumberOfHex> buf16;
buf16.Copy(ptr);
temp.Append(buf16);
Printf(temp);
pos += KNumberOfHex;
}
}
示例10: PrintAuthPolicyL
static void PrintAuthPolicyL(CPrinter* aPrinter, TAuthorisationPolicy aAuthPolicy)
/**
Prints the authorisation policy.
@param aPrinter The printer object.
@param aAuthPolicy The authorisation policy.
*/
{
TBuf<80> buf;
TPtrC authPol;
switch (aAuthPolicy)
{
case EAlwaysCheck:
authPol.Set(_L("EAlwaysCheck"));
break;
case ECheckPostManufacture:
authPol.Set(_L("ECheckPostManufacture"));
break;
case ECheckUnprotectedSids:
authPol.Set(_L("ECheckUnprotectedSids"));
break;
case ECheckIfFailed:
authPol.Set(_L("ECheckIfFailed"));
break;
case ENeverCheck:
authPol.Set(_L("ENeverCheck"));
break;
default:
authPol.Set(_L("*** UNKNOWN ***"));
break;
}
buf.AppendFormat(_L(" Authorisation Policy: %S\n"), &authPol);
aPrinter->PrintL(buf);
}
示例11: RunTestL
void CPolicyTest::RunTestL(TRequestStatus& aStatus)
{
HBufC* hptr16;
hptr16 = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*iNameInfo);
RDebug::Print(KFormat,hptr16);
delete hptr16;
TDriveUnit sysDrive (RFs::GetSystemDrive());
TDriveName sysDriveName (sysDrive.Name());
TBuf<128> passScriptFile (sysDriveName);
passScriptFile.Append(KPassScriptPath);
TBuf<128> failScriptFile (sysDriveName);
failScriptFile.Append(KFailScriptPath);
TPtrC script = (iTestState == ETestPass) ? passScriptFile : failScriptFile;
(iTestState == ETestPass) ? RDebug::RawPrint(KPassTestRunning) : RDebug::RawPrint(KFailTestRunning);
TBuf<128> logTmpFile (sysDriveName);
logTmpFile.Append(KLogTmpPath);
iFs.Delete(logTmpFile); // ignore errors
TBuf<128> commandLine;
commandLine.AppendFormat(_L("%S %S"), &script, &logTmpFile);
StartProcessL(iTestExeTmpNewPath, commandLine, aStatus);
}
示例12: PrintSystemServerSecurity
void PrintSystemServerSecurity(CPrinter* aPrinter, CPolicy *aPolicy)
/**
Prints the system server security configuration.
*/
{
TPtrC p;
switch (aPolicy->SystemServerSecurity())
{
case CPolicy::ESystemServerSecurityPassedOrFailed:
p.Set(_L("ESystemServerSecurityPassedOrFailed"));
break;
case CPolicy::ESystemServerSecurityPassed:
p.Set(_L("ESystemServerSecurityPassed"));
break;
case CPolicy::ESystemServerSecurityFailed:
p.Set(_L("ESystemServerSecurityFailed"));
break;
default:
p.Set(_L("*** UNKNOWN ***"));
break;
}
TBuf<80> buf;
buf.AppendFormat(_L(" System Server Security: %S\n"), &p);
aPrinter->PrintL(buf);
}
示例13: TestStepResult
TVerdict CFile0Step::doTestStepL()
/**
* @return - TVerdict code
* Override of base class pure virtual
* Our implementation only gets called if the base class doTestStepPreambleL() did
* not leave. That being the case, the current test result value will be EPass.
*/
{
if (TestStepResult()==EPass)
{
TestNewL();
TestUnlockResourcesL();
TestSettingsL();
TestWriteL();
if(iErrors == 0)
SetTestStepResult(EPass);
else
{
SetTestStepResult(EFail);
TBuf<64> buf;
INFO_PRINTF1(_L("********"));
buf.AppendFormat(_L("%d errors were found!"), iErrors);
INFO_PRINTF1(buf);
INFO_PRINTF1(_L("********"));
}
}
return TestStepResult();
}
示例14: GenerateTestDescriptionLC
/** Function to generate a meaningful hash string from the test attributes
@param aSize the size of the font
@param aAttributes the attributes of the font
@see TFontEffectsFlags
@param aTypefaceName the typeface name
@return the buffer with a text description, used for inclusion in the hash string
*/
HBufC* CTLinkedFontsComparison::GenerateTestDescriptionLC(TInt aSize,TUint32 aAttributes, const TPtrC &aTypefaceName, const TDesC &aTestDescription)
{
TBuf<KLengthOfHashValue> tempBuffer;
//append the name
tempBuffer.Append(_L("_"));
tempBuffer.Append(aTypefaceName);
tempBuffer.Append(_L("_"));
tempBuffer.Append(aTestDescription);
tempBuffer.Append(_L("_"));
//append the size
tempBuffer.AppendFormat(_L("_size-%d"),aSize);
if (aAttributes == 0)
{
//output no attributes
tempBuffer.Append(_L("_"));
tempBuffer.Append(KFontEffectsFlagsString[0]); //no attributes string
}
else
{
for (TInt counter=0;counter<31;counter++)
{
TInt bit = 1<<counter; //1,2,4,8 etc
if (bit&aAttributes)
{
tempBuffer.Append(_L("_"));
tempBuffer.Append(KFontEffectsFlagsString[counter+1]);
}
}
}
return tempBuffer.AllocLC();
}
示例15: SetLIAC
// ----------------------------------------------------------------------------
// CBluetoothEngine::SetLIAC
// ----------------------------------------------------------------------------
void CBluetoothEngine::SetLIAC(TBool aState) {
TInt err = KErrNone;
// Set LIAC for the system
err = iProperty.Set(KPropertyUidBluetoothControlCategory,
KPropertyKeyBluetoothSetLimitedDiscoverableStatus, aState);
TBuf<KEighty> myMessage;
myMessage.Zero();
if (KErrNone == err) {
if (aState) {
myMessage.Append(KLIACOn);
} else {
myMessage.Append(KLIACOff);
}
iLIAC = aState;
iDeviceDiscoverer->SetLIAC(iLIAC);
} else {
myMessage.AppendFormat(KLIACError, err);
}
TRAP( err, ShowMessageL( myMessage, ETrue ));
}