Update contrib.
2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
24 #ifndef STREAMABLEPTRARRAY_INL
25 #define STREAMABLEPTRARRAY_INL
27 namespace ContentAccess
30 inline RStreamablePtrArray<T>::RStreamablePtrArray()
35 inline void RStreamablePtrArray<T>::Close()
37 iArray.ResetAndDestroy();
41 inline void RStreamablePtrArray<T>::AppendL(T* aElement)
43 User::LeaveIfError(iArray.Append(aElement));
47 inline TInt RStreamablePtrArray<T>::Count() const
49 return iArray.Count();
53 inline T* RStreamablePtrArray<T>::operator [] (TInt aIndex) const
55 // case the value from the array back to its original type
56 return iArray[aIndex];
60 inline void RStreamablePtrArray<T>::ResetAndDestroy()
62 iArray.ResetAndDestroy();
66 inline void RStreamablePtrArray<T>::InternalizeL(RReadStream& aStream)
70 // Read the number of CMetaData objects from the stream
71 TInt count = aStream.ReadInt32L();
73 // Read the objects from the stream and add them to the array
74 for(i = 0; i < count; i++)
76 // create a new T object from the stream using the supplied factory function
77 T* element = T::NewL(aStream);
78 CleanupStack::PushL(element);
82 // Finished with cleanup stack, element now owned by the array so don't delete
83 CleanupStack::Pop(element);
88 inline void RStreamablePtrArray<T>::ExternalizeL(RWriteStream& aStream) const
91 // Write the total number of elements to the stream
92 aStream.WriteInt32L(iArray.Count());
94 // Ask the array elements to write themselves to the stream one by one
95 for(i = 0; i < iArray.Count();i++)
97 iArray[i]->ExternalizeL(aStream);
102 inline void RStreamablePtrArray<T>::RemoveL(TInt aIndex)
104 if ( (aIndex >= iArray.Count()) || (aIndex < 0) )
106 User::Leave(KErrArgument);
108 iArray.Remove(aIndex);
112 #endif // STREAMABLEPTRARRAY_INL