本文整理汇总了C++中TBuf::AllocL方法的典型用法代码示例。如果您正苦于以下问题:C++ TBuf::AllocL方法的具体用法?C++ TBuf::AllocL怎么用?C++ TBuf::AllocL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TBuf
的用法示例。
在下文中一共展示了TBuf::AllocL方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadFieldAsTextL
HBufC* CAgentAddressbook::ReadFieldAsTextL(const CContactItemField& itemField)
{
if (itemField.Storage() == NULL || !itemField.Storage()->IsFull())
return HBufC::NewL(0);
switch (itemField.StorageType())
{
case KStorageTypeText:
{
CContactTextField* txtField = itemField.TextStorage();
if (txtField == NULL)
return HBufC::NewL(0);
return txtField->Text().AllocL();
}
case KStorageTypeDateTime:
{
CContactDateField* dateField = itemField.DateTimeStorage();
if (dateField == NULL)
return HBufC::NewL(0);
TTime time = dateField->Time();
_LIT(KFORMAT_DATE, "%D%M%Y%/0%1%/1%2%/2%3%/3");
TBuf<30> strTime;
time.FormatL(strTime, KFORMAT_DATE);
return strTime.AllocL();
}
default:
return HBufC::NewL(0);
}
}
示例2: ReadSearchL
// -----------------------------------------------------------------------------
// CLogPlayerManager::ReadSearchL
// -----------------------------------------------------------------------------
//
HBufC* CLogPlayerManager::ReadSearchL(RFileReadStream& aReadStream, TInt& aIndex)
{
aIndex = ReadNumberL(aReadStream);
ReadTextL(aReadStream, iTextBuffer, KLogPlayerFieldSeparatorEndLine);
TBuf<KLogPlayerMaxTextLength> searchQuery;
searchQuery.Copy(iTextBuffer);
return searchQuery.AllocL();
}
示例3: 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 );
}
示例4: GetPlatformVersionL
HBufC* GetPlatformVersionL()
{
VersionInfo::TPlatformVersion platformVersion;
User::LeaveIfError(VersionInfo::GetVersion(platformVersion));
TBuf<KBufferSize> version;
version.AppendNum(platformVersion.iMajorVersion);
version.Append('.');
version.AppendNum(platformVersion.iMinorVersion);
return version.AllocL();
}
示例5: dialogs
/*
-------------------------------------------------------------------------------
tells Y-Browser the human readable name of the filetype
shown in file type selection dialogs (like the include/exclude types in file search)
-------------------------------------------------------------------------------
*/
HBufC* CYBRecognizer1::FileTypeNameL(TInt aIndex)
{
TBuf<100> aName;
switch(aIndex)
{
case 0:
aName.Copy(KtxTypeName);
break;
}
return aName.AllocL();
}
示例6: doTestStepL
/**
Function : doTestStepL
Description : Verify if message part(s) of the message entries returned by sort mechanism are
in the intended order.
@return : TVerdict - Test step result
*/
TVerdict CT_MsgVerifySortResult::doTestStepL()
{
INFO_PRINTF1(_L("Test Step : VerifySortResult"));
TPtrC fieldName;
TBuf<1> buf;
TBool sortedByTo = ETrue;
TBool sortedByFrom = ETrue;
TBool sortedByCc = ETrue;
TBool sortedByBcc = ETrue;
TBool sortedBySubject = ETrue;
TBool sortedByUnRead = ETrue;
TBool sortedByDetails = ETrue;
TBool sortedByDescription = ETrue;
TBool sortedByDate = ETrue;
TBool sortedBySize = ETrue;
TBool sortedByAttachment = ETrue;
TBool sortedByPriority = ETrue;
TBool sortedById = ETrue;
TBool sortedByNewFlag = ETrue;
TInt expectedSearchResultCount = 0;
GetIntFromConfig(ConfigSection(), KExpectedResultCount, expectedSearchResultCount); // Read search result count
TInt resultCount = 0;
GetIntFromConfig(ConfigSection(), KCountOfResult, resultCount); // Read search result count
if(expectedSearchResultCount > 0 && resultCount == 0)
{
ERR_PRINTF2(_L("Expected SORT Result Count > 0 and Actual SORT result count = %d"), resultCount);
SetTestStepResult(EFail);
}
else if(expectedSearchResultCount == 0 && resultCount == 0)
{
SetTestStepResult(EPass);
}
else
{
RArray<TMsvEntry> messageEntries = iSharedDataCommon.iSearchSortResultArray;
INFO_PRINTF2(_L("Number of entries to be verified = %d"), messageEntries.Count());
DisplayMsgEntryList(messageEntries); // Log the message entry details
if ( !GetStringFromConfig( ConfigSection(), KSortMsgPart, fieldName))
{
ERR_PRINTF1(_L("Message part to be verified for is not specified"));
SetTestStepResult (EFail);
}
TMsvMessagePart msgPartValue = CT_MsgUtilsEnumConverter::ConvertDesToMessagePart(fieldName);
TPtrC sortOrder;
GetStringFromConfig(ConfigSection(), KSortOrder, sortOrder);
TMsvSortOrder sortOption = CT_MsgUtilsEnumConverter::ConvertDesToSortOrder(sortOrder);
CMsvEntry *entry = CMsvEntry::NewL(*iSharedDataCommon.iSession, KMsvRootIndexEntryId, TMsvSelectionOrdering());
CleanupStack::PushL(entry);
switch(msgPartValue)
{
case EMsvTo:
switch(sortOption)
{
case EMsvSortAscending:
for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByTo; ++j)
{
entry->SetEntryL(messageEntries[j].Id());
CMsvStore* store1 = entry->ReadStoreL();
CleanupStack::PushL(store1);
CImHeader* header1 = CImHeader::NewLC();
header1->RestoreL(*store1); // Retrieves the email message header
HBufC* address1=HBufC::NewL(50);
if(header1->ToRecipients().Count())
{
address1 = (header1->ToRecipients()[0]).AllocL();
}
CleanupStack::PopAndDestroy(2,store1);
entry->SetEntryL(messageEntries[j+1].Id());
CMsvStore* store2 = entry->ReadStoreL();
CleanupStack::PushL(store2);
CImHeader* header2 = CImHeader::NewLC();
header2->RestoreL(*store2); // Retrieves the email message header
HBufC* address2=HBufC::NewL(50);
// FIx when no fields are there
if(header2->ToRecipients().Count())
{
address2 = (header2->ToRecipients()[0]).AllocL();
}
CleanupStack::PopAndDestroy(2,store2);
if(address1->CompareF(*address2) > 0)// Checks if any messages is not in Ascending order w.r.t to TO field
{
ERR_PRINTF1(_L("Sorting by TO: Not in Ascending order"));
sortedByTo = EFalse;
//.........这里部分代码省略.........
示例7: ConstructL
void CMemSpyEngineCodeSegEntry::ConstructL()
{
iFileName = HBufC::NewL( iCreateInfo.iFileName.Length() );
iFileName->Des().Copy( iCreateInfo.iFileName );
// Make caption
TParsePtrC parser( *iFileName );
const TPtrC pFileNameWithoutPath( parser.NameAndExt() );
TBuf<KMaxFullName + 128> item;
//
_LIT(KCodeSegFormat, "\t%S\t\t%S code");
const TMemSpySizeText codeSize( MemSpyEngineUtils::FormatSizeText( iCreateInfo.iCodeSize ) );
item.Format( KCodeSegFormat, &pFileNameWithoutPath, &codeSize );
if ( iCreateInfo.iDataSize > 0 )
{
_LIT(KCodeSegFormatAdditionalData, ", %S data");
const TMemSpySizeText dataSize( MemSpyEngineUtils::FormatSizeText( iCreateInfo.iTotalDataSize ) );
item.AppendFormat( KCodeSegFormatAdditionalData, &dataSize );
}
iCaption = item.AllocL();
//
_LIT(KItem0, "\tName\t\t%S");
item.Format( KItem0, &pFileNameWithoutPath );
AppendL( item );
// Uids
const TUidType uids( iCreateInfo.iUids );
for( TInt i=0; i<KMaxCheckedUid; i++ )
{
_LIT(KItem1, "\tUid #%d\t\t0x%08x");
const TUid uidValue( uids[ i ] );
//
item.Format( KItem1, i+1, uidValue.iUid );
AppendL( item );
}
//
if ( iCreateInfo.iModuleVersion == KModuleVersionWild )
{
_LIT(KItem12, "\tModule Version\t\t[Wild]");
AppendL( KItem12 );
}
else if ( iCreateInfo.iModuleVersion == KModuleVersionNull )
{
_LIT(KItem12, "\tModule Version\t\t[Null]");
AppendL( KItem12 );
}
else
{
_LIT(KItem12, "\tModule Version\t\t0x%08x");
item.Format( KItem12, iCreateInfo.iModuleVersion );
AppendL( item );
}
//
_LIT(KItem13, "\tSID\t\t0x%08x");
item.Format( KItem13, iCreateInfo.iS.iSecureId );
AppendL( item );
//
_LIT(KItem14, "\tVID\t\t0x%08x");
item.Format( KItem14, iCreateInfo.iS.iVendorId );
AppendL( item );
//
if ( iCreateInfo.iCodeSize > 0 )
{
_LIT(KItem2, "\tCode Size\t\t%d");
item.Format( KItem2, iCreateInfo.iCodeSize );
AppendL( item );
}
//
if ( iCreateInfo.iTotalDataSize > 0 )
{
_LIT(KItem6, "\tTotal Data Size\t\t%d");
item.Format( KItem6, iCreateInfo.iTotalDataSize );
AppendL( item );
}
//
if ( iCreateInfo.iTextSize > 0 )
{
_LIT(KItem3, "\tText Size\t\t%d");
item.Format( KItem3, iCreateInfo.iTextSize );
AppendL( item );
}
//
if ( iCreateInfo.iDataSize > 0 )
{
_LIT(KItem4, "\tData Size\t\t%d");
item.Format( KItem4, iCreateInfo.iDataSize );
AppendL( item );
}
//
if ( iCreateInfo.iBssSize > 0 )
{
_LIT(KItem5, "\tBSS Size\t\t%d");
//.........这里部分代码省略.........
示例8: base_tests
bool base_tests(MApp_context& ctx, MOutput& aOutput, int retest)
{
int retest_count=1;
#define RECREATE { CleanupStack::PopAndDestroy(); CCurrentLoc* loc=CCurrentLoc::NewL(ctx, cellid_names); CleanupStack::PushL(loc); loc->add_sinkL(l); }
#define RETEST(interval) { now+=TTimeIntervalMinutes(interval); test_time=now; if(retest==0 || retest_count==retest) { RECREATE l->Expect(prev_e); test_time-=TTimeIntervalMinutes(interval); } ++retest_count; }
CGenericIntMap* cellid_names=CGenericIntMap::NewL();
CleanupStack::PushL(cellid_names);
cellid_names->SetDeletor(delete_bufc);
TTime test_time;
int i;
for (i=1; i<100; i++) {
TBuf<10> ib;
ib.AppendNum(i);
cellid_names->AddDataL(i, (void*)ib.AllocL());
}
CTestLog *l=CTestLog::NewL(aOutput);
CleanupStack::PushL(l);
CCurrentLoc* loc=CCurrentLoc::NewL(ctx, cellid_names);
CleanupStack::PushL(loc);
loc->add_sinkL(l);
now=TTime(1);
loc->EmptyLog();
_LIT(cell, "1, 1, T");
CTestLog::TExpectItem prev_e;
aOutput.Print(_L("start at a base\n"));
prev_e=l->Expect(Mlogger::VALUE, _L("base"), _L("last: "), TTime(0));
l->Expect(Mlogger::VALUE, _L("base"), _L("1"), now);
loc->now_at_location(cell, 1, true, true, now);
l->GotP();
aOutput.Print(_L("move out\n"));
now+=TTimeIntervalMinutes(15);
prev_e=l->Expect(Mlogger::VALUE, _L("base"), _L("last: 1"), now);
loc->now_at_location(cell, 2, false, true, now);
l->GotP();
RETEST(0)
loc->now_at_location(cell, 2, false, true, now);
l->GotP();
aOutput.Print(_L("come to another non-base cell\n"));
RETEST(1)
loc->now_at_location(cell, 3, false, true, now);
aOutput.Print(_L("come to a new base\n"));
RETEST(10)
l->Expect(Mlogger::VALUE, _L("base"), _L("4"), now);
loc->now_at_location(cell, 4, true, true, now);
l->GotP();
aOutput.Print(_L("stay in base, different cell\n"));
RETEST(1)
loc->now_at_location(cell, 5, true, false, now);
aOutput.Print(_L("move out\n"));
RETEST(15)
TTime ppprev=now;
prev_e=l->Expect(Mlogger::VALUE, _L("base"), _L("last: 4"), test_time);
loc->now_at_location(cell, 6, false, true, now);
l->GotP();
aOutput.Print(_L("move out 2\n"));
RETEST(5)
loc->now_at_location(cell, 7, false, true, now);
aOutput.Print(_L("notice this cell is a base\n"));
TTime pprev=now;
RETEST(0)
l->Expect(Mlogger::VALUE, _L("base"), _L("7"), now);
loc->now_at_location(cell, 7, true, false, now);
l->GotP();
aOutput.Print(_L("move out\n"));
RETEST(15)
TTime prev=test_time;
prev_e=l->Expect(Mlogger::VALUE, _L("base"), _L("last: 7"), test_time);
loc->now_at_location(cell, 8, false, true, now);
RETEST(5)
loc->now_at_location(cell, 9, false, true, now);
l->GotP();
aOutput.Print(_L("come to a base\n"));
RETEST(10)
l->Expect(Mlogger::VALUE, _L("base"), _L("10"), now);
loc->now_at_location(cell, 10, true, true, now);
l->GotP();
aOutput.Print(_L("leave quickly\n"));
RETEST(1)
prev_e=l->Expect(Mlogger::VALUE, _L("base"), _L("last: 7"), prev);
loc->now_at_location(cell, 11, false, true, now);
l->GotP();
//.........这里部分代码省略.........
示例9: ConstructL
void CMemSpyEngineChunkEntry::ConstructL( const TMemSpyDriverChunkInfo& aInfo )
{
// Copy info
iInfo = new(ELeave) TMemSpyDriverChunkInfo();
*iInfo = aInfo;
// Make caption
TBuf<KMaxFullName+128> item;
_LIT(KCaptionFormat, "\t%S\t\t%d");
item.Format( KCaptionFormat, &Name(), Size() );
iCaption = item.AllocL();
// Make other items
iList = CMemSpyEngineOutputList::NewL();
_LIT( KEntry0, "Name");
iList->AddItemL( KEntry0, Name() );
_LIT( KEntryType, "Type" );
switch( aInfo.iType )
{
default:
case EMemSpyDriverChunkTypeUnknown:
iList->AddItemL( KEntryType, _L("Unknown") );
break;
case EMemSpyDriverChunkTypeHeap:
iList->AddItemL( KEntryType, _L("Heap") );
break;
case EMemSpyDriverChunkTypeHeapKernel:
iList->AddItemL( KEntryType, _L("Kernel Heap") );
break;
case EMemSpyDriverChunkTypeStackAndProcessGlobalData:
iList->AddItemL( KEntryType, _L("Stack and Process Global Data") );
break;
case EMemSpyDriverChunkTypeStackKernel:
iList->AddItemL( KEntryType, _L("Kernel Stack") );
break;
case EMemSpyDriverChunkTypeGlobalData:
iList->AddItemL( KEntryType, _L("Global Data") );
break;
case EMemSpyDriverChunkTypeCode:
iList->AddItemL( KEntryType, _L("Code") );
break;
case EMemSpyDriverChunkTypeCodeGlobal:
iList->AddItemL( KEntryType, _L("Global Code") );
break;
case EMemSpyDriverChunkTypeCodeSelfModifiable:
iList->AddItemL( KEntryType, _L("Self Modifiable Code") );
break;
case EMemSpyDriverChunkTypeLocal:
iList->AddItemL( KEntryType, _L("Local") );
break;
case EMemSpyDriverChunkTypeGlobal:
iList->AddItemL( KEntryType, _L("Global") );
break;
case EMemSpyDriverChunkTypeRamDrive:
iList->AddItemL( KEntryType, _L("RAM Drive") );
break;
}
_LIT( KEntry1, "Owning Process");
OwnerName( item );
iList->AddItemL( KEntry1, item );
_LIT( KEntry2, "Address" );
_LIT( KEntry2Format, "0x%08x - 0x%08x" );
item.Format( KEntry2Format, BaseAddress(), UpperAddress() );
iList->AddItemL( KEntry2, item );
_LIT( KEntry3, "Size");
iList->AddItemL( KEntry3, Size() );
_LIT( KEntry4, "Max. Size");
iList->AddItemL( KEntry4, MaxSize() );
_LIT( KEntryAttributeFormat, "Attribute %d");
TInt attribNum = 0;
//
if ( aInfo.iAttributes & ENormal )
{
item.Format( KEntryAttributeFormat, ++attribNum );
iList->AddItemL( item, _L("Normal") );
}
if ( aInfo.iAttributes & EDoubleEnded )
{
item.Format( KEntryAttributeFormat, ++attribNum );
iList->AddItemL( item, _L("Double Ended") );
}
if ( aInfo.iAttributes & EDisconnected )
{
item.Format( KEntryAttributeFormat, ++attribNum );
iList->AddItemL( item, _L("Disconnected") );
}
if ( aInfo.iAttributes & EConstructed )
{
item.Format( KEntryAttributeFormat, ++attribNum );
iList->AddItemL( item, _L("Constructed") );
}
if ( aInfo.iAttributes & EMemoryNotOwned )
{
//.........这里部分代码省略.........
示例10: ParseL
//
// Parse/Set data members
//
void CTelVoiceMailboxParser::ParseL(CParsedFieldCollection& aIacpFields)
{
TBuf<64> aFieldValueBuf;
if ((aFieldValueBuf= aIacpFields.GetFieldValue(SMS_TEL_VOICE_MAILBOX_NUM)) != TPtrC())
iTel= aFieldValueBuf.AllocL();
}
示例11: FetchInfoL
// -----------------------------------------------------------------------------
// CSconVersionInfo::FetchInfoL()
// fetch device info
// -----------------------------------------------------------------------------
//
void CSconVersionInfo::FetchInfoL( RFs& aFs )
{
TRACE_FUNC_ENTRY;
iSymbianVersionError = SysVersionInfo::GetVersionInfo( iSymbianVersion, aFs );
iS60VersionError = VersionInfo::GetVersion( iS60Version, aFs );
TBuf<KSysVersionInfoTextLength> info;
TBuf<KSysVersionInfoTextLength> productBuf;
TInt err(KErrNone);
delete iSWVersion;
iSWVersion = NULL;
delete iProduct;
iProduct = NULL;
// get SW version, SW version date and model
TRAP( err, CapUtil::GetSWVersionL( info, iDate, productBuf ) );
iSWVersion = info.AllocL();
iProduct = productBuf.AllocL();
LOGGER_WRITE_1("CapUtil::GetSWVersionL err: %d", err);
SysVersionInfo::TProductVersion productVersion;
TInt sysVersionError = SysVersionInfo::GetVersionInfo( productVersion, aFs );
LOGGER_WRITE_1( "SysVersionInfo::GetVersionInfo returned : %d", sysVersionError );
// Use TelServer to get IMEI and also other info if SysVersionInfo is not supported
RTelServer telServer;
User::LeaveIfError( telServer.Connect() );
CleanupClosePushL( telServer );
RTelServer::TPhoneInfo teleinfo;
User::LeaveIfError( telServer.GetPhoneInfo( 0, teleinfo ) );
RMobilePhone phone;
User::LeaveIfError( phone.Open( telServer, teleinfo.iName ) );
CleanupClosePushL( phone );
User::LeaveIfError(phone.Initialise());
TUint32 teleidentityCaps;
phone.GetIdentityCaps( teleidentityCaps );
RMobilePhone::TMobilePhoneIdentityV1 telid;
TRequestStatus status;
phone.GetPhoneId( status, telid );
User::WaitForRequest( status );
if ( status == KErrNone )
{
if ( sysVersionError )
{
LOGGER_WRITE("Use info from TMobilePhoneIdentityV1");
delete iModel;
iModel = NULL;
delete iRevision;
iRevision = NULL;
// phone model sales name. For example "N01".
iModel = telid.iModel.AllocL();
// product revision. For example "01"
iRevision = telid.iRevision.AllocL();
}
delete iSerialNumber;
iSerialNumber = NULL;
// Phone serial number (IMEI or ESN), in character string format.
iSerialNumber = telid.iSerialNumber.AllocL();
}
CleanupStack::PopAndDestroy( &phone );
CleanupStack::PopAndDestroy( &telServer );
if ( sysVersionError == KErrNone )
{
// use information from SysVersionInfo instead of previous APIs.
LOGGER_WRITE("Using SysVersionInfo");
// phone model sales name. For example "N01".
delete iModel;
iModel = NULL;
iModel = productVersion.iModel.AllocL();
// product revision. For example "01"
delete iRevision;
iRevision = NULL;
iRevision = productVersion.iRevision.AllocL();
// manufacturer name. For example "Nokia"
delete iManufacturer;
iManufacturer = NULL;
iManufacturer = productVersion.iManufacturer.AllocL();
// product code name. For example "RM-1"
delete iProduct;
iProduct = NULL;
iProduct = productVersion.iProduct.AllocL();
}
else
{
CapUtil::GetManufacturer( info );
delete iManufacturer;
iManufacturer = NULL;
iManufacturer = info.AllocL();
}
//.........这里部分代码省略.........