本文整理汇总了C++中TPtr8::Format方法的典型用法代码示例。如果您正苦于以下问题:C++ TPtr8::Format方法的具体用法?C++ TPtr8::Format怎么用?C++ TPtr8::Format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPtr8
的用法示例。
在下文中一共展示了TPtr8::Format方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UsernameTokenL
EXPORT_C TInt CSenWsSecurityHeader::UsernameTokenL(const TDesC8& aUsername,
const TDesC8& aPassword,
HBufC8*& aToken)
{
TPtrC8 nsPrefix = KSecurityXmlNsPrefix();
aToken = HBufC8::NewLC( KUsernameTokenStartTagFmt().Length() +
KUsernameFmt().Length() +
KUsernameTokenEndTag().Length() +
KPasswordStartTagDefaultFmt().Length() +
KPasswordEndTagFmt().Length() +
aPassword.Length() +
aUsername.Length() +
nsPrefix.Length() * 6 );
TPtr8 ptr = aToken->Des();
// ptr.Format(KNameTokenFormat, &nsPrefix, &nsPrefix, &aUsername, &nsPrefix, &nsPrefix);
ptr.Format(KUsernameTokenStartTagFmt, &nsPrefix);
ptr.AppendFormat(KUsernameFmt, &nsPrefix, &aUsername, &nsPrefix);
ptr.AppendFormat(KPasswordStartTagDefaultFmt,
&nsPrefix, &aPassword); // no Type -attribute used
ptr.AppendFormat(KPasswordEndTagFmt, &nsPrefix);
ptr.AppendFormat(KUsernameTokenEndTag, &nsPrefix);
CleanupStack::Pop(); // aToken
return KErrNone;
}
示例2: BinarySecurityTokenL
EXPORT_C TInt CSenWsSecurityHeader::BinarySecurityTokenL(const TDesC8& aContent, HBufC8*& aToken)
{
TPtrC8 nsPrefix = KSecurityXmlNsPrefix();
aToken = HBufC8::NewLC( KBinarySecurityTokenFmt().Length() +
aContent.Length() +
nsPrefix.Length() * 2 );
TPtr8 ptr = aToken->Des();
ptr.Format(KBinarySecurityTokenFmt, &nsPrefix, &aContent, &nsPrefix);
CleanupStack::Pop(); // aToken
return KErrNone;
}
示例3: HexDump
// ==========================================================================
// METHOD: HexDump
//
// DESIGN:
// ==========================================================================
void CLogFileHandler::HexDump( const TDesC8& /*aClassName*/,
const TDesC8& /*aFuncName*/,
const TDesC8& aBuffer )
{
TInt remainingLength = aBuffer.Length();
TInt i = 0;
while( remainingLength > 0 )
{
const TInt KHexDumpWidth=32;
TInt n = Min( KHexDumpWidth, remainingLength );
// Add the starting byte number.
_LIT8(KFirstFormatString,"%04x : ");
iFormatBuffer8.Format(KFirstFormatString, i);
// Add hex values.
TInt j;
for (j=0; j<n; j++)
{
_LIT8(KSecondFormatString,"%02x ");
iFormatBuffer8.AppendFormat(KSecondFormatString, aBuffer[i+j]);
} // end for
// Fill in incomplete lines.
while (j<KHexDumpWidth)
{
_LIT8(KThreeSpaces," ");
iFormatBuffer8.Append(KThreeSpaces);
j++;
} // end while
// Add text representation.
_LIT8(KTwoSpaces," ");
iFormatBuffer8.Append(KTwoSpaces);
for (j=0; j<n; j++)
{
_LIT8(KThirdFormatString,"%c");
iFormatBuffer8.AppendFormat( KThirdFormatString, aBuffer[i+j] );
} // end for
iOutputBuffer.SetLength( 0 );
TRAP_IGNORE( WriteLineL( iFormatBuffer8 ) );
remainingLength -= n;
i += n;
} // end while
} // END HexDump
示例4: ConstructL
/**
CPplContactsFile ConstructL.
*/
void CPplContactsFile::ConstructL()
{
iItemManager = CPplContactItemManager::NewL(iDatabase, *this, iContactProperties, iIccContactStore);
iContactProperties.SetContactItemManagerL(*iItemManager);
iConfigureStr = NULL;
if(KContactsModelSqliteDbCacheSize > 0)
{
//Create configure string to be used when creating/opening database
iConfigureStr = HBufC8::NewL(KSqliteCacheSize().Length() + KCacheDataSize);
TPtr8 ptrConfigureStr = iConfigureStr->Des();
ptrConfigureStr.Format(KSqliteCacheSize(), KContactsModelSqliteDbCacheSize);
}
}
示例5: ReceiveMessageL
// -----------------------------------------------------------------------------
// CSeiForwardPlugin::ReceiveMessageL
//
//
// -----------------------------------------------------------------------------
//
void CSeiForwardPlugin::ReceiveMessageL( TInt aChannel, TPtrC8 aMessage )
{
RDebug::Print( _L( "EcmtSeiForwardPlugin::ReceiveMessageL: channel = %d" ), aChannel );
HBufC8* buf = HBufC8::NewLC( KMaxMsgPrefixLen + 1 + aMessage.Length() );
TPtr8 message = buf->Des();
message.Format( KMsg, aChannel );
message.Append( KBlanco );
message.Append( aMessage );
CEcmtMessageEvent* m = iMessaging->NewMessageEvent( TUid::Uid( KSEIFORWARDPLUGIN_IMPL_UID ), message );
User::LeaveIfNull( m );
iMessaging->GetMessageSender()->SendMessage( m );
}
示例6: ConstructL
/**
CPplContactsFile ConstructL.
*/
void CPplContactsFile::ConstructL()
{
// Do this first since the contacts table created by the
// iItemManager will need to know if the directory exists.
TRAP_IGNORE(TCntImageRescaleUtility::CreateImageDirectoryL());
iItemManager = CPplContactItemManager::NewL(iDatabase, *this, iContactProperties, iIccContactStore);
iContactProperties.SetContactItemManagerL(*iItemManager);
iConfigureStr = NULL;
if(KContactsModelSqliteDbCacheSize > 0)
{
//Create configure string to be used when creating/opening database
iConfigureStr = HBufC8::NewL(KSqliteCacheSize().Length() + KCacheDataSize);
TPtr8 ptrConfigureStr = iConfigureStr->Des();
ptrConfigureStr.Format(KSqliteCacheSize(), KContactsModelSqliteDbCacheSize);
}
}
示例7: TimestampL
EXPORT_C TInt CSenWsSecurityHeader::TimestampL(const TDesC8& aCreated, HBufC8*& aToken)
{
TPtrC8 nsPrefix = KSecurityUtilityXmlNsPrefix();
aToken = HBufC8::NewLC(KTimestampFormatString8().Length()
+ aCreated.Length()
+ nsPrefix.Length()*5
+ KSecurityUtilityXmlNs().Length());
TPtr8 ptr = aToken->Des();
ptr.Format(KTimestampFormatString8,
&nsPrefix,
&nsPrefix,
&KSecurityUtilityXmlNs(),
&nsPrefix,
&aCreated,
&nsPrefix,
&nsPrefix);
CleanupStack::Pop(aToken);
return KErrNone;
}
示例8: OnDataContainerL
/**
This method is a callback that sends data container reference
@param aContainer Container encapsulating binary data
@param aErrorCode is the error code.
If this is not KErrNone then special action may be required.
*/
void CTestHandler::OnDataContainerL(const TXmlEngDataContainer& aContainer, TInt aErrorCode)
{
_LIT8(KOnContentFuncName,"OnDataContainer()\r\n");
_LIT8(KInfoOnContent,"\tData container CID: %S \r\n");
_LIT8(KInfoOnError,"Error occurs %d \r\n");
HBufC8* info = HBufC8::NewL(aContainer.Cid().Size() + 50);
TPtr8 infoPtr = info->Des();
iLog.Write(KOnContentFuncName);
if (aErrorCode == KErrNone)
{ TPtrC8 cid = aContainer.Cid();
infoPtr.Format(KInfoOnContent, &cid);
iLog.Write(infoPtr);
}
else
{
TBuf8<KShortInfoSize> info;
info.Format(KInfoOnError,aErrorCode);
iLog.Write(info);
}
delete info;
}
示例9: OnBinaryContentL
/**
This method is a callback that sends the binary content of the element.
@param aBytes is the raw binary content data for the element.
@param aErrorCode is the error code.
If this is not KErrNone then special action may be required.
*/
void CTestHandler::OnBinaryContentL(const TDesC8& aBytes, const TDesC8& aCid, TInt aErrorCode)
{
/*
//use this part of the code if you want to save binary data to MSWord format
RFs fs;
CleanupClosePushL(fs);
User::LeaveIfError(fs.Connect());
RFile f;
CleanupClosePushL(f);
TInt err = f.Replace(fs, _L("c:\\xmlengine\\deserializer\\output\\bin.doc"), EFileWrite);
err = f.Write(aBytes);
CleanupStack::PopAndDestroy(2); //f fs
*/
aCid.Size(); // eliminate compilation warning
_LIT8(KOnContentFuncName,"OnBinaryContent()\r\n");
_LIT8(KInfoOnContent,"\tBinary content of element: %S \r\n");
_LIT8(KInfoOnError,"Error occurs %d \r\n");
HBufC8* info = HBufC8::NewL(aBytes.Size() + 50);
TPtr8 infoPtr = info->Des();
iLog.Write(KOnContentFuncName);
if (aErrorCode == KErrNone)
{
infoPtr.Format(KInfoOnContent, &aBytes);
iLog.Write(infoPtr);
}
else
{
TBuf8<KShortInfoSize> info;
info.Format(KInfoOnError,aErrorCode);
iLog.Write(info);
}
delete info;
}
示例10: ServiceL
TInt CTestHostlet::ServiceL(MSenHostletRequest& aRequest, MSenHostletResponse& aResponse)
{
iTxnIds.Append(aRequest.RequestId());
iResponseCodes.Append(KErrNone);
TInt retVal(KErrNone);
// Setup default response, can be overridden by test case:
// Dummy response
TPtrC8 request = aRequest.RequestUtf8();
iRequests.Append(request.AllocL());
MSenProperties::TSenPropertiesClassType propType;
TPtrC8 requestProperties = aRequest.Properties(propType);
iRequestProps.Append(requestProperties.AllocL());
iRequestPropTypes.Append(propType);
// _LIT8(KResponseFmt, "<Response><ReplyMessage>CSenHostletConnectionBCTest is alive.</ReplyMessage><Request>%S</Request></Response>");
_LIT8(KResponseFmt, "<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\"><S:Header></S:Header><S:Body>testing text hostlet</S:Body></S:Envelope>");
HBufC8* pResponse = HBufC8::NewLC(request.Length()+KResponseFmt().Length());
TInt appendError = iResponses.Append(pResponse);
if( appendError )
{
CleanupStack::PopAndDestroy(pResponse); // delete orphan HBufC8 / pResponse
}
else
{
CleanupStack::Pop(pResponse); // now owned by iResponses -array..
}
TPtr8 response = iResponses[iTxnIds.Count()-1]->Des();
response.Format(KResponseFmt, &request);
aResponse.SetResponseUtf8L(response, iResponseCodes[iTxnIds.Count()-1]); // by default, all requests are "accepted"
if ( ip2ServiceL )
{
// NOTE(!): if RESPONSE CODE in aResponse is modified in YOUR test case,
// remember set iResponseCodes for this test hostlet instance in your test
// case code (ServiceL callback)
retVal = (*ip2ServiceL)(ipTestSuite, aRequest, aResponse);
}
TPtrC8 providedResponse = aResponse.ResponseUtf8();
if ( iResponses[iTxnIds.Count()-1]->Compare(providedResponse) != 0 )
{
// response was altered by TEST CASE:
iResponses.Insert(aResponse.ResponseUtf8().AllocL(),iTxnIds.Count()-1);
}
RDebug::Print(_L("CTestHostlet::ServiceL received:"));
RDebug::RawPrint(request);
if (ipTestSuite->ipUsedHostletConnection)
{
iRespondRetCode = ipTestSuite->ipUsedHostletConnection->RespondL(aResponse);
}
else
iRespondRetCode = ipTestSuite->ipHostletConnection->RespondL(aResponse);
return retVal;
}