本文整理汇总了C++中TPtrC::Alloc方法的典型用法代码示例。如果您正苦于以下问题:C++ TPtrC::Alloc方法的具体用法?C++ TPtrC::Alloc怎么用?C++ TPtrC::Alloc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPtrC
的用法示例。
在下文中一共展示了TPtrC::Alloc方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NewL
// -----------------------------------------------------------------------------
// CScardServer::NewL
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CScardServer* CScardServer::NewL()
{
_WIMTRACE(_L("WIM|Scard|CScardServer::NewL|Begin"));
CScardServer* self = new( ELeave ) CScardServer;
CleanupStack::PushL( self );
self->ConstructL();
CleanupStack::Pop( self );
TPtrC tempName;
tempName.Set( KScardServerName );
HBufC* pName = tempName.Alloc();
//Again these panics EPR
__ASSERT_ALWAYS( pName,
PanicServer( KScServerPanicSvrCreateServer ) );
self->iName = pName; // Ownership moves
// Start the server
TPtr name = self->iName->Des();
TInt r = self->Start( name );
__ASSERT_ALWAYS( r == KErrNone,
PanicServer( KScServerPanicSvrCreateServer ) );
return self;
}
示例2: ReadStrL
EXPORT_C HBufC* CTIniData::ReadStrL(const TPtrC& aIniParam, const TDesC& aConfigFile)
{
CIniData * iniData = CIniData::NewL(aConfigFile);
CleanupStack::PushL(iniData);
TPtrC value;
User::LeaveIfError(iniData->FindVar(KDefaultSectionName, aIniParam, value));
HBufC* ret = value.Alloc();
CleanupStack::PopAndDestroy(iniData);
return ret;
}
示例3: nInd
//.........这里部分代码省略.........
// Check that the attribute name was preceded by line break or
// it was at the beginning of the Jad file
if (nInd == 0)
{
fullNameFound = ETrue;
}
else
{
ch = parsePtr[nInd-1];
if ((ch == CR) || (ch == LF))
{
fullNameFound = ETrue;
}
else
{
// Name was just a part of longer string (not 'word match')
fullNameFound = EFalse;
// Skip to the last character of the found match.
// We can skip because we are insterested only in 'word' matches
// so the next cannot start inside the area we are skipping now.
parsePtr.Set(parsePtr.Mid(nInd + aAttributeName.Length() - 1));
continue;
}
}
// Check whether Jad file ends after attribute name
if (nInd + aAttributeName.Length() >= parsePtr.Length())
{
// Jad file ends immediately after the found
// attribute name instance. No attribute value
return NULL;
}
// Check that there is a white space character or colon after
// attribute name
ch = parsePtr[nInd + aAttributeName.Length()];
if ((ch == COLON) || (ch == SP) || (ch == HT))
{
fullNameFound = ETrue;
}
else
{
// Name was just a part of longer string (not 'word match')
fullNameFound = EFalse;
// Skip to the next character after the found match
parsePtr.Set(parsePtr.Mid(nInd + aAttributeName.Length()));
continue;
}
}
while (!fullNameFound);
// Skip to the end of the attribute name and find ':' after the name.
// The skipped characters must be white space chacraters, otherwise
// the attribute name is illegal and Java Installer will not accept
// the Jad file.
parsePtr.Set(parsePtr.Mid(nInd + aAttributeName.Length() - 1));
nInd = parsePtr.Locate(COLON);
if (nInd < 0)
{
return NULL;
}
nInd++;
// Parse attribute value (CR or LF ends)
TInt nEndInd = parsePtr.Locate(CR);
TInt nTmpInd = parsePtr.Locate(LF);
if (KErrNotFound == nEndInd)
{
nEndInd = parsePtr.Length() - 1;
}
if (KErrNotFound == nTmpInd)
{
nTmpInd = parsePtr.Length() - 1;
}
if (nTmpInd < nEndInd)
{
nEndInd = nTmpInd;
}
if (nEndInd < nInd)
{
return NULL;
}
TPtrC attributeValue = parsePtr.Mid(nInd, (nEndInd - nInd));
// Remove possible white space from the beginning and end of the value
HBufC *bufValue = attributeValue.Alloc();
if (NULL == bufValue)
{
return NULL;
}
TPtr value = bufValue->Des();
value.Trim();
return bufValue;
} // parseAttribute
示例4: ExecuteActionL
/**
ExecuteActionL
Obtains the parameters for the test action. Get the Message Id at given index. The Message
Id is stored as output parameters of this Test Action
@internalTechnology
@pre None
@post None
@leave System wide errors
*/
void CMtfTestActionSendAsSetBodyText::ExecuteActionL()
{
if((TestCase().TestStepResult()) == EPass)
{
TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSendAsSetBodyText);
// Get test action input parameters
RSendAsMessage sendAsMessage = ObtainValueParameterL<RSendAsMessage>(TestCase(),
ActionParameters().Parameter(0));
// Buffer type to be used for adding the body text
// 0 => Set body text using Descriptor
// 1 => Set body text using CRichText object (Default)
TInt bufferType = ObtainValueParameterL<TInt>(TestCase(),
ActionParameters().Parameter(1),1);
TInt index = ObtainValueParameterL<TInt>(TestCase(),
ActionParameters().Parameter(2));
// Get the body text configuration file name
TPtrC fileName = TestCase().GetConfigurationFileL(CMtfConfigurationType::EMtfDataFile,index);
// Create a Rich text object to store the Body text contents
CPlainText::TTextOrganisation ttOrg = {CPlainText::EOrganiseByLine};
CParaFormatLayer* paraFormatLayer = CParaFormatLayer::NewL();
CleanupStack::PushL(paraFormatLayer);
CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL();
CleanupStack::PushL(charFormatLayer);
CRichText* bodyCRichText = CRichText::NewL(paraFormatLayer, charFormatLayer);
CleanupStack::PushL(bodyCRichText);
HBufC* bodyTextFileName = fileName.Alloc();
CleanupStack::PushL(bodyTextFileName);
// Read the body text contents into the Rich text object
bodyCRichText->ImportTextFileL(0, bodyTextFileName->Des(), ttOrg);
TInt err = KErrNone;
// Set body text using descriptor
if( bufferType == 0 )
{
// Create a heap buffer and copy the file contents
TInt len1 = bodyCRichText->DocumentLength();
HBufC* buf1 = HBufC::NewL(len1);
CleanupStack::PushL(buf1);
TPtr fileContents = buf1->Des();
bodyCRichText->Extract(fileContents,0,(len1));
// Set the body text to the message
TRAP(err, sendAsMessage.SetBodyTextL(fileContents));
if(err == KErrNone)
{
TestCase().INFO_PRINTF1(_L("SetBodyTextL using Descriptor was successful"));
}
else
{
TestCase().ERR_PRINTF2(_L("SetBodyTextL using Descriptor failed with error: %d"), err);
TestCase().SetTestStepResult(EFail);
}
// destroy the temporary storage of the text
CleanupStack::PopAndDestroy(buf1);
}
else if (bufferType == 1)
{
// Set body text using CRichText
TRAP(err, sendAsMessage.SetBodyTextL(*bodyCRichText));
if(err == KErrNone)
{
TestCase().INFO_PRINTF1(_L("SetBodyTextL using Rich Text was successful"));
}
else
{
TestCase().ERR_PRINTF2(_L("SetBodyTextL using Rich Text failed with error: %d"), err);
TestCase().SetTestStepResult(EFail);
}
}
else
{
err = KErrArgument;
TestCase().ERR_PRINTF2(_L("Incorrent input parameter: Buffer type value should be either 0 or 1. The value provided is %d"),bufferType );
TestCase().SetTestStepResult(EFail);
}
StoreParameterL<TInt>(TestCase(),err,ActionParameters().Parameter(3));
CleanupStack::PopAndDestroy(4); //bodyTextFileName, bodyCRichText, charFormatLayer, paraFormatLayer
TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSendAsSetBodyText);
//.........这里部分代码省略.........