本文整理汇总了C++中HBufC::Left方法的典型用法代码示例。如果您正苦于以下问题:C++ HBufC::Left方法的具体用法?C++ HBufC::Left怎么用?C++ HBufC::Left使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HBufC
的用法示例。
在下文中一共展示了HBufC::Left方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MakeNewPolicyNameL
HBufC* CPolicyStore::MakeNewPolicyNameL(const TDes& aOriginalPolicyName,
TInt aSequenceNumber)
{
LOG_("-> CPolicyStore::MakeNewPolicyName");
const TInt KMaxSequenceNumberStringLength = 32;
_LIT(KSequenceNumberFormat, "(%d)");
HBufC* sequenceNumberString = HBufC::NewLC(KMaxSequenceNumberStringLength);
sequenceNumberString->Des().Format(KSequenceNumberFormat, aSequenceNumber);
// New name string to be returned
HBufC* retBuf(NULL);
// Usage of Trim method in PinParser decreases the length by 2 items
TInt spaceLeft = aOriginalPolicyName.MaxLength() - 2 - aOriginalPolicyName.Length();
TInt sequenceNumberStringLength = sequenceNumberString->Length();
if (sequenceNumberStringLength <= spaceLeft)
{
// There's enough free space for the sequence
// number, so we can just add append it
LOG_1(" Sequence number string: '%S'", &(*sequenceNumberString));
// Determine final string length for dynamic allocation
TInt len = aOriginalPolicyName.Length() + sequenceNumberString->Length();
retBuf = HBufC::NewLC(len);
// Construct the final name string
TPtr16 ptr = retBuf->Des();
ptr.Append(aOriginalPolicyName.Left(aOriginalPolicyName.Length()));
ptr.Append(sequenceNumberString->Left(sequenceNumberString->Length()));
}
else
{
// There's not enough space for the sequence
// number so we override the end of the policy
// name with the sequence number
TInt lengap = sequenceNumberStringLength - spaceLeft;
// Determine final string length for dynamic allocation
TInt len = aOriginalPolicyName.MaxLength();
retBuf = HBufC::NewLC(len);
// Construct the final name string
TPtr16 ptr = retBuf->Des();
ptr.Append(aOriginalPolicyName.Left(aOriginalPolicyName.Length() - lengap));
ptr.Append(sequenceNumberString->Left(sequenceNumberString->Length()));
}
// Just pop, and delete the non-returned value explicitly
CleanupStack::Pop(2); // retBuf, sequenceNumberString
delete sequenceNumberString;
LOG_("<- CPolicyStore::MakeNewPolicyName");
return retBuf;
}
示例2: DoEnsureUniquePolicyNameL
TBool CPolicyStore::DoEnsureUniquePolicyNameL(TVpnPolicyDetails& aPolicyDetails)
{
LOG(Log::Printf(_L("-> CPolicyStore::DoEnsureUniquePolicyNameL")));
TBool nameChanged = EFalse;
TBool isUnique = EFalse;
HBufC* newName = aPolicyDetails.iName.AllocLC();
TInt sequenceNumber = 2;
while (!isUnique && sequenceNumber < KMaxTInt)
{
if (PolicyNameExists(*newName))
{
if (newName != NULL)
{
CleanupStack::PopAndDestroy(newName);
LOG_(" Pop (newName)");
newName = NULL;
}
newName = MakeNewPolicyNameL(aPolicyDetails.iName, sequenceNumber);
CleanupStack::PushL(newName);
sequenceNumber++;
nameChanged = ETrue;
}
else
{
isUnique = ETrue;
}
}
if (nameChanged)
{
// We now have a new unique policy name so we can save it
// Make sure there's no risk of overflow
aPolicyDetails.iName.Copy(newName->Left(aPolicyDetails.iName.MaxLength()));
}
if (newName != NULL)
{
CleanupStack::PopAndDestroy(); // newName
}
LOG(Log::Printf(_L("<- CPolicyStore::DoEnsureUniquePolicyName")));
return nameChanged;
}
示例3: bufferPtr
TBool WidgetUnzipUtilityS60::RunUnzipL()
{
CZipFileMember* member = iMembers->NextL();
if (member)
{
CleanupStack::PushL(member);
RZipFileMemberReaderStream* stream;
User::LeaveIfError(iZipFile->GetInputStreamL(member, stream));
CleanupStack::PushL(stream);
HBufC8* buffer = HBufC8::NewLC(member->UncompressedSize());
TPtr8 bufferPtr(buffer->Des());
User::LeaveIfError(stream->Read(bufferPtr, member->UncompressedSize()));
TFileName text;
text.Copy(*iTempZipPath);
text.Append(_L('\\'));
text.Append(*member->Name());
HBufC* zipedFileNameAndPath = text.AllocLC();
TInt index = zipedFileNameAndPath->LocateReverse('\\');
if (index >= 0)
{
TPtrC path = zipedFileNameAndPath->Left(index + 1);
iFs.MkDirAll(path); // errors are ok
}
if (zipedFileNameAndPath->Right(1).Compare(_L('\\')) != 0)
{
RFile file;
CleanupClosePushL(file);
file.Replace(iFs,*zipedFileNameAndPath,EFileWrite);
User::LeaveIfError(file.Write(*buffer));
CleanupStack::PopAndDestroy(); // file
}
iUncompressedSize += member->UncompressedSize();
CleanupStack::PopAndDestroy(4);
return ETrue;
}
else
{
return EFalse;
}
}
示例4: createMMS
//---------------------------------------------------------------
// TestUniDataModelPlugin::createMMS
//---------------------------------------------------------------
void TestUniDataModelMMSPlugin::createMMS(TMsvId pId, TBool subjectField)
{
TMsvEntry indexEntry;
indexEntry.iType = KUidMsvMessageEntry;
indexEntry.iMtm = KUidMsgTypeMultimedia;
indexEntry.iServiceId = iServiceId;
indexEntry.iDate.HomeTime();
// Convert TTime to QDateTime , this will be used for comparing the time of mesage
// when fetched from datamodel
TTime unixEpoch(KUnixEpoch);
TTimeIntervalSeconds seconds;
TTime timeStamp = indexEntry.iDate;
timeStamp.SecondsFrom(unixEpoch, seconds);
retTimeStamp.setTime_t(seconds.Int());
TMsvId parentId = pId;
CMsvEntry* entry = CMsvEntry::NewL(*iMSession,parentId,TMsvSelectionOrdering());
CleanupStack::PushL(entry);
entry->SetEntryL(parentId);
entry->CreateL(indexEntry);
entry->SetEntryL(indexEntry.Id());
iMmsClientMtm->SwitchCurrentEntryL(entry->EntryId());
CMsvStore* store = iMmsClientMtm->Entry().EditStoreL();
CleanupStack::PushL(store);
//MMS Message ID Saved
iMessageId = indexEntry.Id();
//Adding Subject
if(subjectField)
{
QString subject(TEST_MSG_SUBJECT);
HBufC* subj = XQConversions::qStringToS60Desc(subject);
iMmsClientMtm->SetSubjectL(*subj);
}
//Adding Sender
QString sender(TEST_MSG_FROM1);
HBufC* addr = XQConversions::qStringToS60Desc(sender);
if (addr)
{
CleanupStack::PushL(addr);
TBuf<32> name;
name.Copy(addr->Left(32));
indexEntry.iDetails.Set(name);
iMmsClientMtm->SetSenderL(*addr);
CleanupStack::PopAndDestroy(addr);
}
//Adding Recipient
QString recipient(TEST_MSG_RECIEPIENT1);
HBufC* addr2 = XQConversions::qStringToS60Desc(recipient);
if (addr2)
{
CleanupStack::PushL(addr2);
iMmsClientMtm->AddAddresseeL(EMsvRecipientTo,*addr2);
CleanupStack::PopAndDestroy(addr2);
}
//Adding cCRecipient
QString recipient2(TEST_MSG_RECIEPIENT2);
HBufC* addr3 = XQConversions::qStringToS60Desc(recipient2);
if (addr3)
{
CleanupStack::PushL(addr3);
iMmsClientMtm->AddAddresseeL(EMsvRecipientCc,*addr3);
CleanupStack::PopAndDestroy(addr3);
}
//Adding bCCRecipient
QString recipient3(TEST_MSG_RECIEPIENT3);
HBufC* addr4 = XQConversions::qStringToS60Desc(recipient3);
if (addr4)
{
CleanupStack::PushL(addr4);
iMmsClientMtm->AddAddresseeL(EMsvRecipientBcc,*addr4);
CleanupStack::PopAndDestroy(addr4);
}
//Create Text Attachment
TMsvAttachmentId attaId = 0;
TFileName attachmentFile( _L("story.txt") );
TBufC<12> story = _L( "Hello world!" );
iMmsClientMtm->CreateTextAttachmentL(*store, attaId, story, attachmentFile, ETrue );
qDebug() << "Text Attachment id" << attaId;
//Image Attachment added to the message entry
RFile attaFile;
// Set filename of attachment
TFileName name( KPictureFileName );
//.........这里部分代码省略.........
示例5: FindIndexL
TInt CContactViewRangeBase::FindIndexL(const TDesC& aMatch,TCriteria aCriteria) const
// Binary search through iView to find the first contact that matches aMatch according to aCritera.
/** Called by implementations of SetL() to search the sub view's underlying view
for the index of the first item whose field content matches aMatch, using
the specified search criteria.
@internalComponent
@param aMatch The text to search for.
@param aCriteria The search criteria.
@return The index of the first matching item in the view. KErrNotFound if the
view is empty or if none match. */
{
const TInt NumberOfCharsToCompare=1;
TInt result=KErrNotFound;
TInt min=0;
TInt max=iView.CountL()-1;
if (max<0)
{
// The parent view is empty.
return KErrNotFound;
}
TBool finished=EFalse;
HBufC* sortableText;
while (!finished)
{
TInt guess;
if (max==min)
{
finished=ETrue;
}
guess=(max-min)/2+min;
sortableText = iView.AllFieldsLC(guess,KNullDesC);
TInt compare=sortableText->Left(NumberOfCharsToCompare).CompareC(aMatch.Left(NumberOfCharsToCompare),3,iCollateMethod);
CleanupStack::PopAndDestroy();//sortableText
switch (aCriteria)
{
case ELessThan:
{
if (compare>0 || compare==0)
{
// String is greater than aMatch.
max=guess-1;
if (max<min)
{
finished=ETrue;
}
}
else if (compare<0)
{
// String is less than aMatch - could be a hit.
min=guess+1;
if (min>max)
{
finished=ETrue;
}
if (result==KErrNotFound || guess>result)
{
// guess is a closer match, so overwrite result.
result=guess;
}
}
break;
}
case ELessThanOrEqualTo:
{
if (compare>0)
{
// String is greater than aMatch.
max=guess-1;
if (max<min)
{
finished=ETrue;
}
}
else if (compare<=0)
{
// String is less than or equal to aMatch - possible hit.
min=guess+1;
if (min>max)
{
finished=ETrue;
}
if (result==KErrNotFound || guess>result)
{
// guess is a closer match, so overwrite result.
result=guess;
}
}
break;
}
case EGreaterThan:
{
if (compare<0 || compare==0)
{
// String is less than aMatch.
min=guess+1;
if (min>max)
{
//.........这里部分代码省略.........
示例6: SetContentL
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//
void CPosLmGpxParser::SetContentL( TPosXmlTagType aTag, const TDesC& aContent )
{
switch (aTag)
{
// landmarkCollection Tags
case EPosXmlLmCollName:
AddCollectionDataL( EPosLmCollDataCollectionName, aContent );
break;
case EPosXmlLmCollDescription:
AddCollectionDataL( EPosLmCollDataCollectionDescription, aContent );
break;
// landmark Tags
case EPosXmlLandmark:
{
if ( !Math::IsNaN( iParsedLatitude ) && !Math::IsNaN( iParsedLongitude ) )
{
TLocality loc(
TCoordinate(
iParsedLatitude,
iParsedLongitude,
iParsedAltitude),
iParsedHorAcc,
iParsedVertAcc);
iWorkingLandmark->SetPositionL(loc);
}
TBuf<5> num;
num.Num(iNoOfMediaLinks);
iWorkingLandmark->SetPositionFieldL(EPositionFieldMediaLinks, num);
// v1.0 media links
if ( iReadUrl && iGpxVersion == EGpxVersion10 )
{
SetContentL( EPosXmlLmMediaLink, KNullDesC );
}
HandleLandmarkParsedL();
break;
}
case EPosXmlLmName:
iWorkingLandmark->SetLandmarkNameL( aContent.Left( KPosLmMaxTextFieldLength ) );
break;
case EPosXmlLmDescription:
iWorkingLandmark->SetLandmarkDescriptionL( aContent.Left( KPosLmMaxDescriptionLength ) );
break;
case EPosXmlLmDescription2:
iWorkingLandmark->SetPositionFieldL( EPositionFieldComment, aContent.Left( KPosLmMaxTextFieldLength ) );
break;
case EPosXmlCoordAltitude:
PosLmConverterUtils::DesToRealL(aContent, iParsedAltitude);
break;
case EPosXmlCoordHorizontalAcc:
PosLmConverterUtils::DesToRealL(aContent, iParsedHorAcc);
// Ensure horizontal acc is >= 0
PosLmConverterUtils::AssertL(
iParsedHorAcc >= 0 || Math::IsNaN( iParsedHorAcc ) );
iParsedHorAcc *= KPosLmDopToAccuracyFactor;
break;
case EPosXmlCoordVerticalAcc:
PosLmConverterUtils::DesToRealL( aContent, iParsedVertAcc );
// Ensure vertical acc is >= 0
PosLmConverterUtils::AssertL(
iParsedVertAcc >= 0 || Math::IsNaN( iParsedVertAcc ) );
iParsedVertAcc *= KPosLmDopToAccuracyFactor;
break;
// mediaLink Tag
case EPosXmlMediaLinkUrl:
PosLmConverterUtils::AssertL( PosLmConverterUtils::IsAnyUri( aContent ) );
iReadUrl = aContent.AllocL();
break;
case EPosXmlMediaLinkMime:
iReadMimeType = aContent.AllocL();
break;
case EPosXmlLmMediaLink:
{
HBufC* mediaLink = PosLmConverterUtils::ConcatenateMediaLinkLC(
*iReadMimeType, *iReadUrl );
iWorkingLandmark->SetPositionFieldL(static_cast<TPositionFieldId>
(EPositionFieldMediaLinksStart + iNoOfMediaLinks),
mediaLink->Left(KPosLmMaxTextFieldLength));
iNoOfMediaLinks++;
CleanupStack::PopAndDestroy(mediaLink);
delete iReadMimeType;
iReadMimeType = NULL;
delete iReadUrl;
iReadUrl = NULL;
break;
}
//.........这里部分代码省略.........
示例7: HandleChildElement
void CHandleOutSearch::HandleChildElement(TiXmlNode* aElement)
{
TInt index=iPointArray.Count()-1;
TInt itemIndex=iPointArray[index]->GetItemCount()-1;
if(itemIndex<0)
{
iPointArray[index]->CreatNewItem();
itemIndex=0;
}
if(aElement->NoChildren())
{
if(iFlag)
{
HBufC* buf = CnvUtfConverter::ConvertToUnicodeFromUtf8L(TPtrC8((const TUint8*)aElement->Value()));
CleanupStack::PushL(buf);
if(buf->Compare(_L("br"))==0)
{
if(!iPointArray[index]->GetItem(itemIndex).IsNull())
iPointArray[index]->CreatNewItem();
}
if(buf->Compare(_L("br"))!=0&&buf->Compare(_L("img"))!=0&&buf->Compare(_L("input"))!=0&&buf->Compare(_L("|"))!=0)
{
if(buf->Left(2).Compare(_L("--"))==0)
{
TInt f=0;
for(TInt i=0;i<buf->Length();i++)
{
if(buf->Mid(i,1).Compare(_L("-"))!=0)
{
f=1;
break;
}
}
if(f==0)
{
iFlag=EFalse;
}
}
if(iFlag)
iPointArray[index]->GetItem(itemIndex).SetName(*buf);
else
{
if(!iPointArray[index]->GetItem(itemIndex).IsNull())
iPointArray[index]->CreatNewItem();
}
}
iMainEngine.WriteLog16(*buf);
CleanupStack::PopAndDestroy(1);
}
}
else
{
HBufC8* tag=TPtrC8((const TUint8*)aElement->Value()).Alloc();
CleanupStack::PushL(tag);
TInt value=CheckTag(*tag);
CleanupStack::PopAndDestroy(1);
if(value>0)
{
switch(value)
{
case 1: //P±êÇ©
{
TiXmlNode* element=aElement->FirstChild();
while(element!=0)
{
HandleChildElement(element);
element=element->NextSibling();
}
}
break;
case 2: //Á¬½Ó±êÇ©
{
HBufC8* bufUrl = TPtrC8((const TUint8*)aElement->ToElement()->Attribute("href")).Alloc();
CleanupStack::PushL(bufUrl);
TInt urlFlag=CheckUrl(*bufUrl);
if(urlFlag>0)
{
iPointArray[index]->GetItem(itemIndex).SetUrl(*bufUrl);
}
CleanupStack::PopAndDestroy(1);
if(urlFlag==1||urlFlag==2)
{
HBufC* buf = CnvUtfConverter::ConvertToUnicodeFromUtf8L(TPtrC8((const TUint8*)aElement->FirstChild()->Value()));
CleanupStack::PushL(buf);
iPointArray[index]->GetItem(itemIndex).SetName(*buf);
iMainEngine.WriteLog16(*buf);
CleanupStack::PopAndDestroy(1);
iPointArray[index]->GetItem(itemIndex).SetIsLink(ETrue);
iPointArray[index]->CreatNewItem();
}
else
//.........这里部分代码省略.........
示例8: ShowQueryL
//.........这里部分代码省略.........
secondaryDisplayCmdId = SecondaryDisplay::ECmdShowBtSapDisconnectQuery;
break;
case ESysApMemoryCardLockedNote:
iPendingQuery = ESysApMemoryCardLockedNote;
queryStringBuf = StringLoader::LoadLC( R_QTN_MEMC_LOCKED_NOT_SUPPORTED, aLoaderEnv );
keys = R_AVKON_SOFTKEYS_OK_EMPTY;
anim = R_QGN_NOTE_INFO_ANIM;
secondaryDisplayCmdId = SecondaryDisplay::ECmdShowMemoryCardLockedQuery;
break;
/* case ESysApUseFmTxInOfflineQuery:
queryStringBuf
= StringLoader::LoadLC( R_QTN_FMTX_SYSAP_NOTE_ACTIVATE_IN_OFFLINE,
aLoaderEnv );
keys = R_AVKON_SOFTKEYS_YES_NO;
secondaryDisplayCmdId = SecondaryDisplay::ECmdShowFmTxKeepOnInOfflineQuery;
break;
*/ case ESysApBattChargingPowerSavingQuery:
queryStringBuf = StringLoader::LoadLC( R_QTN_BATTERY_CHARGING_POWER_SAVING_QUERY, aLoaderEnv );
keys = R_AVKON_SOFTKEYS_YES_NO;
secondaryDisplayCmdId = SecondaryDisplay::ECmdShowChargingDeactivatePowerSavingQuery;
tone = static_cast<CAknQueryDialog::TTone>( EAvkonSIDChargingBatteryTone );
break;
case ESysApBattLowPowerSavingQuery:
queryStringBuf = StringLoader::LoadLC( R_QTN_BATTERY_CONF_QUERY, aLoaderEnv );
keys = R_AVKON_SOFTKEYS_YES_NO;
secondaryDisplayCmdId = SecondaryDisplay::ECmdShowBattLowActivatePowerSavingQuery;
break;
default:
break;
}
if ( iSysApAppUi.CoverDisplaySupported() && secondaryDisplayCmdId != SecondaryDisplay::ECmdNoNote )
{
TRACES( RDebug::Print( _L("CSysApConfirmationQuery::ShowQueryL - Notifying secondary display") ) );
CAknSDData* sd = NULL;
if ( secondaryDisplayCmdId == SecondaryDisplay::ECmdShowBtSapDisconnectQuery )
{
SecondaryDisplay::TDeviceName sdDeviceName;
sdDeviceName.Append(deviceNameBuf->Left(SecondaryDisplay::KMaxDeviceNameLen));
SecondaryDisplay::TBtSapDisconnectQueryPckg pckg(sdDeviceName);
sd = CAknSDData::NewL(SecondaryDisplay::KCatSysAp, SecondaryDisplay::ECmdShowBtSapDisconnectQuery, pckg);
}
else
{
sd = CAknSDData::NewL(SecondaryDisplay::KCatSysAp, secondaryDisplayCmdId, KNullDesC8);
}
iQuery->SetSecondaryDisplayData(sd); // ownership to notifier client
}
if ( keys && queryStringBuf )
{
if ( anim )
{
iQuery->ShowConfirmationQueryL( iStatus,
queryStringBuf->Des(),
keys,
anim,
KNullDesC,
0,
0,
tone );
}
else
{
iQuery->ShowConfirmationQueryL( iStatus,
queryStringBuf->Des(),
keys,
0,
KNullDesC,
0,
0,
tone );
}
}
SetActive();
}
else
{
// If another query is wanted when ESysApMemoryCardLockedNote is active, override it (Continues in RunL which handles cancel).
if ( iQueryId == ESysApMemoryCardLockedNote && aQueryId != ESysApMemoryCardLockedNote )
{
iPendingQuery = aQueryId;
iQuery->CancelConfirmationQuery();
}
}
if ( queryStringBuf )
{
CleanupStack::PopAndDestroy( queryStringBuf ); // queryStringbuf
}
if ( deviceNameBuf )
{
CleanupStack::PopAndDestroy( deviceNameBuf ); // deviceNameBuf
}
}
示例9: DoRunL
void CCmdIniEdit::DoRunL()
{
TBool interactive = ETrue;
if (iForce)
{
iReader = CIniReader::NewL(iIniFile);
}
else
{
iReader = CIniFile::NewL(iIniFile, iDescriptionFile);
}
TBool updated = EFalse;
if (iSet)
{
TInt eqPos = iSet->Find(KEquals);
TPtrC value(KNullDesC);
TPtrC id(KNullDesC);
if (eqPos == KErrNotFound)
{
id.Set(*iSet);
Stdin().SetReadModeL(RIoReadHandle::ELine);
iBuf.CreateL(0x100);
Stdin().ReadL(iBuf);
value.Set(iBuf);
}
else
{
id.Set(iSet->Left(eqPos));
value.Set(iSet->Mid(eqPos+1));
}
iReader->SetValueL(Trim(id), value);
updated = ETrue;
interactive = EFalse;
}
if (iRemove)
{
iReader->RemoveValueL(*iRemove);
updated = ETrue;
interactive = EFalse;
}
if (iGet)
{
const TDesC* value = iReader->GetValue(*iGet);
if (!value) LeaveIfErr(KErrNotFound, _L("id '%S' not found in %S"), iGet, &iIniFile);
Write(*value);
interactive = EFalse;
}
else if (iDump)
{
RPointerArray<CValue> values;
CleanupClosePushL(values);
iReader->GetValuesL(values);
for (TInt i=0; i<values.Count(); ++i)
{
if (iForce)
{
Printf(_L("%S: %S\n"), &values[i]->Id(), &values[i]->Value());
}
else
{
CSetting* setting = (CSetting*)values[i];
Printf(_L("%S: %S\n"), &setting->Name(), &setting->Value());
}
}
CleanupStack::PopAndDestroy(&values);
interactive = EFalse;
}
if (interactive)
{
// TODO enter interactive mode
LeaveIfErr(KErrNotSupported, _L("Interactive mode not implemented yet."));
}
if (updated)
{
WriteIniFileL(iIniFile, *iReader);
}
}