当前位置: 首页>>代码示例>>C++>>正文


C++ TBuf8::AppendFormat方法代码示例

本文整理汇总了C++中TBuf8::AppendFormat方法的典型用法代码示例。如果您正苦于以下问题:C++ TBuf8::AppendFormat方法的具体用法?C++ TBuf8::AppendFormat怎么用?C++ TBuf8::AppendFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TBuf8的用法示例。


在下文中一共展示了TBuf8::AppendFormat方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SetCursorPosRel

TInt CVtConsoleOutputController::SetCursorPosRel(const TPoint& aPoint)
	{
	TInt err = KErrInUse;
	if (iMode == ConsoleMode::EText)
		{
		TBuf8<32> buf;

		if (aPoint.iY == 0)
			{
			// Do nothing.
			}
		else if (aPoint.iY < 0)
			{
			// Move cursor up.
			_LIT8(KEscapeCursorUp, "\x1b[%uA");
			buf.AppendFormat(KEscapeCursorUp, -aPoint.iY);
			}
		else if (aPoint.iY > 0)
			{
			// Move cursor down.
			_LIT8(KEscapeCursorDown, "\x1b[%uB");
			buf.AppendFormat(KEscapeCursorDown, aPoint.iY);
			}

		if (aPoint.iX == 0)
			{
			// Do nothing.
			}
		else if (aPoint.iX < 0)
			{
			// Move cursor left.
			_LIT8(KEscapeCursorLeft, "\x1b[%uD");
			buf.AppendFormat(KEscapeCursorLeft, -aPoint.iY);
			}
		else if (aPoint.iX > 0)
			{
			// Move cursor right.
			_LIT8(KEscapeCursorRight, "\x1b[%uC");
			buf.AppendFormat(KEscapeCursorRight, aPoint.iY);
			}
		
		err = KErrNone;
		if (buf.Length() > 0)
			{
			err = iOutput.Output(buf);
			if (err == KErrNone)
				{
				iCursorTracker->SetCursorPosRel(aPoint);
				}
			}
		}
	return err;
	}
开发者ID:cdaffara,项目名称:symbiandump-os1,代码行数:53,代码来源:vtc_controller.cpp

示例2: AssertionFail

void AssertionFail(const char* aAssertion, const char* aFile, TInt aLine)
	{
	__DEBUGGER();
	TBuf8<256> buf;
	TSilentOverflow o;
	buf.AppendFormat(_L8("Assertion failed: \"%s\" in %s:%i\n"), &o, aAssertion, aFile, aLine);
	if (buf.Length()*2>buf.MaxLength()) buf.SetLength(buf.MaxLength()/2);
	console->Write(buf.Expand());
	User::Panic(_L("Fed"), aLine);
	}
开发者ID:cdaffara,项目名称:symbiandump-os1,代码行数:10,代码来源:main.cpp

示例3: EncodeL

// -----------------------------------------------------------------------------
// CSdpConnectionField::EncodeL
// Writes attributes in proper format to the stream
// -----------------------------------------------------------------------------
//
EXPORT_C void CSdpConnectionField::EncodeL(
    RWriteStream& aStream ) const
	{
	__TEST_INVARIANT;
    TBuf8<20> number;  // Is enough for addr as well

    // c=<network type> <address type> <connection address>
    RStringF header = iPool.StringF( SdpCodecStringConstants::EConnection,
                                     SdpCodecStringConstants::Table );
    aStream.WriteL( header.DesC() );

    // Network type
    aStream.WriteL( iNetType.DesC() );
    aStream.WriteL( KSPStr );

    // Address type
    aStream.WriteL( iAddressType.DesC() );
    aStream.WriteL( KSPStr );

    // Connection address
    aStream.WriteL( *iAddress );
    if ( iTTL != KErrNotFound )
        {
        number.Zero();
        number.Append( KSlashStr );
        number.AppendFormat( _L8("%d"), iTTL );
        aStream.WriteL( number );
        }

    if ( iNumOfAddress > 1 )
        {
        number.Zero();
        number.Append( KSlashStr );
        number.AppendFormat( _L8("%u"), iNumOfAddress );
        aStream.WriteL( number );
        }

     // End-of-Line mark
	aStream.WriteL( KCRLFStr );
	}
开发者ID:kuailexs,项目名称:symbiandump-mw1,代码行数:45,代码来源:SdpConnectionField.cpp

示例4: TestReportLog

LOCAL_C void TestReportLog(const TDesC8& aText)
	{
	TBuf8<200> buf;

	TTime now;
	now.UniversalTime();
	TDateTime dateTime;
	dateTime = now.DateTime();
	buf.Format(_L8 ("%02d.%02d:%02d:%06d "),dateTime.Hour(),dateTime.Minute(),dateTime.Second(),dateTime.MicroSecond());
	buf.AppendFormat(_L8("%S\015\012"),&aText);
	TestRpt.Write(buf);
	TestRpt.Flush();
	}
开发者ID:cdaffara,项目名称:symbiandump-os1,代码行数:13,代码来源:Te_LoopBackt_tsylb.cpp

示例5: WriteRecord

void CDTSYLogger::WriteRecord(const TDesC8& aText)
	{
	if(iValid)
		{
		TBuf8<KGenericBufferSize> buf;
		TTime now;
		now.UniversalTime();
		TDateTime dateTime;
		dateTime = now.DateTime();
		buf.Format(_L8 ("%04d/%02d/%02d %02d.%02d:%02d:%06d "),dateTime.Year(),dateTime.Month()+1, dateTime.Day()+1,dateTime.Hour(),dateTime.Minute(),dateTime.Second(),dateTime.MicroSecond());
		buf.AppendFormat(_L8("%S\015\012"),&aText);
		iFile.Write(buf);
		iFile.Flush();
		}
	}
开发者ID:cdaffara,项目名称:symbiandump-os1,代码行数:15,代码来源:Dsatlog.cpp

示例6: PrintDecisionL

void CDatabase::PrintDecisionL(CDecisionRecord& aRecord)
	{
	_LIT(KDelimiter,	";");
	_LIT(KWriteId,		"\"%08x\"");
	_LIT(KWriteString,	"\"%S\"");
	_LIT8(KWriteString8,"\"%S\"");
	_LIT8(KWriteHex8,	"%02x");

	
	iPrinter->PrintfL(KWriteId,aRecord.iClientSid.iId);
	iPrinter->PrintfL(KDelimiter);
	iPrinter->PrintfL(KWriteId,aRecord.iEvaluatorId.iUid);
	iPrinter->PrintfL(KDelimiter);
	iPrinter->PrintfL(KWriteId,aRecord.iServiceId.iUid);
	iPrinter->PrintfL(KDelimiter);
	iPrinter->PrintfL(KWriteId,aRecord.iServerSid.iId);
	iPrinter->PrintfL(KDelimiter);
	
	TBuf8<KUpsMaxFingerprintLength*2> hexdump;
	TUint8 *ptr = (TUint8 *)aRecord.iFingerprint.Ptr();
	TInt i;
	TInt len = aRecord.iFingerprint.Length();

	for(i=0; i<len; ++i)
		{
		hexdump.AppendFormat(KWriteHex8,ptr[i]);
		}
	iPrinter->Printf8L(KWriteString8,&hexdump);
	iPrinter->PrintfL(KDelimiter);
		
	if(iFlag & EPrintBinary)
		{
		iPrinter->Printf8L(KWriteString8,&aRecord.iClientEntity);
		iPrinter->PrintfL(KDelimiter);
		}
	else
		{
		hexdump.Zero();
		ptr = (TUint8 *)aRecord.iClientEntity.Ptr();
		len = aRecord.iClientEntity.Length();
		for(i=0; i<len; ++i)
			{
			hexdump.AppendFormat(KWriteHex8,ptr[i]);
			}
		iPrinter->Printf8L(KWriteString8,&hexdump);
		iPrinter->PrintfL(KDelimiter);
		}	
		
	iPrinter->PrintfL(KWriteString,&aRecord.iDescription);
	iPrinter->PrintfL(KDelimiter);
	
	iPrinter->PrintfL(KWriteId,aRecord.iResult);
	iPrinter->PrintfL(KDelimiter);
	iPrinter->PrintfL(KWriteId,aRecord.iEvaluatorInfo);
	iPrinter->PrintfL(KDelimiter);
	iPrinter->PrintfL(KWriteId,aRecord.iMajorPolicyVersion);
	iPrinter->PrintfL(KDelimiter);
	iPrinter->PrintfL(KWriteId,aRecord.iRecordId);
	
	iPrinter->Printf8L(_L8("\n"));
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:61,代码来源:dumpupsdb.cpp

示例7: LogExtra

EXPORT_C void RTestExecuteLogServ::LogExtra(const TText8* aFile, TInt aLine, TInt aSeverity,TRefByValue<const TDesC> aFmt, VA_LIST aList)
/**
 * @param aFile - Source file name
 * @param aLine - Source file line number
 * @param aSeverity - ERR, WARN, INFO
 * @param aFmt - UNICODE format string
 * @param aList - Variable argument list
 *
 * Format a log output line
 */
	{
	if (aSeverity>iLogLevel) 
		{
		return;
		}
	// Create a filename string
	TBuf16<KMaxFilename> fileName;
	GetCPPModuleName(fileName, aFile);
	// Create a buffer for formatting
	HBufC* buffer = HBufC::New(KMaxTestExecuteLogLineLength*2);
	if (buffer)
		{
		TPtr ptr(buffer->Des());
		_LIT(KErr,"ERROR - ");
		_LIT(KHigh,"HIGH - ");
		_LIT(KWarn,"WARN - ");
		_LIT(KMedium,"MEDIUM - ");
		_LIT(KInfo,"INFO - ");
		_LIT(KLow,"LOW - ");
		_LIT(KFormat," %d %S %d ");
		if(aSeverity == ESevrErr)
			ptr.Append(KErr);
		else if(aSeverity == ESevrHigh)
			ptr.Append(KHigh);
		else if(aSeverity == ESevrWarn)
			ptr.Append(KWarn);
		else if(aSeverity == ESevrMedium)
			ptr.Append(KMedium);
		else if (aSeverity == ESevrInfo)
			ptr.Append(KInfo);
		else if(aSeverity == ESevrLow)
			ptr.Append(KLow);
		else //if(aSeverity == ESevrAll)
			ptr.Append(KInfo);
		// Add the thread id
		ptr.AppendFormat(KFormat,(TInt)RThread().Id(),&fileName, aLine);
		TTEFDes16Overflow des16OverflowObject;
		ptr.AppendFormatList(aFmt, aList, &des16OverflowObject);
		

		TRAP_IGNORE(WriteL(ptr));
		delete buffer;
		}
	else
		{
		_LIT(KWarn,"WARN - ");
		TBuf8<KLowMemBufLength> noMemory;
		AddTime(noMemory);
		noMemory.Append(KWarn);
		noMemory.AppendFormat(_L8(" %d "), (TInt)RThread().Id());
		noMemory.Append(fileName);
		noMemory.AppendFormat(_L8(" %d %S"), aLine, &KLoggerNotEnoughMemory8());
		TRAP_IGNORE(WriteL(noMemory));
		}
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:65,代码来源:client.cpp

示例8: PrintBuf

/* ???
LOCAL_C void PrintBuf(TDes8 &aBuf)
//
// Print the contents of a buffer
//
	{

	TInt len=aBuf.Length();
	for (TInt i=0;i<=len/8;i++)
		{
		test.Printf(_L("%4d: "),i*8);

		for (TInt j=0;j<8;j++)
			{
			if ((i*8)+j>=len)
				break;
			TInt v=aBuf[(i*8)+j];
			test.Printf(_L("%02x "),v);
			}
		test.Printf(_L("\n\r"));
		}
	}
*/
LOCAL_C void testLoopBack(TLineRate aLineRate,TBps aBaudRate)
//
// Perform an analogue loopback test at the specified linerate
//
{

    TInt err;
    TBuf<64> b;
    TPtrC bd=BaudRateInText(aBaudRate);
    b.Format(_L("Loopback test(%S)"),&bd);
    test.Start(b);

    TBuf8<KBlockSize> txBuf;
    theSerialPort->ResetBuffers();
    txBuf.Format(_L8("AT&F+MS=%d,0,%d,%d\\N0&K3&D2M0\r"),LineModeData[aLineRate],LineRateData[aLineRate],LineRateData[aLineRate]);
    test(theSerialPort->WriteS(txBuf)==KErrNone);

    TBuf8<KBlockSize> rxBuf;
    User::After(2000000);		  // 2Secs
    err=theSerialPort->QueryReceiveBuffer();
    test(err>0);
    rxBuf.SetLength(err);
    TRequestStatus rxStat;
    theSerialPort->ReadOneOrMore(rxStat,rxBuf);
    User::WaitForRequest(rxStat);
//	test.Printf(_L("   Rx(%d):"),rxStat); // ???
    test(rxStat==KErrNone);
    txBuf.Append(_L("\r\nOK\r\n"));
    err=rxBuf.Compare(txBuf);
//	test(TranslateCrLf(rxBuf)==KErrNone); // ???
//  test.Printf(_L(" %S\r\n"),&rxBuf); // ???
    test(err==0);

    test.Next(_L("Get loopback"));
    txBuf.Format(_L8("AT&T1\r"));
    test(theSerialPort->WriteS(txBuf)==KErrNone);
    User::After(5000000);		  // 5Secs
    err=theSerialPort->QueryReceiveBuffer();
    test(err>0);
    rxBuf.SetLength(err);
    theSerialPort->ReadOneOrMore(rxStat,rxBuf);
    User::WaitForRequest(rxStat);
    test.Printf(_L("   Rx(%d):"),rxStat);
    test(rxStat==KErrNone);
    txBuf.AppendFormat(_L8("\r\nCONNECT %d\r\n"),LineConnectData[aLineRate]);
    err=rxBuf.Compare(txBuf);
    test(TranslateCrLf(rxBuf)==KErrNone);
    test.Printf(_L(" %S\r\n"),&rxBuf); // Print what we got back (without CR/LF etc).
    // Sometimes get extra character as modem goes on-line so just look for command echo + connect
    test(err>=0);
    User::After(2000000);		  // 2Secs

    TInt totalBlocksToTransfer;
    if (aBaudRate<EBps1200||aLineRate<EV22_1200)
        totalBlocksToTransfer=KBlocksShort;
    else if (aBaudRate<EBps4800||aLineRate<EV32_4800)
        totalBlocksToTransfer=KBlocksMedium;
    else if (aLineRate<EV34_28800)
        totalBlocksToTransfer=KBlocksLong;
    else
        totalBlocksToTransfer=KBlocksVeryLong;
    b.Format(_L("Transfering data(%dK)"),(totalBlocksToTransfer*KBlockSize)/1024);
    test.Next(b);
    TInt loopBackFail=KErrGeneral;
    TRequestStatus txStat;
    txBuf.SetLength(KBlockSize);
    TInt i;
    for (i=0; i<KBlockSize; i++)
        txBuf[i]=(TUint8)i;
    theSerialPort->Write(txStat,txBuf,KBlockSize);
    TInt txBlks=(totalBlocksToTransfer-1);
    rxBuf.Fill(0,KBlockSize);
    theSerialPort->Read(rxStat,rxBuf,KBlockSize);
    TInt rxBlks=0;
    TRequestStatus tStat;
    RTimer tim;
    test(tim.CreateLocal()==KErrNone);
//.........这里部分代码省略.........
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:101,代码来源:t_modem1.cpp


注:本文中的TBuf8::AppendFormat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。