1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
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
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #if !defined(__S32MEM_H__)
18 #if !defined(__S32BUF_H__)
21 #if !defined(__S32STOR_H__)
28 * A stream buffer that uses plain memory for its implementation.
30 A stream of this type is used by RMemWriteStream and RMemReadStream objects.
31 It also has intermediate buffering capabilities.
33 This is a seekable stream buffer.
38 class TMemBuf : public TStreamBuf
42 IMPORT_C void Set(TUint8* aPtr,TUint8* anEnd,TInt aMode=ERead|EWrite);
44 IMPORT_C TInt UnderflowL(TInt aMaxLength);
45 IMPORT_C void OverflowL();
46 IMPORT_C TStreamPos DoSeekL(TMark aMark,TStreamLocation aLocation,TInt anOffset);
48 inline TUint8* Base() const;
49 inline TUint8* End() const;
57 * A stream buffer that uses a descriptor for its implementation.
59 A stream of this type is used by RDesWriteStream and RDesReadStream objects.
60 It also has intermediate buffering capabilities.
62 This is a seekable stream buffer.
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
66 to RWriteStream::CommitL().
70 @see RWriteStream::CommitL()
71 @see MStreamBuf::SynchL()
73 class TDesBuf : public TStreamBuf
77 IMPORT_C void Set(TDes8& aDes,TInt aMode=ERead|EWrite);
79 IMPORT_C TInt UnderflowL(TInt aMaxLength);
80 IMPORT_C void OverflowL();
81 IMPORT_C void DoSynchL();
82 IMPORT_C TStreamPos DoSeekL(TMark aMark,TStreamLocation aLocation,TInt anOffset);
84 inline TDes8& Des() const;
85 inline TUint8* Base() const;
94 * A stream buffer that uses a dynamic buffer for its implementation.
96 A stream of this type is used by RBufWriteStream and RBufReadStream objects.
97 It also has intermediate buffering capabilities.
99 This is a seekable stream buffer.
101 There are three write modes:
103 insert mode - inserts new data into the buffer at the offset passed to Set()
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
107 as more data is written. This is the default mode.
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
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()
115 Note that this object never takes ownership of the dynamic buffer, the CBufBase
120 @see CBufBase::Size()
121 @see MStreamBuf::SynchL()
123 class TBufBuf : public TStreamBuf
126 enum {ETruncate=0x10,EInsert=0x20};
129 IMPORT_C void Set(CBufBase& aBuf,TInt aPos,TInt aMode=ERead|EWrite);
131 IMPORT_C TInt UnderflowL(TInt aMaxLength);
132 IMPORT_C void OverflowL();
133 IMPORT_C void DoSynchL();
134 IMPORT_C void DoWriteL(const TAny* aPtr,TInt aLength);
135 IMPORT_C TStreamPos DoSeekL(TMark aMark,TStreamLocation aLocation,TInt anOffset);
137 inline CBufBase& Buf() const;
140 void SetPos(TMark aMark,TInt aPos);
141 inline void SetPos(TRead,TInt aPos);
142 inline void SetPos(TWrite,TInt aPos);
143 TInt Pos(TMark aMark) const;
144 inline TInt Pos(TRead) const;
145 inline TInt Pos(TWrite) const;
146 inline TInt MovePos(TRead,TInt anOffset);
147 inline TInt MovePos(TWrite,TInt anOffset);
148 inline TInt Mark(TRead) const;
149 inline TInt Mark(TWrite) const;
161 Supports the reading of a stream from a pointer of any type.
166 class RMemReadStream : public RReadStream
170 IMPORT_C RMemReadStream(const TAny* aPtr,TInt aLength);
171 IMPORT_C void Open(const TAny* aPtr,TInt aLength);
180 Supports the writing of a stream to a pointer of any type.
185 class RMemWriteStream : public RWriteStream
189 inline RMemWriteStream(const MExternalizer<TStreamRef>& anExter);
190 IMPORT_C RMemWriteStream(TAny* aPtr,TInt aMaxLength);
191 IMPORT_C void Open(TAny* aPtr,TInt aMaxLength);
200 Supports the reading of a stream from an 8-bit descriptor.
205 class RDesReadStream : public RReadStream
209 IMPORT_C RDesReadStream(const TDesC8& aDes);
210 IMPORT_C void Open(const TDesC8& aDes);
219 Supports the writing of a stream to an 8-bit descriptor.
224 class RDesWriteStream : public RWriteStream
228 inline RDesWriteStream(const MExternalizer<TStreamRef>& anExter);
229 IMPORT_C RDesWriteStream(TDes8& aDes);
230 IMPORT_C void Open(TDes8& aDes);
239 Supports the reading of a stream from a dynamic buffer.
244 class RBufReadStream : public RReadStream
248 IMPORT_C RBufReadStream(const CBufBase& aBuf,TInt aPos=0);
249 IMPORT_C void Open(const CBufBase& aBuf,TInt aPos=0);
258 Supports the writing of a stream to a dynamic buffer.
263 class RBufWriteStream : public RWriteStream
267 inline RBufWriteStream(const MExternalizer<TStreamRef>& anExter);
268 IMPORT_C RBufWriteStream(CBufBase& aBuf,TInt aPos=0);
269 IMPORT_C void Open(CBufBase& aBuf,TInt aPos=0);
270 IMPORT_C void Truncate(CBufBase& aBuf,TInt aPos=0);
271 IMPORT_C void Insert(CBufBase& aBuf,TInt aPos);
272 inline void Append(CBufBase& aBuf);
280 * In-memory non-persistent store. The buffer store does not have a root stream
281 and cannot be closed without losing all the data.
283 It implements many of the operations defined by the store abstract framework.
284 Specifically, streams in this store can be: overwritten, replaced, appended,
285 deleted, and created in advance of being written to. However the class does
286 not support commit and revert operations.
288 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
290 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
292 can be changed and rewritten.
294 class CBufStore : public CStreamStore
297 IMPORT_C static CBufStore* NewL(TInt anExpandSize);
298 IMPORT_C static CBufStore* NewLC(TInt anExpandSize);
299 IMPORT_C CBufStore(TInt anExpandSize);
300 IMPORT_C ~CBufStore();
302 IMPORT_C TStreamId DoExtendL();
303 IMPORT_C void DoDeleteL(TStreamId anId);
304 IMPORT_C MStreamBuf* DoReadL(TStreamId anId) const;
305 IMPORT_C MStreamBuf* DoCreateL(TStreamId& anId);
306 IMPORT_C MStreamBuf* DoWriteL(TStreamId anId);
307 IMPORT_C MStreamBuf* DoReplaceL(TStreamId anId);
309 CBufSeg& BufL(TStreamId anId) const;
311 CArrayFixFlat<CBufSeg*> iBufArray;
315 #include <s32mem.inl>