1.1 --- a/epoc32/include/s32mem.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/s32mem.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,316 @@
1.4 -s32mem.h
1.5 +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +// All rights reserved.
1.7 +// This component and the accompanying materials are made available
1.8 +// 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
1.9 +// which accompanies this distribution, and is available
1.10 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.11 +//
1.12 +// Initial Contributors:
1.13 +// Nokia Corporation - initial contribution.
1.14 +//
1.15 +// Contributors:
1.16 +//
1.17 +// Description:
1.18 +//
1.19 +
1.20 +#if !defined(__S32MEM_H__)
1.21 +#define __S32MEM_H__
1.22 +#if !defined(__S32BUF_H__)
1.23 +#include <s32buf.h>
1.24 +#endif
1.25 +#if !defined(__S32STOR_H__)
1.26 +#include <s32stor.h>
1.27 +#endif
1.28 +
1.29 +/**
1.30 + * @publishedAll
1.31 + * @released
1.32 + * A stream buffer that uses plain memory for its implementation.
1.33 +
1.34 +A stream of this type is used by RMemWriteStream and RMemReadStream objects.
1.35 +It also has intermediate buffering capabilities.
1.36 +
1.37 +This is a seekable stream buffer.
1.38 +
1.39 +@see RMemWriteStream
1.40 +@see RMemReadStream
1.41 +*/
1.42 +class TMemBuf : public TStreamBuf
1.43 + {
1.44 +public:
1.45 + IMPORT_C TMemBuf();
1.46 + IMPORT_C void Set(TUint8* aPtr,TUint8* anEnd,TInt aMode=ERead|EWrite);
1.47 +protected:
1.48 + IMPORT_C TInt UnderflowL(TInt aMaxLength);
1.49 + IMPORT_C void OverflowL();
1.50 + IMPORT_C TStreamPos DoSeekL(TMark aMark,TStreamLocation aLocation,TInt anOffset);
1.51 +private:
1.52 + inline TUint8* Base() const;
1.53 + inline TUint8* End() const;
1.54 +private:
1.55 + TUint8* iBase;
1.56 + };
1.57 +
1.58 +/**
1.59 + * @publishedAll
1.60 + * @released
1.61 + * A stream buffer that uses a descriptor for its implementation.
1.62 +
1.63 +A stream of this type is used by RDesWriteStream and RDesReadStream objects.
1.64 +It also has intermediate buffering capabilities.
1.65 +
1.66 +This is a seekable stream buffer.
1.67 +
1.68 +When used in write mode, the length of the descriptor is only updated when
1.69 +the stream buffer's SynchL() function is called, i.e. as a result of a call
1.70 +to RWriteStream::CommitL().
1.71 +
1.72 +@see RDesWriteStream
1.73 +@see RDesReadStream
1.74 +@see RWriteStream::CommitL()
1.75 +@see MStreamBuf::SynchL()
1.76 +*/
1.77 +class TDesBuf : public TStreamBuf
1.78 + {
1.79 +public:
1.80 + IMPORT_C TDesBuf();
1.81 + IMPORT_C void Set(TDes8& aDes,TInt aMode=ERead|EWrite);
1.82 +protected:
1.83 + IMPORT_C TInt UnderflowL(TInt aMaxLength);
1.84 + IMPORT_C void OverflowL();
1.85 + IMPORT_C void DoSynchL();
1.86 + IMPORT_C TStreamPos DoSeekL(TMark aMark,TStreamLocation aLocation,TInt anOffset);
1.87 +private:
1.88 + inline TDes8& Des() const;
1.89 + inline TUint8* Base() const;
1.90 + void Consolidate();
1.91 +private:
1.92 + TDes8* iDes;
1.93 + };
1.94 +
1.95 +/**
1.96 + * @publishedAll
1.97 + * @released
1.98 + * A stream buffer that uses a dynamic buffer for its implementation.
1.99 +
1.100 +A stream of this type is used by RBufWriteStream and RBufReadStream objects.
1.101 +It also has intermediate buffering capabilities.
1.102 +
1.103 +This is a seekable stream buffer.
1.104 +
1.105 +There are three write modes:
1.106 +
1.107 +insert mode - inserts new data into the buffer at the offset passed to Set()
1.108 +
1.109 +overwrite mode - replaces the data in the buffer starting at the offset passed
1.110 +to Set(). Once the end of the buffer is reached, it is automatically extended
1.111 +as more data is written. This is the default mode.
1.112 +
1.113 +truncate mode - truncates the buffer to the offset passed to Set() before
1.114 +data is written, extending the buffer. When writing, the buffer size as reported
1.115 +by CBufBase::Size() may be larger than the data written to the stream. To
1.116 +synchronise the buffer's reported size with the stream, call the MStreamBuf::SynchL()
1.117 +function.
1.118 +
1.119 +Note that this object never takes ownership of the dynamic buffer, the CBufBase
1.120 +type object.
1.121 +
1.122 +@see RBufWriteStream
1.123 +@see RBufReadStream
1.124 +@see CBufBase::Size()
1.125 +@see MStreamBuf::SynchL()
1.126 +*/
1.127 +class TBufBuf : public TStreamBuf
1.128 + {
1.129 +public:
1.130 + enum {ETruncate=0x10,EInsert=0x20};
1.131 +public:
1.132 + IMPORT_C TBufBuf();
1.133 + IMPORT_C void Set(CBufBase& aBuf,TInt aPos,TInt aMode=ERead|EWrite);
1.134 +protected:
1.135 + IMPORT_C TInt UnderflowL(TInt aMaxLength);
1.136 + IMPORT_C void OverflowL();
1.137 + IMPORT_C void DoSynchL();
1.138 + IMPORT_C void DoWriteL(const TAny* aPtr,TInt aLength);
1.139 + IMPORT_C TStreamPos DoSeekL(TMark aMark,TStreamLocation aLocation,TInt anOffset);
1.140 +private:
1.141 + inline CBufBase& Buf() const;
1.142 + void Consolidate();
1.143 +//
1.144 + void SetPos(TMark aMark,TInt aPos);
1.145 + inline void SetPos(TRead,TInt aPos);
1.146 + inline void SetPos(TWrite,TInt aPos);
1.147 + TInt Pos(TMark aMark) const;
1.148 + inline TInt Pos(TRead) const;
1.149 + inline TInt Pos(TWrite) const;
1.150 + inline TInt MovePos(TRead,TInt anOffset);
1.151 + inline TInt MovePos(TWrite,TInt anOffset);
1.152 + inline TInt Mark(TRead) const;
1.153 + inline TInt Mark(TWrite) const;
1.154 +private:
1.155 + CBufBase* iBuf;
1.156 + TInt iRPos;
1.157 + TInt iWPos;
1.158 + TInt iMode;
1.159 + };
1.160 +
1.161 +/**
1.162 +@publishedAll
1.163 +@released
1.164 +
1.165 +Supports the reading of a stream from a pointer of any type.
1.166 +
1.167 +@see TMemBuf
1.168 +@see RReadStream
1.169 + */
1.170 +class RMemReadStream : public RReadStream
1.171 + {
1.172 +public:
1.173 + RMemReadStream() {}
1.174 + IMPORT_C RMemReadStream(const TAny* aPtr,TInt aLength);
1.175 + IMPORT_C void Open(const TAny* aPtr,TInt aLength);
1.176 +private:
1.177 + TMemBuf iSource;
1.178 + };
1.179 +
1.180 +/**
1.181 +@publishedAll
1.182 +@released
1.183 +
1.184 +Supports the writing of a stream to a pointer of any type.
1.185 +
1.186 +@see TMemBuf
1.187 +@see RWriteStream
1.188 + */
1.189 +class RMemWriteStream : public RWriteStream
1.190 + {
1.191 +public:
1.192 + RMemWriteStream() {}
1.193 + inline RMemWriteStream(const MExternalizer<TStreamRef>& anExter);
1.194 + IMPORT_C RMemWriteStream(TAny* aPtr,TInt aMaxLength);
1.195 + IMPORT_C void Open(TAny* aPtr,TInt aMaxLength);
1.196 +private:
1.197 + TMemBuf iSink;
1.198 + };
1.199 +
1.200 +/**
1.201 +@publishedAll
1.202 +@released
1.203 +
1.204 +Supports the reading of a stream from an 8-bit descriptor.
1.205 +
1.206 +@see TMemBuf
1.207 +@see RReadStream
1.208 +*/
1.209 +class RDesReadStream : public RReadStream
1.210 + {
1.211 +public:
1.212 + RDesReadStream() {}
1.213 + IMPORT_C RDesReadStream(const TDesC8& aDes);
1.214 + IMPORT_C void Open(const TDesC8& aDes);
1.215 +private:
1.216 + TMemBuf iSource;
1.217 + };
1.218 +
1.219 +/**
1.220 +@publishedAll
1.221 +@released
1.222 +
1.223 +Supports the writing of a stream to an 8-bit descriptor.
1.224 +
1.225 +@see TDesBuf
1.226 +@see RWriteStream
1.227 + */
1.228 +class RDesWriteStream : public RWriteStream
1.229 + {
1.230 +public:
1.231 + RDesWriteStream() {}
1.232 + inline RDesWriteStream(const MExternalizer<TStreamRef>& anExter);
1.233 + IMPORT_C RDesWriteStream(TDes8& aDes);
1.234 + IMPORT_C void Open(TDes8& aDes);
1.235 +private:
1.236 + TDesBuf iSink;
1.237 + };
1.238 +
1.239 +/**
1.240 +@publishedAll
1.241 +@released
1.242 +
1.243 +Supports the reading of a stream from a dynamic buffer.
1.244 +
1.245 +@see TBufBuf
1.246 +@see RReadStream
1.247 +*/
1.248 +class RBufReadStream : public RReadStream
1.249 + {
1.250 +public:
1.251 + RBufReadStream() {}
1.252 + IMPORT_C RBufReadStream(const CBufBase& aBuf,TInt aPos=0);
1.253 + IMPORT_C void Open(const CBufBase& aBuf,TInt aPos=0);
1.254 +private:
1.255 + TBufBuf iSource;
1.256 + };
1.257 +
1.258 +/**
1.259 +@publishedAll
1.260 +@released
1.261 +
1.262 +Supports the writing of a stream to a dynamic buffer.
1.263 +
1.264 +@see TBufBuf
1.265 +@see RWriteStream
1.266 + */
1.267 +class RBufWriteStream : public RWriteStream
1.268 + {
1.269 +public:
1.270 + RBufWriteStream() {}
1.271 + inline RBufWriteStream(const MExternalizer<TStreamRef>& anExter);
1.272 + IMPORT_C RBufWriteStream(CBufBase& aBuf,TInt aPos=0);
1.273 + IMPORT_C void Open(CBufBase& aBuf,TInt aPos=0);
1.274 + IMPORT_C void Truncate(CBufBase& aBuf,TInt aPos=0);
1.275 + IMPORT_C void Insert(CBufBase& aBuf,TInt aPos);
1.276 + inline void Append(CBufBase& aBuf);
1.277 +private:
1.278 + TBufBuf iSink;
1.279 + };
1.280 +
1.281 +/**
1.282 + * @publishedAll
1.283 + * @released
1.284 + * In-memory non-persistent store. The buffer store does not have a root stream
1.285 +and cannot be closed without losing all the data.
1.286 +
1.287 +It implements many of the operations defined by the store abstract framework.
1.288 +Specifically, streams in this store can be: overwritten, replaced, appended,
1.289 +deleted, and created in advance of being written to. However the class does
1.290 +not support commit and revert operations.
1.291 +
1.292 +Overwriting an existing stream can result in a shorter stream; however, a
1.293 +stream cannot be extended beyond its original length. Replacing a stream can
1.294 +result in a stream which is longer or shorter than the original. The order
1.295 +in which streams are written to a memory store is not important as streams
1.296 +can be changed and rewritten.
1.297 +*/
1.298 +class CBufStore : public CStreamStore
1.299 + {
1.300 +public:
1.301 + IMPORT_C static CBufStore* NewL(TInt anExpandSize);
1.302 + IMPORT_C static CBufStore* NewLC(TInt anExpandSize);
1.303 + IMPORT_C CBufStore(TInt anExpandSize);
1.304 + IMPORT_C ~CBufStore();
1.305 +protected:
1.306 + IMPORT_C TStreamId DoExtendL();
1.307 + IMPORT_C void DoDeleteL(TStreamId anId);
1.308 + IMPORT_C MStreamBuf* DoReadL(TStreamId anId) const;
1.309 + IMPORT_C MStreamBuf* DoCreateL(TStreamId& anId);
1.310 + IMPORT_C MStreamBuf* DoWriteL(TStreamId anId);
1.311 + IMPORT_C MStreamBuf* DoReplaceL(TStreamId anId);
1.312 +private:
1.313 + CBufSeg& BufL(TStreamId anId) const;
1.314 +private:
1.315 + CArrayFixFlat<CBufSeg*> iBufArray;
1.316 + TInt iExpandSize;
1.317 + };
1.318 +
1.319 +#include <s32mem.inl>
1.320 +#endif