本文整理汇总了C++中CArrayFix::Count方法的典型用法代码示例。如果您正苦于以下问题:C++ CArrayFix::Count方法的具体用法?C++ CArrayFix::Count怎么用?C++ CArrayFix::Count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CArrayFix
的用法示例。
在下文中一共展示了CArrayFix::Count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
LOCAL_C void test1(CArrayFix<TText>& aFix)
//
{
test.Next(_L("AppendL and InsertL single chars"));
aFix.AppendL(_S("abcd"),4);
test(aFix[0]=='a');
test(aFix[1]=='b');
test(aFix[3]=='d');
test(aFix.Count()==4);
aFix.InsertL(2,_S("ef"),2);
test(aFix[1]=='b');
test(aFix[2]=='e');
test(aFix[4]=='c');
test(aFix.Count()==6);
aFix.AppendL(TText('z'));
test(aFix[6]=='z');
aFix.InsertL(0,TText('y'));
test(aFix[0]=='y');
test(aFix[1]=='a');
test(aFix.Count()==8);
test.Next(_L("Delete single chars"));
aFix.Delete(3);
test(aFix[2]=='b');
test(aFix[3]=='f');
test(aFix[4]=='c');
aFix.Delete(1,2);
test(aFix[0]=='y');
test(aFix[1]=='f');
test(aFix[2]=='c');
test(aFix.Count()==5);
aFix.Compress();
}
示例2:
// ---------------------------------------------------------
// FavouritesUtil::ExternalizeL
// ---------------------------------------------------------
//
void FavouritesUtil::ExternalizeL
( const CArrayFix<TInt>& aArray, RWriteStream& aStream )
{
aStream.WriteInt32L( aArray.Count() );
for ( TInt i = 0; i < aArray.Count(); i++ )
{
aStream.WriteInt32L( aArray[ i ] );
}
}
示例3: GetAvailableHeightsInTwipsAndPointsL
EXPORT_C TInt FontUtils::GetAvailableHeightsInTwipsAndPointsL(const CGraphicsDevice& aDevice,const TDesC& aTypefaceName,CArrayFix<TInt>& aTwipsList,CDesCArray& aPointsList)
/** Gets a list of all heights in twips, available for the named typeface and the
graphics device specified.
Also gets a list of heights in points, represented as character strings.
@param aDevice The graphics device.
@param aTypefaceName The name of the typeface.
@param aTwipsList On return, contains all available heights for the typeface,
in twips.
@param aPointsList On return, the heights in points, represented as character
strings.
@return KErrNotSupported if the named typeface is not supported by the graphics
device, otherwise KErrNone. */
{ // static
aTwipsList.Reset();
aPointsList.Reset();
TInt err=GetAvailableHeightsInTwipsL(aDevice,aTypefaceName,aTwipsList);
if (err==KErrNotSupported)
return err;
const TInt count=aTwipsList.Count();
for (TInt ii=0;ii<count;ii++)
{
const TInt points=PointsFromTwips(aTwipsList[ii]);
if (points<EMinFontHeight)
continue;
TBuf<8> num;
num.Num(points);
aPointsList.AppendL(num);
}
return KErrNone;
}
示例4: ExportItemL
// -----------------------------------------------------------------------------
// CPIMAgnToDoAdapter::ExportItemL
// (other items were commented in a header)
// -----------------------------------------------------------------------------
//
void CPIMAgnToDoAdapter::ExportItemL(const MPIMToDoItem& aItem,
CCalEntry& aEntry, TBool aResetEntry)
{
JELOG2(EPim);
if (aResetEntry)
{
// Reset native entry for exporting new data
aEntry.SetSummaryL(KNullDesC());
aEntry.SetDescriptionL(KNullDesC());
aEntry.SetPriorityL(0);
aEntry.SetCompletedL(EFalse, aEntry.CompletedTimeL());
}
// Export item data to the native ToDo calendar entry
const MPIMItemData& itemData = aItem.ItemData();
CArrayFix<TPIMField>* fields = itemData.FieldsLC();
// Add default values to the calendar entry
AddDefaultValuesToEntryL(itemData, aEntry);
// Convert each field to the native ToDo calendar entry
TInt count = fields->Count();
for (TInt i = 0; i < count; i++)
{
TPIMToDoField field = static_cast<TPIMToDoField>(fields->At(i));
ConvertToAgnL(field, aEntry, itemData);
}
CleanupStack::PopAndDestroy(fields);
}
示例5: 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;
}
示例6: ConvertExceptionDatesL
// -----------------------------------------------------------------------------
// CPIMEventPropertyConverter::ConvertExceptionDatesL
// Inserts exceptiondates to a parser.
// -----------------------------------------------------------------------------
//
void CPIMEventPropertyConverter::ConvertExceptionDatesL(const CArrayFix<
TPIMDate>& aDates, CParserVCalEntity& aParser)
{
JELOG2(EPim);
TInt exDateCount = aDates.Count();
if (exDateCount > 0)
{
CArrayPtrFlat<TVersitDateTime>* versitExDates =
new(ELeave) CArrayPtrFlat<TVersitDateTime> (exDateCount);
CleanupStack::PushL(versitExDates);
CleanupResetAndDestroyPushL(*versitExDates);
for (TInt i = 0; i < exDateCount; i++)
{
TVersitDateTime
* versitDateTime =
new(ELeave) TVersitDateTime(aDates.At(i).DateTime(), TVersitDateTime::EIsUTC);
CleanupDeletePushL(versitDateTime);
versitExDates->AppendL(versitDateTime);
CleanupStack::Pop(versitDateTime); // versitDateTime
}
CParserPropertyValue* propertyValue =
new(ELeave) CParserPropertyValueMultiDateTime(versitExDates);
CleanupStack::Pop(2); // versitExDates is now owned by propertyValue
AddPropertyToParserL(propertyValue, KVersitTokenEXDATE(), aParser);
// Needed cleanup stack items are popped out in the AddPropretyToParserL
}
}
示例7: ConvertFieldsToAgnL
// -----------------------------------------------------------------------------
// CPIMAgnEventAdapter::ConvertFieldsToAgnL
// Reads PIM Item fields and converts them into Agenda entry's fields.
// -----------------------------------------------------------------------------
//
void CPIMAgnEventAdapter::ConvertFieldsToAgnL(const MPIMEventItem& aItem,
CCalEntry& aEntry)
{
JELOG2(EPim);
CArrayFix<TPIMField>* fields = aItem.ItemData().FieldsLC();
TInt amount = fields->Count();
for (int i = 0; i < amount; i++)
{
TPIMEventField field = static_cast<TPIMEventField>(fields->At(i));
switch (field)
{
case EPIMEventSummary: // Fallthrough
case EPIMEventLocation: // Fallthrough
case EPIMEventNote:
{
ConvertStringFieldToAgnL(aItem, aEntry, field);
break;
}
case EPIMEventAlarm:
{
ConvertAlarmToAgnL(aItem, aEntry);
break;
}
case EPIMEventStart: // Fallthrough
case EPIMEventEnd:
{
ConvertDateFieldToAgnL(aItem, aEntry, field);
break;
}
case EPIMEventClass:
{
ConvertClassToAgnL(aItem, aEntry);
break;
}
case EPIMEventRevision: // fallthrough
case EPIMEventUid:
{
// nothing
break;
}
default:
{
User::Leave(KErrArgument);
}
}
}
CleanupStack::PopAndDestroy(fields);
}
示例8: GetRepeatRuleFieldsL
// -----------------------------------------------------------------------------
// CPIMEventPropertyConverter::GetRepeatRuleFieldsL
// Gets the fields from a repeat rule
// -----------------------------------------------------------------------------
//
void CPIMEventPropertyConverter::GetRepeatRuleFieldsL(
const MPIMRepeatRuleData* aRepeat, // Fields are read from this
TInt* aInterval, // interval is stored here
TInt* aFrequency, // frequency is stored here
TVersitDateTime** aVersitEndDate) // end date is stored here
{
JELOG2(EPim);
TBool endExists = EFalse;
CArrayFix<TPIMField>* repeatFields = aRepeat->GetFieldsL();
CleanupStack::PushL(repeatFields);
TInt fieldCount = repeatFields->Count();
for (TInt i = 0; i < fieldCount; i++)
{
switch (repeatFields->At(i))
{
case EPIMRepeatRuleFrequency:
{
*aFrequency = aRepeat->GetIntL(EPIMRepeatRuleFrequency);
break;
}
case EPIMRepeatRuleInterval:
{
*aInterval = aRepeat->GetIntL(EPIMRepeatRuleInterval);
break;
}
case EPIMRepeatRuleEnd:
{
endExists = ETrue;
break;
}
default:
{
// We ignore other fields
}
}
}
CleanupStack::PopAndDestroy(repeatFields);
if (endExists)
{
TPIMDate endDate = aRepeat->GetDateL(EPIMRepeatRuleEnd);
*aVersitEndDate
= new(ELeave) TVersitDateTime(endDate.DateTime(), TVersitDateTime::EIsUTC);
}
}
示例9: FindLargestLocallyCreated
TInt TDmAdUtil::FindLargestLocallyCreated(const CArrayFix<TSmlDmMappingInfo>& aPreviousUriSegmentList)
{
TRACE("TDmAdUtil::FindLargestLocallyCreated");
TInt largest = 0;
for (TInt i=0; i < aPreviousUriSegmentList.Count(); i++)
{
const TSmlDmMappingInfo& mappingInfo = aPreviousUriSegmentList.At(i);
if (mappingInfo.iURISeg.Find(KDmAdLocallyCreatedRtNodeUriSegPrefix) == 0)
{
TPtrC8 numberPart(mappingInfo.iURISeg.Mid(KDmAdLocallyCreatedRtNodeUriSegPrefix().Length()));
TInt number = TDmAdUtil::DesToInt(numberPart);
if (number > largest)
{
largest = number;
}
}
}
return largest;
}
示例10: IndexOfNearestHeight
EXPORT_C TInt FontUtils::IndexOfNearestHeight(CArrayFix<TInt>& aTwipsList,TInt aHeight)
/** Gets the index into the supplied list of font heights of the closest
match to the font height specified.
@param aTwipsList The twips list.
@param aHeight The requested font height. This may be generated by a call to GetAvailableHeightsInTwipsL()
or GetAvailableHeightsInTwipsAndPointsL().
@return The index into the list of the closest font height to aHeight. */
{ // static
TInt pos=0;
const TInt count=aTwipsList.Count();
for (TInt ii=0; ii<count; ii++)
{
if (aTwipsList[ii]>aHeight)
break;
pos=ii;
}
return pos;
}
示例11: GetPointListFromConfigL
TBool CDataWrapperBase::GetPointListFromConfigL(const TDesC& aSectName, const TDesC& aKeyName, CArrayFix<TPoint>& aResult)
{
TBuf<KMaxTestExecuteCommandLength> tempStore;
TPoint point;
aResult.Reset();
TBool ok=ETrue;
for ( TInt index=0; ok; )
{
tempStore.Format(KFormatFieldNumber, &aKeyName, ++index);
ok=GetPointFromConfig(aSectName, tempStore, point);
if ( ok )
{
aResult.AppendL(point);
}
}
return aResult.Count()>0;
}
示例12: GetContactIdsL
/**
Convert between view indexes and contact ids.
This method makes the request to the server.
@capability ReadUserData
*/
void RContactRemoteView::GetContactIdsL(const CArrayFix<TInt>& aIndexes, CContactIdArray& aContactIds)
{
CBufBase* buffer = CBufFlat::NewL(32);
CleanupStack::PushL(buffer);
RBufWriteStream writeStream(*buffer);
CleanupClosePushL(writeStream);
const TInt count = aIndexes.Count();
writeStream.WriteUint32L(count);
for (TInt i=0; i<count; ++i)
{
writeStream.WriteUint32L(aIndexes[i]);
}
writeStream.CommitL();
CleanupStack::PopAndDestroy(&writeStream); //writeStream.Close()
TPtr8 indexes(buffer->Ptr(0));
const TInt bufferSize = buffer->Size();
TPckg<TInt> size(bufferSize);
HBufC8* buf=HBufC8::NewLC(bufferSize);
TPtr8 ids(buf->Des());
TIpcArgs args(&size, &indexes, &ids);
User::LeaveIfError(SendReceive(ECntGetContactIds,args));
RDesReadStream readStream(ids);
CleanupClosePushL(readStream);
CContactIdArray* array = CContactIdArray::NewLC();
readStream >> *array;
const TInt arrayCount = array->Count();
for(TInt loop=0;loop<arrayCount;loop++)
aContactIds.AddL((*array)[loop]);
CleanupStack::PopAndDestroy(4,buffer); //array, &readStream, buf, buffer
}
示例13: caNamePtr
RPointerArray<CX509Certificate> PkiUtil::GetCaCertListL(RPKIServiceAPI& aPkiService,
const CArrayFixFlat<TCertInfo*>& aIkeCAList)
{
__ASSERT_ALWAYS(aIkeCAList.Count() > 0, User::Invariant());
_LIT8(KEmptyString, "");
RPointerArray<CX509Certificate> certificateArray;
ResetAndDestroyPushL(certificateArray);
RArray<TUid> applUidArray;
CleanupClosePushL(applUidArray);
for (TInt i = 0; i < aIkeCAList.Count(); ++i)
{
const TCertInfo* certInfo = aIkeCAList[i];
switch(certInfo->iFormat)
{
case CA_NAME:
{
// Reserve enough space for UTF-8
TInt len = 3*( certInfo->iData.Length() );
HBufC8* caName = HBufC8::NewLC(len);
TPtr8 caNamePtr(caName->Des());
if (CnvUtfConverter::ConvertFromUnicodeToUtf8(caNamePtr, certInfo->iData) != 0)
{
User::Leave(KErrCorrupt);
}
CX509Certificate* cert = ReadCertificateLC(aPkiService,
KEmptyString,
*caName,
KEmptyString,
EPKICACertificate);
User::LeaveIfError(certificateArray.Append(cert));
CleanupStack::Pop(cert);
CleanupStack::PopAndDestroy(caName);
}
break;
case KEY_ID:
{
TPKIKeyIdentifier keyId(NULL);
for (TInt j = 0; j < certInfo->iData.Length(); j += 2)
{
TPtrC hexByte(certInfo->iData.Mid(j, 2));
TLex lex(hexByte);
TUint8 value;
User::LeaveIfError(lex.Val(value, EHex));
keyId.Append(&value, 1);
}
CX509Certificate* cert = ReadCertificateLC(aPkiService,
keyId);
User::LeaveIfError(certificateArray.Append(cert));
CleanupStack::Pop(cert);
}
break;
case APPL_UID:
{
TLex lex(certInfo->iData);
TUint32 value;
User::LeaveIfError(lex.Val(value, EHex));
TUid id = { value };
User::LeaveIfError(applUidArray.Append(id));
}
break;
default:
User::Leave(KErrArgument);
break;
}
}
if (applUidArray.Count() > 0)
{
CArrayFix<TCertificateListEntry>* certListArray = NULL;;
aPkiService.ListApplicableCertificatesL(applUidArray, certListArray);
CleanupStack::PushL(certListArray);
if (certListArray->Count() == 0)
{
User::Leave(KErrNotFound);
}
for (TInt i = 0; i < certListArray->Count(); ++i)
{
TCertificateListEntry entry = (*certListArray)[i];
if (entry.iOwnerType == EPKICACertificate)
{
CX509Certificate* cert = ReadCertificateLC(aPkiService,
KEmptyString,
entry.iIdentitySubjectName,
KEmptyString,
EPKICACertificate);
User::LeaveIfError(certificateArray.Append(cert));
CleanupStack::Pop(cert);
}
}
//.........这里部分代码省略.........
示例14: BuildRtNodeChildUriListL
DMAD_EXPORT_C void TDmAdUtil::BuildRtNodeChildUriListL(MDmAdCallBack* aDmAdCallBack,
MDmAdStoreApi* aStoreApi,
const TDesC8& aUri,
const TDesC8& aParentLuid,
const CArrayFix<TSmlDmMappingInfo>& aPreviousUriSegmentList,
CBufBase& aCurrentList)
{
#ifdef DMAD_DUMP_PREVIOUS_URI_SEGMENT_LIST
DEBUG_LOG(_L("BuildRtNodeChildUriListL:"));
{
for (TInt i=0; i < aPreviousUriSegmentList.Count(); i++)
{
const TSmlDmMappingInfo& mappingInfo = aPreviousUriSegmentList.At(i);
DEBUG_LOG1(_L("entry %d:"), i);
DEBUG_LOG1(_L8("Uri: %S"), &(mappingInfo.iURISeg));
DEBUG_LOG_HEX(mappingInfo.iURISegLUID);
}
}
#endif
RPointerArray<HBufC8> luidList;
CleanupStack::PushL(TCleanupItem(PointerArrayCleanup, &luidList));
aStoreApi->LuidListL(aUri, aParentLuid, luidList);
// Finds largest number used in cli<x> named nodes.
TInt largest = FindLargestLocallyCreated(aPreviousUriSegmentList);
DEBUG_LOG1(_L("largest is cli%d"), largest);
TInt countLuidList = luidList.Count();
for (TInt j=0; j < countLuidList; j++)
{
const HBufC8* luidElem = luidList[j];
HBufC8* uriSeg = 0;
//Tries to find the luid from the aPreviousUriSegmentList
for (TInt i=0; i < aPreviousUriSegmentList.Count(); i++)
{
const TSmlDmMappingInfo& mappingInfo = aPreviousUriSegmentList.At(i);
if (mappingInfo.iURISegLUID.Compare(*luidElem) == 0)
{
uriSeg = mappingInfo.iURISeg.AllocLC();
break;
}
}
if (uriSeg == 0)
{
//Uri was not found from the aPreviousUriSegmentList
uriSeg = BuildLocallyCreatedRtNodeUriSegLC(largest);
DEBUG_LOG2(_L8("uriSeg %S, largest %d"), uriSeg, largest);
HBufC8* wholeUri = TDmAdUtil::BuildUriLC(aUri, *uriSeg);
aDmAdCallBack->SetMappingL(*wholeUri, *luidElem);
CleanupStack::PopAndDestroy(); //wholeUri
}
//If this is not the first element, inserts slash at the beginning
//of the result list.
if (j > 0)
{
aCurrentList.InsertL(aCurrentList.Size(), KDmAdSeparator);
}
aCurrentList.InsertL(aCurrentList.Size(), *uriSeg);
CleanupStack::PopAndDestroy(); // uriSeg
}
CleanupStack::PopAndDestroy(); //luidList
}
示例15: TestGetBodyTextL
LOCAL_C TBool TestGetBodyTextL()
{
__UHEAP_MARK;
// Retrieve the store from the current context...
CMsvStore* store = pContext->EditStoreL();
CleanupStack::PushL(store);
// Populate CMsvBodyText from the data in the store...
CMsvBodyText* obj = CMsvBodyText::NewLC();
obj->RestoreL(*store);
// Create a rich text object...
CParaFormatLayer* paraLayer = CParaFormatLayer::NewL();
CleanupStack::PushL(paraLayer);
CCharFormatLayer* charLayer = CCharFormatLayer::NewL();
CleanupStack::PushL(charLayer);
CRichText* richText = CRichText::NewL(paraLayer, charLayer);
CleanupStack::PushL(richText);
// Create an array of available character sets...
CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* charSets;
CCnvCharacterSetConverter* converter = CCnvCharacterSetConverter::NewL();
CleanupStack::PushL(converter);
charSets = converter->CreateArrayOfCharacterSetsAvailableLC(gFs);
// For each available character set, call GetBodyTextL...
TInt i;
for (i = 0; i < charSets->Count(); i++)
{
// Over-ride the stored character set.
obj->SetCharacterSet((*charSets)[i].Identifier());
// Convert the 8 bit data to the specified character set.
obj->GetBodyTextL(gFs, *store, *richText);
test(richText->HasChanged());
richText->Reset();
}
// Instead of decoding 10 bytes of data, increase the amount of data to 4000 bytes.
obj->SetCharacterSet(0);
obj->SetDefaultCharacterSet((*charSets)[0].Identifier());
const TInt KTextBufferSize=4000;
CBufBase *buffer=CBufFlat::NewL(KTextBufferSize);
CleanupStack::PushL(buffer);
while(buffer->Size()<KTextBufferSize)
{
buffer->InsertL(buffer->Size(),K10BytesData);
}
obj->StoreL(*store, *buffer);
CleanupStack::PopAndDestroy(buffer);
store->CommitL();
obj->RestoreL(*store);
obj->GetBodyTextL(gFs, *store, *richText);
test(richText->HasChanged());
// Clean up and release resources...
CleanupStack::PopAndDestroy(charSets);
CleanupStack::PopAndDestroy(converter);
CleanupStack::PopAndDestroy(richText);
CleanupStack::PopAndDestroy(charLayer);
CleanupStack::PopAndDestroy(paraLayer);
CleanupStack::PopAndDestroy(obj);
CleanupStack::PopAndDestroy(store);
__UHEAP_MARKEND;
return ETrue;
}