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


C++ TDesC::AllocLC方法代码示例

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


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

示例1: SetL

EXPORT_C void CEnvironment::SetL(const TDesC& aKey, const TDesC& aValue)
	{
	WaitLC();

	HBufC** valPtr = iVars.Find(aKey);
	HBufC* currentValue = NULL;
	if (valPtr) currentValue = *valPtr;

	if (valPtr == NULL && iParentEnv)
		{
		// If we don't have it, and we have a parent env, we should pass the request through to it.
		iParentEnv->SetL(aKey, aValue);
		}
	else
		{
		if (currentValue)
			{
			// If we already have a value in the hash, just update it if possible
			TPtr ptr = currentValue->Des();
			if (ptr.MaxLength() >= aValue.Length())
				{
				ptr.Copy(aValue);
				CleanupStack::PopAndDestroy(); // Release lock
				return;
				}
			}
		}
	
	HBufC* newVal = aValue.AllocLC();
	iVars.InsertL(aKey, newVal);
	delete currentValue;
	CleanupStack::Pop(newVal);
	CleanupStack::PopAndDestroy(); // Release lock
	}
开发者ID:cdaffara,项目名称:symbiandump-os1,代码行数:34,代码来源:env.cpp

示例2: WrapPhoneNumberToArrayL

EXPORT_C TBool AknPhoneNumberTextUtils::WrapPhoneNumberToArrayL( 
    const TDesC& aPhoneNumberToWrap,
    TInt aLineWidthInPixels,
    TInt aMaxLines,
    const CFont& aFont,
    CArrayFix<TPtrC>& aWrappedArray )
    {
    TBool retVal( EFalse ); // Not truncated
 
    HBufC* reversedText = aPhoneNumberToWrap.AllocLC();
    TPtr revPtr = reversedText->Des();

    ReverseDescriptor( revPtr );

    CArrayFix<TInt>* lineWidthArray = new (ELeave) CArrayFixFlat<TInt>(KLineArrayGranularity);
    CleanupStack::PushL( lineWidthArray );

    lineWidthArray->AppendL( aLineWidthInPixels, aMaxLines );

    // Perform the wrap on the reversed text
    AknTextUtils::WrapToArrayL( revPtr, *lineWidthArray, aFont, aWrappedArray );

    // Now rearrange the TPtrCs to point to the original array
    TInt totalLen = reversedText->Length();
    TInt count = aWrappedArray.Count();
    TInt usedLen = 0; // Accumulates the length actually used
    for ( TInt index = 0; index < count; index++)
        {
        TPtrC& currentPtr = aWrappedArray.At(index);
        // The TPtrCs have to be moved. The reversing is taken into effect, but not purely reversed
        // because their otherwise they would have negative lengths.  That is, {a,b} does not go to
        // { final - a, final - b }, but rather to {final - b, final - a}; they are flipped, to get
        // their start points before the end points
        //
        // Now, representing the start position by pos, and the end by pos+len-1 we have the TPtrC at
        // {pos, pos+len-1} inclusive, in reversed array. 
        // The TPtrC must be modified to point to {total_len-1 - (pos+len-1), total_len-1 - pos} 
        // in the unreversed array:
        TInt len = currentPtr.Length();
        usedLen += len;
        TInt pos = currentPtr.Ptr() - reversedText->Ptr(); // pointer arithmetic
        TInt newPos = totalLen - pos - len;
        // If the TPtr is zero length then it must get special treatment, as the normal
        // calculations give an end point before the start point! i.e. {pos, pos-1}
        // We handle this by NOT flipping in this case.
        // { pos, pos-1 } -> {totalLen-1-pos, totalLen-1 - (pos-1)}
        // Note that a zero length wrapped line is completely possible amoung a bunch of other 
        // lines with characters on them, as the line lengths may be of wildly different lengths.
        if ( len == 0 ) 
            newPos--;
        currentPtr.Set( aPhoneNumberToWrap.Mid(newPos, len) );
        }

    // If the accumulated length is less than that in the entire input descriptor, then text does not fit
    if ( usedLen < totalLen )
        retVal = ETrue;

    CleanupStack::PopAndDestroy(2); // lineWidthArray first, and then reversedText
    return retVal;
    }
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:60,代码来源:AknPhoneNumberTextUtils.cpp

示例3: RemoveField

// -----------------------------------------------------------------------------
void CPresenceCacheBuddyInfo::DoSet16BitValueL( 
    const TDesC& aKey,    
    const TDesC& aValue )
    {   
      
    // Remove old values first
    RemoveField( aKey );
    
    //Convert Unicode to Utf-8
    HBufC8* convertBuffer =  CnvUtfConverter::ConvertFromUnicodeToUtf8L( aValue );
    CleanupStack::PushL( convertBuffer );
    HBufC* keyBuffer = aKey.AllocLC();    
    
    TInt insertPos = iIds.Find(0);
    if ( insertPos < 0 )
        {
        insertPos = iIds.Count();
        iIds.Append( keyBuffer );
        iValues.Append( convertBuffer );
        }
    else
        {
        iIds[insertPos] = keyBuffer;
        iValues[insertPos] = convertBuffer;
        }
    
    iHashMap.InsertL( keyBuffer, insertPos  );
        
    CleanupStack::Pop( keyBuffer );
    CleanupStack::Pop( convertBuffer );       
    }
开发者ID:cdaffara,项目名称:symbiandump-ossapps,代码行数:32,代码来源:presencecachebuddyinfo.cpp

示例4: IsMimeTypeSupportedL

// -----------------------------------------------------------------------------
// Implements checking if a given MIME type is supported or not
// -----------------------------------------------------------------------------
//
TBool CAknsWallpaperPlugin::IsMimeTypeSupportedL(const TDesC& aMimeTypeString)
    {
    // Check for a type separator in the string
    TInt pos = aMimeTypeString.Find(KAknsWallpaperPluginSeparator);

    // Leave if no separator was found.. the MIME
    // standard requires it
    if (pos == KErrNotFound)
        {
        User::Leave(KErrArgument);
        }

    // Copy the full Mime type string (needed for uppercase)
    HBufC* fullBuf = aMimeTypeString.AllocLC();
    TPtr fullString = fullBuf->Des();
    fullString.UpperCase();

    // Construct the compare string
    TPtrC compareString(aMimeTypeString.Left(pos));

    // Perform the comparison
    TBool ret = EFalse;

    // Mime type case:  IMAGE/* except IMAGE/X-OTA-BITMAP
    if (compareString.CompareF(KAknsWallpaperPluginMimeTypeImage) == 0 &&
        !(fullString.CompareF(KAknsWallpaperPluginMimeTypeOTABitmap) == 0))
        {
        ret = ETrue;
        }
    CleanupStack::PopAndDestroy(fullBuf);

    return ret;
    }
开发者ID:cdaffara,项目名称:symbiandump-mw4,代码行数:37,代码来源:aknswallpaperplugin.cpp

示例5: SetVersionL

// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
//
void CPosModulesSettings::SetVersionL( const TDesC& aVersion )
	{
	HBufC* version = aVersion.AllocLC();
	delete iVersion;
	iVersion = version;
	CleanupStack::Pop( version );
	}
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:10,代码来源:epos_cposmodulessettings.cpp

示例6: CommitChangesToCreL

void CCreGenerator::CommitChangesToCreL(RFs& aFs,TUint8 aPersistVersion,CHeapRepository& aRep,const TDesC& aTargetFilePath)
{
    HBufC* tmpFilePath=aTargetFilePath.AllocLC();
    TPtr tmpFilePathPtr(tmpFilePath->Des());
    tmpFilePathPtr.Replace(tmpFilePath->Length()-3,3,KTmpExtension());

    CDirectFileStore* store = CDirectFileStore::ReplaceLC(aFs, *tmpFilePath,(EFileWrite | EFileShareExclusive));

    const TUid uid2	 = KNullUid ;
    store->SetTypeL(TUidType(KDirectFileStoreLayoutUid, uid2, KServerUid3)) ;

    // Write the stream index/dictionary as root stream within the store
    // so we can access it when we do a restore later on
    RStoreWriteStream rootStream ;
    TStreamId rootStreamId = rootStream.CreateLC(*store) ;
    ExternalizeCre(aPersistVersion,aRep, rootStream) ;
    rootStream.CommitL() ;

    CleanupStack::PopAndDestroy(&rootStream) ;
    store->SetRootL(rootStreamId);
    store->CommitL();
    CleanupStack::PopAndDestroy(store) ;
    User::LeaveIfError(aFs.Replace(*tmpFilePath,aTargetFilePath));
    CleanupStack::PopAndDestroy();
}
开发者ID:kuailexs,项目名称:symbiandump-os2,代码行数:25,代码来源:cregen.cpp

示例7: UpdateL

//--------------------------------------------------------------------
//--------------------------------------------------------------------
//
void CPosLmNameIndex::UpdateL( TPosLmItemId aId, const TDesC& aName )
    {
    HBufC* name = aName.AllocLC();
	CleanupStack::Pop( name );//ownership of name is transferred in the call to UpdateL
//coverity[freed_arg : FALSE]
    UpdateL( aId, name );
//coverity[pass_freed_arg : FALSE]
    }
开发者ID:cdaffara,项目名称:symbiandump-mw2,代码行数:11,代码来源:EPos_CPosLmNameIndex.cpp

示例8: AddConfigurationFilenameL

void CMtfConfigurationType::AddConfigurationFilenameL(const TDesC& aFilename)
{
	// ISSUE: the parameter should be of type TFileName to prevent aFilename
	// being longer than the maximum length of a filename.
	HBufC* fileName = aFilename.AllocLC();
	User::LeaveIfError(iFilenames.Append(fileName));
	CleanupStack::Pop(fileName);
}
开发者ID:cdaffara,项目名称:symbiandump-mw2,代码行数:8,代码来源:CMtfConfigurationType.cpp

示例9: AppendL

void CPresetList::AppendL(TUid aUid, const TDesC& aName)
	{
	HBufC* tempName = aName.AllocLC();
	TPresetEle ele;
	ele.iUid = aUid;
	ele.iName = tempName;
	User::LeaveIfError(iArray.Append(ele));
	CleanupStack::Pop(tempName);
	}
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:9,代码来源:PresetList.cpp

示例10:

void CIpuTestHarness::CTestInfo::SetNameL(const TDesC& aName)
//
//	Sets iName
	{
	HBufC* temp = aName.AllocLC();
	CleanupStack::Pop();	//	temp
	delete iName;
	iName = temp;
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:9,代码来源:IpuTestHarness.cpp

示例11: id

TBool
LaunchWapBrowserUtil::LaunchWapBrowser(const TDesC& aUrl)
{
#if defined NAV2_CLIENT_SERIES60_V2 || defined NAV2_CLIENT_SERIES60_V3
   TInt urlLen = aUrl.Length();
   HBufC* fixedUrl;

   if (KFourHttpString().Compare(aUrl.Left(KFourHttpString().Length()))) {
      /* Not 4 http:// at the beginning. */

      if (KHttpString().Compare(aUrl.Left(KHttpString().Length()))) {
         /* Not http:// at the beginning. */
         urlLen += KFourHttpString().Length() + 1;
         fixedUrl = HBufC::NewLC(urlLen);
         fixedUrl->Des().Copy(KFourHttpString);
      } else {
         urlLen += KFourString().Length() + 1;
         fixedUrl = HBufC::NewLC(urlLen);
         fixedUrl->Des().Copy(KFourString);
      }
      fixedUrl->Des().Append(aUrl);
   } else {
      fixedUrl = aUrl.AllocLC();
   }

   RApaLsSession aApaLsSession;

   TUid id( KPhoneUidWmlBrowser );
   TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
   TApaTask task = taskList.FindApp( id );

   if ( task.Exists() ) {
      HBufC8* param8 = HBufC8::NewLC( fixedUrl->Length() );
      param8->Des().Append( *fixedUrl );
      task.SendMessage( TUid::Uid( 0 ), *param8 ); // UID is not used
      CleanupStack::PopAndDestroy( param8 );
   } else {
      if ( !aApaLsSession.Handle() )
      {
         User::LeaveIfError( aApaLsSession.Connect() );
      }
      TThreadId thread;
      User::LeaveIfError( aApaLsSession.StartDocument( *fixedUrl,
               KPhoneUidWmlBrowser, thread ) );
   }
   CleanupStack::PopAndDestroy(fixedUrl);

   aApaLsSession.Close();

#elif defined NAV2_CLIENT_SERIES60_V1
   return EFalse;
#else
# error This code not implemented!
#endif
   return ETrue;
}
开发者ID:VLjs,项目名称:Wayfinder-S60-Navigator,代码行数:56,代码来源:LaunchWapBrowserUtil.cpp

示例12: ParseAttributedKeyL

// ---------------------------------------------------------------------------
//  Fails only on OOM case
// ---------------------------------------------------------------------------
//
void CPosModulesSettings::ParseAttributedKeyL( 
	const TDesC& aString, 
	RModuleList& aList ) const
	{
    // The sequence in the buffer is "H{8},D+,D+[,...]" 
    // which is "UID,status,cost"
    // H - hex digit, D - decimal digit, delimiter - comma
    // UID check is strict and fails with KErrCorrupt if something's wrong
    // Status and Cost checks a lazy, use default value if error
    // Status - inactive, cost - unknown
    
    // TLex uses whitespace as delimiter
    // Replace all commas with whitespace
    HBufC* string = aString.AllocLC();
    ReplaceCommasWithWhitespace( string->Des() );
    
    TLex lex( *string );
    while ( !lex.Eos() )
        {
        TPosModuleListItem item;
    
        // parse UID
        TPtrC token( lex.NextToken() );
        if ( !token.Length() )
            {
            break;  // no more items found
            }
        
        item.iUid.iUid = 0;
        TInt err = ParseModuleUid( token, (TUint32&) item.iUid.iUid );

        // parse status field
        token.Set( lex.NextToken() );
        err |= TLex( token ).Val( (TUint&) item.iAvailable, EDecimal );

        if ( item.iAvailable != EModuleAvailable && 
        	 item.iAvailable != EModuleNotAvailable )
        	 {
        	 err |= KErrCorrupt;
        	 }

        // parse cost field
        token.Set( lex.NextToken() );
        err |= TLex( token ).Val( (TUint&) item.iCost, EDecimal );

        // Avoid duplicate UIDs ( in both lists )
        TPosModuleAttributes otherItem;
        if ( !err && !ModuleExists( item.iUid ) )
            {
	        // Add module list item to the list
	        aList.AppendL( item );
            }
        }
        
	CleanupStack::PopAndDestroy( string );
	}
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:60,代码来源:epos_cposmodulessettings.cpp

示例13: NewTestL

// Call this when you're starting a new test
void CTOCSPResult::NewTestL(const TDesC& aName)
{
    CheckL();

    HBufC* name = aName.AllocLC();
    User::LeaveIfError(iNames.Append(name));
    CleanupStack::Pop(name);

    iTotal++;
}
开发者ID:kuailexs,项目名称:symbiandump-mw3,代码行数:11,代码来源:result.cpp

示例14: ReplyToMeetingRequestL

/**
 * Create and send a MR response email.
 */
EXPORT_C void CBaseMrInfoProcessor::ReplyToMeetingRequestL(
    const TFSMailMsgId& aMailBoxId,
    const TFSMailMsgId& aMessageId,
    MMRInfoObject& aMeetingRequest,
    TMRInfoResponseMode& aResponseMode,
    const TDesC& aResponseText /*= KNullDesC()*/ )

    {
    if ( MMRInfoProcessor::EMRInfoResponseSync != aResponseMode )
        {
        CFSMailMessage* reply = iPlugin.CreateMrReplyMessageL(
            aMailBoxId, aMeetingRequest, aMessageId );
        CleanupStack::PushL( reply );
        
        //body.
        if ( aResponseText != KNullDesC )
            {
            CFSMailMessagePart* body = reply->PlainTextBodyPartL();
            if ( NULL != body )
                {
                CleanupStack::PushL( body );
                
                /**@ completely unnecessary but the fw needs to accept a TDesC in
                SetContent instead.*/
                HBufC* descCopy = aResponseText.AllocLC();
                TPtr ptr = descCopy->Des();
                body->SetContent( ptr );
                
                CleanupStack::PopAndDestroy( descCopy );
                CleanupStack::PopAndDestroy( body );
                }
            }
        
        CBaseMrInfoObject* mrInfo = CBaseMrInfoObject::NewL( aMeetingRequest );
    
        if ( MMRInfoProcessor::EMRInfoRemoveFromCal == aResponseMode )
        	{
        	mrInfo->SetMethod( MMRInfoObject::EMRMethodCancel );
        	}
        else
        	{
        	mrInfo->SetMethod( MMRInfoObject::EMRMethodResponse );
        	}
    
        reply->SetMRInfo( mrInfo );
        iPlugin.SendMessageL( *reply );
    
        CleanupStack::PopAndDestroy( reply );
        }
    	
    } //ReplyToMeetingRequestL.
开发者ID:cdaffara,项目名称:symbiandump-ossapps,代码行数:54,代码来源:BaseMrInfoObject.cpp

示例15: BISetDatabaseNameL

void CLogServBackupManager::BISetDatabaseNameL(const TDesC& aDatabaseName)
{
#ifdef LOGGING_ENABLED
    LOGTEXT3("CLogServBackupManager::BISetDatabaseNameL(%S, isActive: %d)", &aDatabaseName, IsActive());
    if	(iDatabaseName)
    {
        LOGTEXT2("CLogServBackupManager::BISetDatabaseNameL() - currently registered database filename is: %S", iDatabaseName);
    }
    else
    {
        LOGTEXT("CLogServBackupManager::BISetDatabaseNameL() - no file registered with backup interface yet");
    }
#endif

    Cancel();

    HBufC* databaseName = aDatabaseName.AllocLC();

    // If we haven't already created a backup observer, then we need
    // to kick the object back into life again.
    if	(!iBackup)
    {
        LOGTEXT("CLogServBackupManager::BISetDatabaseNameL() - no backup session created");

        // Try and create backup interface synchronously first of all, if that fails
        // then construct as an idle operation
        TRAPD(err, iBackup = CreateBackupL(*databaseName));

        LOGTEXT2("CLogServBackupManager::BISetDatabaseNameL() - backup session creation error: %d", err);
        if	(err != KErrNone)
            After(0);
    }
    else if (iDatabaseName->Compare(aDatabaseName) != KErrNone)
    {
        LOGTEXT3("CLogServBackupManager::BISetDatabaseNameL() - database filename changed from %S to %S", &iDatabaseName, &aDatabaseName);

        // De register the old, register the new
        iBackup->DeregisterFile(*iDatabaseName);
        iBackup->RegisterFileL(aDatabaseName, *this);

        LOGTEXT("CLogServBackupManager::BISetDatabaseNameL() - database re-registration complete");
    }


    delete iDatabaseName;
    iDatabaseName = databaseName;
    CleanupStack::Pop(databaseName);

    LOGTEXT("CLogServBackupManager::BISetDatabaseNameL() - end");
}
开发者ID:kuailexs,项目名称:symbiandump-os2,代码行数:50,代码来源:LogServBackupManager.cpp


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