|
1 /* |
|
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Utility functions for copying and streaming RArray/RpointerArray. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalTechnology |
|
23 @prototype |
|
24 */ |
|
25 |
|
26 #ifndef STREAMINGARRAY_H |
|
27 #define STREAMINGARRAY_H |
|
28 |
|
29 #include <e32std.h> |
|
30 #include <s32strm.h> |
|
31 |
|
32 |
|
33 // RPointerArray utilities |
|
34 |
|
35 /** |
|
36 Copy a pointer array of template objects to another one. |
|
37 Note that only objects are copied into the target array, NOT pointers. |
|
38 T class must provide a static T::NewL(T&) construction function. |
|
39 @param aTarget The pointer array to which a given array will be copied. |
|
40 @param aSource The pointer array which will be copied. |
|
41 */ |
|
42 template <class T> |
|
43 void CopyPointerArrayL(RPointerArray<T>& aTarget, const RPointerArray<T>& aSource); |
|
44 |
|
45 /** |
|
46 Externalize an array of pointers of template class. |
|
47 @param aArray The pointer array which will be externalized |
|
48 @param aAddLength Whether the length of the array is added to the beginning of the externalized data. |
|
49 @return Pointer to the memory of the externalized array which is left on |
|
50 the cleanup stack. Ownership is transferred. |
|
51 |
|
52 */ |
|
53 template <class T> |
|
54 HBufC8* ExternalizePointersArrayLC(const RPointerArray<T>& aArray, TBool aAddLength=ETrue); |
|
55 |
|
56 /** |
|
57 Externalize an array of pointers of template class. |
|
58 @param aArray The pointer array which will be externalized. |
|
59 @param aStream A stream to the buffer where the pointer array will be externalized. |
|
60 @param aAddLength Whether the length of the array is added to the beginning of the externalized data. |
|
61 */ |
|
62 template <class T> |
|
63 void ExternalizePointersArrayL(const RPointerArray<T>& aArray, RWriteStream& aStream, TBool aAddLength=ETrue); |
|
64 |
|
65 /** |
|
66 Internalize a given externalized pointers array stream. |
|
67 Template class must provide a static T::NewL(RReadStream&) function. |
|
68 @param aArray The pointer array which the stream will be internalized into. |
|
69 @param aStream A stream to the externalized pointer array |
|
70 @param aAddLength Whether the length of the array exists at the beginning of the data being internalized. |
|
71 */ |
|
72 template <class T> |
|
73 void InternalizePointersArrayL(RPointerArray<T>& aArray, RReadStream& aStream, TBool aAddLength=ETrue); |
|
74 |
|
75 |
|
76 // RArray utilities |
|
77 |
|
78 /** |
|
79 Copy an array of fixed length template objects to another one. |
|
80 Note that T must have a valid copy c'tor. |
|
81 @param aTarget The array to which a given array will be copied. |
|
82 @param aSource The array which will be copied. |
|
83 */ |
|
84 template <class T> |
|
85 void CopyFixedLengthArrayL(RArray<T>& aTarget, const RArray<T>& aSource); |
|
86 |
|
87 |
|
88 /** |
|
89 Externalize an array of fixed length template objects. |
|
90 @param aArray The array which will be externalized. |
|
91 @return Pointer to the memory of the externalized array which is left on |
|
92 the cleanup stack. Ownership is transferred. |
|
93 */ |
|
94 template <class T> |
|
95 HBufC8* ExternalizeFixedLengthArrayLC(const RArray<T>& aArray); |
|
96 |
|
97 /** |
|
98 Externalize an array of fixed length template objects. |
|
99 @param aArray The array which will be externalized. |
|
100 @param aStream A stream to the buffer where the fixed length array will be externalized. |
|
101 */ |
|
102 template <class T> |
|
103 void ExternalizeFixedLengthArrayL(const RArray<T>& aArray, RWriteStream& aStream); |
|
104 |
|
105 /** |
|
106 Internalize a given externalized fixed length array stream. |
|
107 @param aArray The pointer array which the stream will be internalized into. |
|
108 @param aStream A stream to the externalized fixed length array |
|
109 */ |
|
110 template <class T> |
|
111 void InternalizeFixedLengthArrayL(RArray<T>& aArray, RReadStream& aStream); |
|
112 |
|
113 #include <scs/streamingarray.inl> |
|
114 |
|
115 #endif // STREAMINGARRAY_H |