1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 // |
7 // |
8 // Initial Contributors: |
8 // Initial Contributors: |
9 // Nokia Corporation - initial contribution. |
9 // Nokia Corporation - initial contribution. |
10 // |
10 // |
11 // Contributors: |
11 // Contributors: |
50 private: |
50 private: |
51 TUint8* iBase; |
51 TUint8* iBase; |
52 }; |
52 }; |
53 |
53 |
54 /** |
54 /** |
55 * @publishedAll |
55 * @publishedAll |
56 * @released |
56 * @released |
57 * A stream buffer that uses a descriptor for its implementation. |
57 * A stream buffer that uses a descriptor for its implementation. |
58 |
58 |
59 A stream of this type is used by RDesWriteStream and RDesReadStream objects. |
59 A stream of this type is used by RDesWriteStream and RDesReadStream objects. |
60 It also has intermediate buffering capabilities. |
60 It also has intermediate buffering capabilities. |
61 |
61 |
62 This is a seekable stream buffer. |
62 This is a seekable stream buffer. |
63 |
63 |
64 When used in write mode, the length of the descriptor is only updated when |
64 When used in write mode, the length of the descriptor is only updated when |
65 the stream buffer's SynchL() function is called, i.e. as a result of a call |
65 the stream buffer's SynchL() function is called, i.e. as a result of a call |
66 to RWriteStream::CommitL(). |
66 to RWriteStream::CommitL(). |
67 |
67 |
68 @see RDesWriteStream |
68 @see RDesWriteStream |
69 @see RDesReadStream |
69 @see RDesReadStream |
70 @see RWriteStream::CommitL() |
70 @see RWriteStream::CommitL() |
71 @see MStreamBuf::SynchL() |
71 @see MStreamBuf::SynchL() |
72 */ |
72 */ |
73 class TDesBuf : public TStreamBuf |
73 class TDesBuf : public TStreamBuf |
74 { |
74 { |
75 public: |
75 public: |
76 IMPORT_C TDesBuf(); |
76 IMPORT_C TDesBuf(); |
87 private: |
87 private: |
88 TDes8* iDes; |
88 TDes8* iDes; |
89 }; |
89 }; |
90 |
90 |
91 /** |
91 /** |
92 * @publishedAll |
92 * @publishedAll |
93 * @released |
93 * @released |
94 * A stream buffer that uses a dynamic buffer for its implementation. |
94 * A stream buffer that uses a dynamic buffer for its implementation. |
95 |
95 |
96 A stream of this type is used by RBufWriteStream and RBufReadStream objects. |
96 A stream of this type is used by RBufWriteStream and RBufReadStream objects. |
97 It also has intermediate buffering capabilities. |
97 It also has intermediate buffering capabilities. |
98 |
98 |
99 This is a seekable stream buffer. |
99 This is a seekable stream buffer. |
100 |
100 |
101 There are three write modes: |
101 There are three write modes: |
102 |
102 |
103 insert mode - inserts new data into the buffer at the offset passed to Set() |
103 insert mode - inserts new data into the buffer at the offset passed to Set() |
104 |
104 |
105 overwrite mode - replaces the data in the buffer starting at the offset passed |
105 overwrite mode - replaces the data in the buffer starting at the offset passed |
106 to Set(). Once the end of the buffer is reached, it is automatically extended |
106 to Set(). Once the end of the buffer is reached, it is automatically extended |
107 as more data is written. This is the default mode. |
107 as more data is written. This is the default mode. |
108 |
108 |
109 truncate mode - truncates the buffer to the offset passed to Set() before |
109 truncate mode - truncates the buffer to the offset passed to Set() before |
110 data is written, extending the buffer. When writing, the buffer size as reported |
110 data is written, extending the buffer. When writing, the buffer size as reported |
111 by CBufBase::Size() may be larger than the data written to the stream. To |
111 by CBufBase::Size() may be larger than the data written to the stream. To |
112 synchronise the buffer's reported size with the stream, call the MStreamBuf::SynchL() |
112 synchronise the buffer's reported size with the stream, call the MStreamBuf::SynchL() |
113 function. |
113 function. |
114 |
114 |
115 Note that this object never takes ownership of the dynamic buffer, the CBufBase |
115 Note that this object never takes ownership of the dynamic buffer, the CBufBase |
116 type object. |
116 type object. |
117 |
117 |
118 @see RBufWriteStream |
118 @see RBufWriteStream |
119 @see RBufReadStream |
119 @see RBufReadStream |
120 @see CBufBase::Size() |
120 @see CBufBase::Size() |
121 @see MStreamBuf::SynchL() |
121 @see MStreamBuf::SynchL() |
122 */ |
122 */ |
123 class TBufBuf : public TStreamBuf |
123 class TBufBuf : public TStreamBuf |
124 { |
124 { |
125 public: |
125 public: |
126 enum {ETruncate=0x10,EInsert=0x20}; |
126 enum {ETruncate=0x10,EInsert=0x20}; |
153 TInt iWPos; |
153 TInt iWPos; |
154 TInt iMode; |
154 TInt iMode; |
155 }; |
155 }; |
156 |
156 |
157 /** |
157 /** |
158 @publishedAll |
158 @publishedAll |
159 @released |
159 @released |
160 |
160 |
161 Supports the reading of a stream from a pointer of any type. |
161 Supports the reading of a stream from a pointer of any type. |
162 |
162 |
163 @see TMemBuf |
163 @see TMemBuf |
164 @see RReadStream |
164 @see RReadStream |
165 */ |
165 */ |
166 class RMemReadStream : public RReadStream |
166 class RMemReadStream : public RReadStream |
167 { |
167 { |
168 public: |
168 public: |
|
169 /** |
|
170 Constructs an empty object. |
|
171 |
|
172 Call Open() to prepare the stream for reading. |
|
173 */ |
169 RMemReadStream() {} |
174 RMemReadStream() {} |
170 IMPORT_C RMemReadStream(const TAny* aPtr,TInt aLength); |
175 IMPORT_C RMemReadStream(const TAny* aPtr,TInt aLength); |
171 IMPORT_C void Open(const TAny* aPtr,TInt aLength); |
176 IMPORT_C void Open(const TAny* aPtr,TInt aLength); |
172 private: |
177 private: |
173 TMemBuf iSource; |
178 TMemBuf iSource; |
174 }; |
179 }; |
175 |
180 |
176 /** |
181 /** |
177 @publishedAll |
182 @publishedAll |
178 @released |
183 @released |
179 |
184 |
180 Supports the writing of a stream to a pointer of any type. |
185 Supports the writing of a stream to a pointer of any type. |
181 |
186 |
182 @see TMemBuf |
187 @see TMemBuf |
183 @see RWriteStream |
188 @see RWriteStream |
184 */ |
189 */ |
185 class RMemWriteStream : public RWriteStream |
190 class RMemWriteStream : public RWriteStream |
186 { |
191 { |
187 public: |
192 public: |
|
193 /** |
|
194 Constructs an empty write stream object. |
|
195 |
|
196 Call Open() to prepare a stream for writing. |
|
197 */ |
188 RMemWriteStream() {} |
198 RMemWriteStream() {} |
189 inline RMemWriteStream(const MExternalizer<TStreamRef>& anExter); |
199 inline RMemWriteStream(const MExternalizer<TStreamRef>& anExter); |
190 IMPORT_C RMemWriteStream(TAny* aPtr,TInt aMaxLength); |
200 IMPORT_C RMemWriteStream(TAny* aPtr,TInt aMaxLength); |
191 IMPORT_C void Open(TAny* aPtr,TInt aMaxLength); |
201 IMPORT_C void Open(TAny* aPtr,TInt aMaxLength); |
192 private: |
202 private: |
193 TMemBuf iSink; |
203 TMemBuf iSink; |
194 }; |
204 }; |
195 |
205 |
196 /** |
206 /** |
197 @publishedAll |
207 @publishedAll |
198 @released |
208 @released |
199 |
209 |
200 Supports the reading of a stream from an 8-bit descriptor. |
210 Supports the reading of a stream from an 8-bit descriptor. |
201 |
211 |
202 @see TMemBuf |
212 @see TMemBuf |
203 @see RReadStream |
213 @see RReadStream |
204 */ |
214 */ |
205 class RDesReadStream : public RReadStream |
215 class RDesReadStream : public RReadStream |
206 { |
216 { |
207 public: |
217 public: |
|
218 /** |
|
219 Constructs an empty read stream object. |
|
220 |
|
221 Call Open() to prepare the stream for reading. |
|
222 */ |
208 RDesReadStream() {} |
223 RDesReadStream() {} |
209 IMPORT_C RDesReadStream(const TDesC8& aDes); |
224 IMPORT_C RDesReadStream(const TDesC8& aDes); |
210 IMPORT_C void Open(const TDesC8& aDes); |
225 IMPORT_C void Open(const TDesC8& aDes); |
211 private: |
226 private: |
212 TMemBuf iSource; |
227 TMemBuf iSource; |
213 }; |
228 }; |
214 |
229 |
215 /** |
230 /** |
216 @publishedAll |
231 @publishedAll |
217 @released |
232 @released |
218 |
233 |
219 Supports the writing of a stream to an 8-bit descriptor. |
234 Supports the writing of a stream to a stream buffer hosted by an 8-bit descriptor. |
220 |
235 |
221 @see TDesBuf |
236 @see TDesBuf |
222 @see RWriteStream |
237 @see RWriteStream |
223 */ |
238 */ |
224 class RDesWriteStream : public RWriteStream |
239 class RDesWriteStream : public RWriteStream |
225 { |
240 { |
226 public: |
241 public: |
|
242 /** |
|
243 Constructs an empty write stream object. |
|
244 |
|
245 Call Open() to prepare a stream for writing. |
|
246 */ |
227 RDesWriteStream() {} |
247 RDesWriteStream() {} |
228 inline RDesWriteStream(const MExternalizer<TStreamRef>& anExter); |
248 inline RDesWriteStream(const MExternalizer<TStreamRef>& anExter); |
229 IMPORT_C RDesWriteStream(TDes8& aDes); |
249 IMPORT_C RDesWriteStream(TDes8& aDes); |
230 IMPORT_C void Open(TDes8& aDes); |
250 IMPORT_C void Open(TDes8& aDes); |
231 private: |
251 private: |
232 TDesBuf iSink; |
252 TDesBuf iSink; |
233 }; |
253 }; |
234 |
254 |
235 /** |
255 /** |
236 @publishedAll |
256 @publishedAll |
237 @released |
257 @released |
238 |
258 |
239 Supports the reading of a stream from a dynamic buffer. |
259 Supports the opening of an existing stream hosted by a dynamic buffer. |
|
260 The stream does not take ownership of the dynamic buffer, which means |
|
261 that the creator is responsible for deleting the buffer when it is no |
|
262 longer needed. |
240 |
263 |
241 @see TBufBuf |
264 @see TBufBuf |
242 @see RReadStream |
265 @see RReadStream |
243 */ |
266 */ |
244 class RBufReadStream : public RReadStream |
267 class RBufReadStream : public RReadStream |
245 { |
268 { |
246 public: |
269 public: |
|
270 /** |
|
271 Constructs an empty read stream object. |
|
272 |
|
273 Call Open() to prepare the stream for reading. |
|
274 */ |
247 RBufReadStream() {} |
275 RBufReadStream() {} |
248 IMPORT_C RBufReadStream(const CBufBase& aBuf,TInt aPos=0); |
276 IMPORT_C RBufReadStream(const CBufBase& aBuf,TInt aPos=0); |
249 IMPORT_C void Open(const CBufBase& aBuf,TInt aPos=0); |
277 IMPORT_C void Open(const CBufBase& aBuf,TInt aPos=0); |
250 private: |
278 private: |
251 TBufBuf iSource; |
279 TBufBuf iSource; |
252 }; |
280 }; |
253 |
281 |
254 /** |
282 /** |
255 @publishedAll |
283 @publishedAll |
256 @released |
284 @released |
257 |
285 |
258 Supports the writing of a stream to a dynamic buffer. |
286 Supports the writing of a stream to a dynamic buffer. The stream does |
|
287 not take ownership of the dynamic buffer, which means that the creator |
|
288 is responsible for deleting the buffer when it is no longer needed. |
259 |
289 |
260 @see TBufBuf |
290 @see TBufBuf |
261 @see RWriteStream |
291 @see RWriteStream |
262 */ |
292 */ |
263 class RBufWriteStream : public RWriteStream |
293 class RBufWriteStream : public RWriteStream |
264 { |
294 { |
265 public: |
295 public: |
|
296 /** |
|
297 Default constructor. Constructs an empty write stream object. |
|
298 |
|
299 Call Open(), Truncate() or Insert() to prepare a stream for writing. |
|
300 */ |
266 RBufWriteStream() {} |
301 RBufWriteStream() {} |
|
302 |
267 inline RBufWriteStream(const MExternalizer<TStreamRef>& anExter); |
303 inline RBufWriteStream(const MExternalizer<TStreamRef>& anExter); |
268 IMPORT_C RBufWriteStream(CBufBase& aBuf,TInt aPos=0); |
304 IMPORT_C RBufWriteStream(CBufBase& aBuf,TInt aPos=0); |
269 IMPORT_C void Open(CBufBase& aBuf,TInt aPos=0); |
305 IMPORT_C void Open(CBufBase& aBuf,TInt aPos=0); |
270 IMPORT_C void Truncate(CBufBase& aBuf,TInt aPos=0); |
306 IMPORT_C void Truncate(CBufBase& aBuf,TInt aPos=0); |
271 IMPORT_C void Insert(CBufBase& aBuf,TInt aPos); |
307 IMPORT_C void Insert(CBufBase& aBuf,TInt aPos); |
273 private: |
309 private: |
274 TBufBuf iSink; |
310 TBufBuf iSink; |
275 }; |
311 }; |
276 |
312 |
277 /** |
313 /** |
278 * @publishedAll |
314 * @publishedAll |
279 * @released |
315 * @released |
280 * In-memory non-persistent store. The buffer store does not have a root stream |
316 * In-memory non-persistent store. The buffer store does not have a root stream |
281 and cannot be closed without losing all the data. |
317 and cannot be closed without losing all the data. |
282 |
318 |
283 It implements many of the operations defined by the store abstract framework. |
319 It implements many of the operations defined by the store abstract framework. |
284 Specifically, streams in this store can be: overwritten, replaced, appended, |
320 Specifically, streams in this store can be: overwritten, replaced, appended, |
285 deleted, and created in advance of being written to. However the class does |
321 deleted, and created in advance of being written to. However the class does |
286 not support commit and revert operations. |
322 not support commit and revert operations. |
287 |
323 |
288 Overwriting an existing stream can result in a shorter stream; however, a |
324 Overwriting an existing stream can result in a shorter stream; however, a |
289 stream cannot be extended beyond its original length. Replacing a stream can |
325 stream cannot be extended beyond its original length. Replacing a stream can |
290 result in a stream which is longer or shorter than the original. The order |
326 result in a stream which is longer or shorter than the original. The order |
291 in which streams are written to a memory store is not important as streams |
327 in which streams are written to a memory store is not important as streams |
292 can be changed and rewritten. |
328 can be changed and rewritten. |
293 */ |
329 */ |
294 class CBufStore : public CStreamStore |
330 class CBufStore : public CStreamStore |
295 { |
331 { |
296 public: |
332 public: |
297 IMPORT_C static CBufStore* NewL(TInt anExpandSize); |
333 IMPORT_C static CBufStore* NewL(TInt anExpandSize); |