epoc32/include/s32mem.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
williamr@2
     1
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     2
// All rights reserved.
williamr@2
     3
// This component and the accompanying materials are made available
williamr@2
     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
williamr@2
     5
// which accompanies this distribution, and is available
williamr@2
     6
// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
williamr@2
     7
//
williamr@2
     8
// Initial Contributors:
williamr@2
     9
// Nokia Corporation - initial contribution.
williamr@2
    10
//
williamr@2
    11
// Contributors:
williamr@2
    12
//
williamr@2
    13
// Description:
williamr@2
    14
//
williamr@2
    15
williamr@2
    16
#if !defined(__S32MEM_H__)
williamr@2
    17
#define __S32MEM_H__
williamr@2
    18
#if !defined(__S32BUF_H__)
williamr@2
    19
#include <s32buf.h>
williamr@2
    20
#endif
williamr@2
    21
#if !defined(__S32STOR_H__)
williamr@2
    22
#include <s32stor.h>
williamr@2
    23
#endif
williamr@2
    24
williamr@2
    25
/**
williamr@2
    26
 * @publishedAll 
williamr@2
    27
 * @released
williamr@2
    28
 * A stream buffer that uses plain memory for its implementation.
williamr@2
    29
williamr@2
    30
A stream of this type is used by RMemWriteStream and RMemReadStream objects. 
williamr@2
    31
It also has intermediate buffering capabilities.
williamr@2
    32
williamr@2
    33
This is a seekable stream buffer.
williamr@2
    34
williamr@2
    35
@see RMemWriteStream
williamr@2
    36
@see RMemReadStream  
williamr@2
    37
*/
williamr@2
    38
class TMemBuf : public TStreamBuf
williamr@2
    39
	{
williamr@2
    40
public:
williamr@2
    41
	IMPORT_C TMemBuf();
williamr@2
    42
	IMPORT_C void Set(TUint8* aPtr,TUint8* anEnd,TInt aMode=ERead|EWrite);
williamr@2
    43
protected:
williamr@2
    44
	IMPORT_C TInt UnderflowL(TInt aMaxLength);
williamr@2
    45
	IMPORT_C void OverflowL();
williamr@2
    46
	IMPORT_C TStreamPos DoSeekL(TMark aMark,TStreamLocation aLocation,TInt anOffset);
williamr@2
    47
private:
williamr@2
    48
	inline TUint8* Base() const;
williamr@2
    49
	inline TUint8* End() const;
williamr@2
    50
private:
williamr@2
    51
	TUint8* iBase;
williamr@2
    52
	};
williamr@2
    53
williamr@2
    54
/**
williamr@2
    55
 * @publishedAll 
williamr@2
    56
 * @released
williamr@2
    57
 * A stream buffer that uses a descriptor for its implementation.
williamr@2
    58
williamr@2
    59
A stream of this type is used by RDesWriteStream and RDesReadStream objects. 
williamr@2
    60
It also has intermediate buffering capabilities.
williamr@2
    61
williamr@2
    62
This is a seekable stream buffer.
williamr@2
    63
williamr@2
    64
When used in write mode, the length of the descriptor is only updated when 
williamr@2
    65
the stream buffer's SynchL() function is called, i.e. as a result of a call 
williamr@2
    66
to RWriteStream::CommitL().
williamr@2
    67
williamr@2
    68
@see RDesWriteStream
williamr@2
    69
@see RDesReadStream
williamr@2
    70
@see RWriteStream::CommitL()
williamr@2
    71
@see MStreamBuf::SynchL()  
williamr@2
    72
*/
williamr@2
    73
class TDesBuf : public TStreamBuf
williamr@2
    74
	{
williamr@2
    75
public:
williamr@2
    76
	IMPORT_C TDesBuf();
williamr@2
    77
	IMPORT_C void Set(TDes8& aDes,TInt aMode=ERead|EWrite);
williamr@2
    78
protected:
williamr@2
    79
	IMPORT_C TInt UnderflowL(TInt aMaxLength);
williamr@2
    80
	IMPORT_C void OverflowL();
williamr@2
    81
	IMPORT_C void DoSynchL();
williamr@2
    82
	IMPORT_C TStreamPos DoSeekL(TMark aMark,TStreamLocation aLocation,TInt anOffset);
williamr@2
    83
private:
williamr@2
    84
	inline TDes8& Des() const;
williamr@2
    85
	inline TUint8* Base() const;
williamr@2
    86
 	void Consolidate();
williamr@2
    87
private:
williamr@2
    88
	TDes8* iDes;
williamr@2
    89
	};
williamr@2
    90
williamr@2
    91
/**
williamr@2
    92
 * @publishedAll 
williamr@2
    93
 * @released
williamr@2
    94
 * A stream buffer that uses a dynamic buffer for its implementation.
williamr@2
    95
williamr@2
    96
A stream of this type is used by RBufWriteStream and RBufReadStream objects. 
williamr@2
    97
It also has intermediate buffering capabilities.
williamr@2
    98
williamr@2
    99
This is a seekable stream buffer.
williamr@2
   100
williamr@2
   101
There are three write modes:
williamr@2
   102
williamr@2
   103
insert mode - inserts new data into the buffer at the offset passed to Set()
williamr@2
   104
williamr@2
   105
overwrite mode - replaces the data in the buffer starting at the offset passed 
williamr@2
   106
to Set(). Once the end of the buffer is reached, it is automatically extended 
williamr@2
   107
as more data is written. This is the default mode.
williamr@2
   108
williamr@2
   109
truncate mode - truncates the buffer to the offset passed to Set() before 
williamr@2
   110
data is written, extending the buffer. When writing, the buffer size as reported 
williamr@2
   111
by CBufBase::Size() may be larger than the data written to the stream. To 
williamr@2
   112
synchronise the buffer's reported size with the stream, call the MStreamBuf::SynchL() 
williamr@2
   113
function.
williamr@2
   114
williamr@2
   115
Note that this object never takes ownership of the dynamic buffer, the CBufBase 
williamr@2
   116
type object.
williamr@2
   117
williamr@2
   118
@see RBufWriteStream
williamr@2
   119
@see RBufReadStream
williamr@2
   120
@see CBufBase::Size()
williamr@2
   121
@see MStreamBuf::SynchL() 
williamr@2
   122
*/
williamr@2
   123
class TBufBuf : public TStreamBuf
williamr@2
   124
	{
williamr@2
   125
public:
williamr@2
   126
	enum {ETruncate=0x10,EInsert=0x20};
williamr@2
   127
public:
williamr@2
   128
	IMPORT_C TBufBuf();
williamr@2
   129
	IMPORT_C void Set(CBufBase& aBuf,TInt aPos,TInt aMode=ERead|EWrite);
williamr@2
   130
protected:
williamr@2
   131
	IMPORT_C TInt UnderflowL(TInt aMaxLength);
williamr@2
   132
	IMPORT_C void OverflowL();
williamr@2
   133
	IMPORT_C void DoSynchL();
williamr@2
   134
	IMPORT_C void DoWriteL(const TAny* aPtr,TInt aLength);
williamr@2
   135
	IMPORT_C TStreamPos DoSeekL(TMark aMark,TStreamLocation aLocation,TInt anOffset);
williamr@2
   136
private:
williamr@2
   137
	inline CBufBase& Buf() const;
williamr@2
   138
 	void Consolidate();
williamr@2
   139
//
williamr@2
   140
	void SetPos(TMark aMark,TInt aPos);
williamr@2
   141
	inline void SetPos(TRead,TInt aPos);
williamr@2
   142
	inline void SetPos(TWrite,TInt aPos);
williamr@2
   143
	TInt Pos(TMark aMark) const;
williamr@2
   144
	inline TInt Pos(TRead) const;
williamr@2
   145
	inline TInt Pos(TWrite) const;
williamr@2
   146
	inline TInt MovePos(TRead,TInt anOffset);
williamr@2
   147
	inline TInt MovePos(TWrite,TInt anOffset);
williamr@2
   148
	inline TInt Mark(TRead) const;
williamr@2
   149
	inline TInt Mark(TWrite) const;
williamr@2
   150
private:
williamr@2
   151
	CBufBase* iBuf;
williamr@2
   152
	TInt iRPos;
williamr@2
   153
	TInt iWPos;
williamr@2
   154
	TInt iMode;
williamr@2
   155
	};
williamr@2
   156
williamr@2
   157
/**
williamr@2
   158
@publishedAll 
williamr@2
   159
@released
williamr@2
   160
williamr@2
   161
Supports the reading of a stream from a pointer of any type.
williamr@2
   162
williamr@2
   163
@see TMemBuf
williamr@2
   164
@see RReadStream 
williamr@2
   165
 */
williamr@2
   166
class RMemReadStream : public RReadStream
williamr@2
   167
	{
williamr@2
   168
public:
williamr@2
   169
	RMemReadStream() {}
williamr@2
   170
	IMPORT_C RMemReadStream(const TAny* aPtr,TInt aLength);
williamr@2
   171
	IMPORT_C void Open(const TAny* aPtr,TInt aLength);
williamr@2
   172
private:
williamr@2
   173
	TMemBuf iSource;
williamr@2
   174
	};
williamr@2
   175
williamr@2
   176
/**
williamr@2
   177
@publishedAll 
williamr@2
   178
@released
williamr@2
   179
williamr@2
   180
Supports the writing of a stream to a pointer of any type.
williamr@2
   181
williamr@2
   182
@see TMemBuf
williamr@2
   183
@see RWriteStream 
williamr@2
   184
 */
williamr@2
   185
class RMemWriteStream : public RWriteStream
williamr@2
   186
	{
williamr@2
   187
public:
williamr@2
   188
	RMemWriteStream() {}
williamr@2
   189
	inline RMemWriteStream(const MExternalizer<TStreamRef>& anExter);
williamr@2
   190
	IMPORT_C RMemWriteStream(TAny* aPtr,TInt aMaxLength);
williamr@2
   191
	IMPORT_C void Open(TAny* aPtr,TInt aMaxLength);
williamr@2
   192
private:
williamr@2
   193
	TMemBuf iSink;
williamr@2
   194
	};
williamr@2
   195
williamr@2
   196
/**
williamr@2
   197
@publishedAll 
williamr@2
   198
@released
williamr@2
   199
williamr@2
   200
Supports the reading of a stream from an 8-bit descriptor.
williamr@2
   201
williamr@2
   202
@see TMemBuf
williamr@2
   203
@see RReadStream 
williamr@2
   204
*/
williamr@2
   205
class RDesReadStream : public RReadStream
williamr@2
   206
	{
williamr@2
   207
public:
williamr@2
   208
	RDesReadStream() {}
williamr@2
   209
	IMPORT_C RDesReadStream(const TDesC8& aDes);
williamr@2
   210
	IMPORT_C void Open(const TDesC8& aDes);
williamr@2
   211
private:
williamr@2
   212
	TMemBuf iSource;
williamr@2
   213
	};
williamr@2
   214
williamr@2
   215
/**
williamr@2
   216
@publishedAll 
williamr@2
   217
@released
williamr@2
   218
williamr@2
   219
Supports the writing of a stream to an 8-bit descriptor.
williamr@2
   220
williamr@2
   221
@see TDesBuf
williamr@2
   222
@see RWriteStream 
williamr@2
   223
 */
williamr@2
   224
class RDesWriteStream : public RWriteStream
williamr@2
   225
	{
williamr@2
   226
public:
williamr@2
   227
	RDesWriteStream() {}
williamr@2
   228
	inline RDesWriteStream(const MExternalizer<TStreamRef>& anExter);
williamr@2
   229
	IMPORT_C RDesWriteStream(TDes8& aDes);
williamr@2
   230
	IMPORT_C void Open(TDes8& aDes);
williamr@2
   231
private:
williamr@2
   232
	TDesBuf iSink;
williamr@2
   233
	};
williamr@2
   234
williamr@2
   235
/**
williamr@2
   236
@publishedAll 
williamr@2
   237
@released
williamr@2
   238
williamr@2
   239
Supports the reading of a stream from a dynamic buffer.
williamr@2
   240
williamr@2
   241
@see TBufBuf
williamr@2
   242
@see RReadStream 
williamr@2
   243
*/
williamr@2
   244
class RBufReadStream : public RReadStream
williamr@2
   245
	{
williamr@2
   246
public:
williamr@2
   247
	RBufReadStream() {}
williamr@2
   248
	IMPORT_C RBufReadStream(const CBufBase& aBuf,TInt aPos=0);
williamr@2
   249
	IMPORT_C void Open(const CBufBase& aBuf,TInt aPos=0);
williamr@2
   250
private:
williamr@2
   251
	TBufBuf iSource;
williamr@2
   252
	};
williamr@2
   253
williamr@2
   254
/**
williamr@2
   255
@publishedAll 
williamr@2
   256
@released
williamr@2
   257
williamr@2
   258
Supports the writing of a stream to a dynamic buffer.
williamr@2
   259
williamr@2
   260
@see TBufBuf
williamr@2
   261
@see RWriteStream 
williamr@2
   262
 */
williamr@2
   263
class RBufWriteStream : public RWriteStream
williamr@2
   264
	{
williamr@2
   265
public:
williamr@2
   266
	RBufWriteStream() {}
williamr@2
   267
	inline RBufWriteStream(const MExternalizer<TStreamRef>& anExter);
williamr@2
   268
	IMPORT_C RBufWriteStream(CBufBase& aBuf,TInt aPos=0);
williamr@2
   269
	IMPORT_C void Open(CBufBase& aBuf,TInt aPos=0);
williamr@2
   270
	IMPORT_C void Truncate(CBufBase& aBuf,TInt aPos=0);
williamr@2
   271
	IMPORT_C void Insert(CBufBase& aBuf,TInt aPos);
williamr@2
   272
	inline void Append(CBufBase& aBuf);
williamr@2
   273
private:
williamr@2
   274
	TBufBuf iSink;
williamr@2
   275
	};
williamr@2
   276
williamr@2
   277
/**
williamr@2
   278
 * @publishedAll 
williamr@2
   279
 * @released
williamr@2
   280
 * In-memory non-persistent store. The buffer store does not have a root stream 
williamr@2
   281
and cannot be closed without losing all the data.
williamr@2
   282
williamr@2
   283
It implements many of the operations defined by the store abstract framework. 
williamr@2
   284
Specifically, streams in this store can be: overwritten, replaced, appended, 
williamr@2
   285
deleted, and created in advance of being written to. However the class does 
williamr@2
   286
not support commit and revert operations.
williamr@2
   287
williamr@2
   288
Overwriting an existing stream can result in a shorter stream; however, a 
williamr@2
   289
stream cannot be extended beyond its original length. Replacing a stream can 
williamr@2
   290
result in a stream which is longer or shorter than the original. The order 
williamr@2
   291
in which streams are written to a memory store is not important as streams 
williamr@2
   292
can be changed and rewritten.  
williamr@2
   293
*/
williamr@2
   294
class CBufStore : public CStreamStore
williamr@2
   295
	{
williamr@2
   296
public:
williamr@2
   297
	IMPORT_C static CBufStore* NewL(TInt anExpandSize);
williamr@2
   298
	IMPORT_C static CBufStore* NewLC(TInt anExpandSize);
williamr@2
   299
	IMPORT_C CBufStore(TInt anExpandSize);
williamr@2
   300
	IMPORT_C ~CBufStore();
williamr@2
   301
protected:
williamr@2
   302
	IMPORT_C TStreamId DoExtendL();
williamr@2
   303
	IMPORT_C void DoDeleteL(TStreamId anId);
williamr@2
   304
	IMPORT_C MStreamBuf* DoReadL(TStreamId anId) const;
williamr@2
   305
	IMPORT_C MStreamBuf* DoCreateL(TStreamId& anId);
williamr@2
   306
	IMPORT_C MStreamBuf* DoWriteL(TStreamId anId);
williamr@2
   307
	IMPORT_C MStreamBuf* DoReplaceL(TStreamId anId);
williamr@2
   308
private:
williamr@2
   309
	CBufSeg& BufL(TStreamId anId) const;
williamr@2
   310
private:
williamr@2
   311
	CArrayFixFlat<CBufSeg*> iBufArray;
williamr@2
   312
	TInt iExpandSize;
williamr@2
   313
	};		
williamr@2
   314
williamr@2
   315
#include <s32mem.inl>
williamr@2
   316
#endif