epoc32/include/s32buf.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
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@4
     4
// under the terms of "Eclipse Public License v1.0"
williamr@2
     5
// which accompanies this distribution, and is available
williamr@4
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.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(__S32BUF_H__)
williamr@2
    17
#define __S32BUF_H__
williamr@2
    18
#if !defined(__E32STD_H__)
williamr@2
    19
#include <e32std.h>
williamr@2
    20
#endif
williamr@2
    21
williamr@2
    22
/** Defines the type of location within a stream on which the calculation 
williamr@2
    23
of a new seek position is based.
williamr@2
    24
williamr@2
    25
The type is used by the stream buffer SeekL() functions.
williamr@2
    26
williamr@2
    27
@see MStreamBuf::SeekL() */
williamr@2
    28
enum TStreamLocation 
williamr@2
    29
	/** The seek position is calculated relative to the beginning of the 
williamr@2
    30
	stream.*/
williamr@2
    31
	{EStreamBeginning,
williamr@2
    32
	/** The seek position is calculated relative to the end of the stream.*/
williamr@2
    33
	EStreamMark,
williamr@2
    34
	/** The seek position is calculated relative to the existing read or 
williamr@2
    35
	write mark in the stream. */
williamr@2
    36
	EStreamEnd};
williamr@2
    37
williamr@2
    38
/**
williamr@2
    39
 * @publishedAll 
williamr@2
    40
 * @released
williamr@2
    41
 * Holds the position of the read or write mark within a seekable stream.
williamr@2
    42
williamr@2
    43
Position is the offset from the beginning of a seekable stream. The class 
williamr@2
    44
provides convenient operators for performing arithmetic on the offset value 
williamr@2
    45
and for doing comparisons between stream position objects.
williamr@2
    46
williamr@2
    47
It can be considered as an absolute stream position.
williamr@2
    48
williamr@2
    49
Objects of this type are usually created as a result of calling 
williamr@2
    50
MStreamBuf::SeekL() or MStreamBuf::TellL(); they allow a program to remember 
williamr@2
    51
the current read position in a stream buffer and reset it to the same 
williamr@2
    52
location later.
williamr@2
    53
williamr@2
    54
@see MStreamBuf::SeekL()
williamr@2
    55
@see MStreamBuf::TellL()  
williamr@2
    56
*/
williamr@2
    57
class TStreamPos
williamr@2
    58
	{
williamr@2
    59
public:
williamr@2
    60
	/** Constructs an empty stream position object. */
williamr@2
    61
	TStreamPos() {}
williamr@2
    62
	inline TStreamPos(TInt anOffset);
williamr@2
    63
//
williamr@2
    64
	inline TBool operator==(TStreamPos aPos) const;
williamr@2
    65
	inline TBool operator!=(TStreamPos aPos) const;
williamr@2
    66
	inline TBool operator<(TStreamPos aPos) const;
williamr@2
    67
	inline TBool operator<=(TStreamPos aPos) const;
williamr@2
    68
	inline TBool operator>(TStreamPos aPos) const;
williamr@2
    69
	inline TBool operator>=(TStreamPos aPos) const;
williamr@2
    70
//
williamr@2
    71
	inline TInt operator-(TStreamPos aPos) const;
williamr@2
    72
	inline TStreamPos operator+(TInt anOffset) const;
williamr@2
    73
	inline TStreamPos operator-(TInt anOffset) const;
williamr@2
    74
//
williamr@2
    75
	inline TStreamPos& operator+=(TInt anOffset);
williamr@2
    76
	inline TStreamPos& operator-=(TInt anOffset);
williamr@2
    77
//
williamr@2
    78
	inline TInt Offset() const;
williamr@2
    79
private:
williamr@2
    80
	TInt iOff;
williamr@2
    81
	};
williamr@2
    82
inline TStreamPos operator+(TInt anOffset,TStreamPos aPos);
williamr@2
    83
#if defined(__NO_CLASS_CONSTS__)
williamr@2
    84
/** Constructs a TStreamPos object that denotes the beginning of any seekable 
williamr@2
    85
stream.
williamr@2
    86
williamr@2
    87
@see TStreamPos */
williamr@2
    88
#define KStreamBeginning TStreamPos(0)
williamr@2
    89
#else
williamr@2
    90
const TStreamPos KStreamBeginning=TStreamPos(0);
williamr@2
    91
#endif
williamr@2
    92
williamr@2
    93
/**
williamr@2
    94
 * @publishedAll 
williamr@2
    95
 * @released
williamr@2
    96
 * Stream transfer object.
williamr@2
    97
williamr@2
    98
Holds and maintains a value that represents how much data is to be transferred, 
williamr@2
    99
or remains to be transferred, between streams.
williamr@2
   100
williamr@2
   101
Objects of this type are used by ReadL() and WriteL() functions of MStreamBuf.
williamr@2
   102
williamr@2
   103
@see MStreamBuf
williamr@2
   104
@see TStreamBuf
williamr@2
   105
@see TStreamMark
williamr@2
   106
@see TStreamExchange
williamr@2
   107
@see RShareBuf  
williamr@2
   108
*/
williamr@2
   109
class TStreamTransfer
williamr@2
   110
	{
williamr@2
   111
public:
williamr@2
   112
	/** An enumerator type passed to a constructor of this class to indicate 
williamr@2
   113
	that there is no explicit limit to the amount of data that can be 
williamr@2
   114
	transferred between streams. The enumeration is not used. */
williamr@2
   115
	enum TUnlimited {EUnlimited};
williamr@2
   116
public:
williamr@2
   117
	/** Constructs a stream transfer object specifying that there is no 
williamr@2
   118
	explicit limit to the amount of data that can be transferred between 
williamr@2
   119
	streams.
williamr@2
   120
	
williamr@2
   121
	The amount of data to be transferred is only limited by the streams 
williamr@2
   122
	themselves.
williamr@2
   123
	
williamr@2
   124
	The arithmetical operators do not change the state of an unlimited stream 
williamr@2
   125
	transfer object. */
williamr@2
   126
	TStreamTransfer() {}
williamr@2
   127
	inline TStreamTransfer(TInt aMaxLength);
williamr@2
   128
	inline TStreamTransfer(TUnlimited);
williamr@2
   129
//
williamr@2
   130
	inline TBool operator==(TInt aLength) const;
williamr@2
   131
	inline TBool operator>(TInt aLength) const;
williamr@2
   132
	inline TStreamTransfer operator-(TInt aLength) const;
williamr@2
   133
	inline TInt operator[](TInt aMaxLength) const;
williamr@2
   134
//
williamr@2
   135
	inline TStreamTransfer& operator-=(TInt aLength);
williamr@2
   136
//
williamr@2
   137
	inline TInt Left() const;
williamr@2
   138
private:
williamr@2
   139
	TInt iVal;
williamr@2
   140
private:
williamr@2
   141
	IMPORT_C static void __DbgChkNonNegative(TInt aLength);
williamr@2
   142
	};
williamr@2
   143
inline TBool operator==(TInt aLength,TStreamTransfer aTransfer);
williamr@2
   144
inline TBool operator<(TInt aLength,TStreamTransfer aTransfer);
williamr@2
   145
#if defined(__NO_CLASS_CONSTS__)
williamr@2
   146
/** Constructs a TStreamTransfer object indicating that no explicit limit is 
williamr@2
   147
imposed on transfers between streams.
williamr@2
   148
williamr@2
   149
@see TStreamTransfer
williamr@2
   150
@see MStreamBuf::ReadL()
williamr@2
   151
@see MStreamBuf::WriteL() */
williamr@2
   152
#define KStreamUnlimited TStreamTransfer(TStreamTransfer::EUnlimited)
williamr@2
   153
#else
williamr@2
   154
const TStreamTransfer KStreamUnlimited=TStreamTransfer::EUnlimited;
williamr@2
   155
#endif
williamr@2
   156
//
williamr@2
   157
class MStreamInput;
williamr@2
   158
class MStreamOutput;
williamr@2
   159
williamr@2
   160
/**
williamr@2
   161
 * @publishedAll 
williamr@2
   162
 * @released
williamr@2
   163
 * A stream buffer that provides a generic I/O interface for streamed data.
williamr@2
   164
williamr@2
   165
A stream buffer:
williamr@2
   166
williamr@2
   167
may be buffered or unbuffered
williamr@2
   168
williamr@2
   169
may provide read-only, write-only or read/write capability
williamr@2
   170
williamr@2
   171
may be seekable, or unseekable.
williamr@2
   172
williamr@2
   173
A seekable stream buffer maintains independent read and write pointers, which 
williamr@2
   174
can be manipulated separately. This is unlike the RFile interface which 
williamr@2
   175
maintains a single current position in the file. For example, file streams 
williamr@2
   176
and memory streams are seekable streams, but socket, serial-comms, and filtered 
williamr@2
   177
streams are not.
williamr@2
   178
williamr@2
   179
Objects of this type are used by the stream interface classes derived from 
williamr@2
   180
RReadStream and RWriteStream.
williamr@2
   181
williamr@2
   182
The class has no member data.
williamr@2
   183
williamr@2
   184
Derive from this class, if the stream has no intermediate buffering 
williamr@2
   185
capabilities, otherwise derive from TStreamBuf.
williamr@2
   186
williamr@2
   187
Get a reference to the stream buffer used by a read stream by calling 
williamr@2
   188
RReadStream::Source(). Get a reference to the stream buffer used by a write 
williamr@2
   189
stream by calling RWriteStream::Sink()
williamr@2
   190
williamr@2
   191
@see RReadStream
williamr@2
   192
@see RWriteStream
williamr@2
   193
@see TStreamBuf 
williamr@2
   194
*/
williamr@2
   195
class MStreamBuf
williamr@2
   196
	{
williamr@2
   197
public:
williamr@2
   198
	/** Indicates that an operation applies to the read mark in a stream or to 
williamr@2
   199
	the read area in an stream buffer. */
williamr@2
   200
	enum TRead {ERead=0x01};
williamr@2
   201
williamr@2
   202
	/** Indicates that an operation applies to the write mark in a stream or 
williamr@2
   203
	to the write area in an stream buffer. */
williamr@2
   204
	enum TWrite {EWrite=0x02};
williamr@2
   205
williamr@2
   206
	/** Used to identify the type of mark in a stream.
williamr@2
   207
williamr@2
   208
	The type is used by functions of this class and derived classes that perform 
williamr@2
   209
	seek operations to marks within a stream.
williamr@2
   210
williamr@2
   211
	The type uses the ERead and EWrite enumeration values, as bit flags, to 
williamr@2
   212
	identify the read and write marks respectively.
williamr@2
   213
williamr@2
   214
	ERead is an MStreamBuf::TRead enumerator. EWrite is an MStreamBuf::EWrite 
williamr@2
   215
	enumerator.
williamr@2
   216
williamr@2
   217
	@see MStreamBuf::TRead
williamr@2
   218
	@see MStreamBuf::TWrite */
williamr@2
   219
	typedef TInt TMark;
williamr@2
   220
public:
williamr@2
   221
	IMPORT_C void Close();
williamr@2
   222
	inline void Release();
williamr@2
   223
	IMPORT_C TInt Synch();
williamr@2
   224
	inline void SynchL();
williamr@2
   225
//
williamr@2
   226
	IMPORT_C void PushL();
williamr@2
   227
//
williamr@2
   228
	inline TInt ReadL(TAny* aPtr,TInt aMaxLength);
williamr@2
   229
	IMPORT_C TInt Read(TDes8& aDes,TRequestStatus& aStatus);
williamr@2
   230
	IMPORT_C TInt Read(TDes8& aDes,TInt aMaxLength,TRequestStatus& aStatus);
williamr@2
   231
	IMPORT_C TInt ReadL(TDes8& aDes,TRequestStatus& aStatus);
williamr@2
   232
	inline TInt ReadL(TDes8& aDes,TInt aMaxLength,TRequestStatus& aStatus);
williamr@2
   233
	inline TStreamTransfer ReadL(MStreamInput& anInput,TStreamTransfer aTransfer);
williamr@2
   234
	IMPORT_C TInt ReadL(MStreamInput& anInput,TInt aMaxLength);
williamr@2
   235
	inline void ReadL(MStreamInput& anInput);
williamr@2
   236
//
williamr@2
   237
	inline void WriteL(const TAny* aPtr,TInt aLength);
williamr@2
   238
	IMPORT_C TInt Write(const TDesC8& aDes,TRequestStatus& aStatus);
williamr@2
   239
	IMPORT_C TInt Write(const TDesC8& aDes,TInt aMaxLength,TRequestStatus& aStatus);
williamr@2
   240
	IMPORT_C TInt WriteL(const TDesC8& aDes,TRequestStatus& aStatus);
williamr@2
   241
	inline TInt WriteL(const TDesC8& aDes,TInt aMaxLength,TRequestStatus& aStatus);
williamr@2
   242
	inline TStreamTransfer WriteL(MStreamOutput& anOutput,TStreamTransfer aTransfer);
williamr@2
   243
	IMPORT_C TInt WriteL(MStreamOutput& anOutput,TInt aMaxLength);
williamr@2
   244
	inline void WriteL(MStreamOutput& anOutput);
williamr@2
   245
//
williamr@2
   246
	inline void SeekL(TMark aMark,TStreamPos aPos);
williamr@2
   247
	inline TStreamPos SeekL(TMark aMark,TStreamLocation aLocation,TInt anOffset=0);
williamr@2
   248
	inline TStreamPos SeekL(TRead,TStreamLocation aLocation,TInt anOffset=0);
williamr@2
   249
	inline TStreamPos SeekL(TWrite,TStreamLocation aLocation,TInt anOffset=0);
williamr@2
   250
	inline TStreamPos SeekL(TRead,TInt anOffset);
williamr@2
   251
	inline TStreamPos SeekL(TWrite,TInt anOffset);
williamr@2
   252
//
williamr@2
   253
	inline TStreamPos TellL(TRead) const;
williamr@2
   254
	inline TStreamPos TellL(TWrite) const;
williamr@2
   255
	inline TInt SizeL() const;
williamr@2
   256
protected:
williamr@2
   257
	MStreamBuf() {}
williamr@2
   258
private:
williamr@2
   259
	MStreamBuf(const MStreamBuf&);
williamr@2
   260
	MStreamBuf& operator=(const MStreamBuf&);
williamr@2
   261
//
williamr@2
   262
	virtual IMPORT_C void DoRelease();
williamr@2
   263
	virtual IMPORT_C void DoSynchL();
williamr@2
   264
	virtual IMPORT_C TInt DoReadL(TAny* aPtr,TInt aMaxLength);
williamr@2
   265
	virtual IMPORT_C TInt DoReadL(TDes8& aDes,TInt aMaxLength,TRequestStatus& aStatus);
williamr@2
   266
	virtual IMPORT_C TStreamTransfer DoReadL(MStreamInput& anInput,TStreamTransfer aTransfer);
williamr@2
   267
	virtual IMPORT_C void DoWriteL(const TAny* aPtr,TInt aLength);
williamr@2
   268
	virtual IMPORT_C TInt DoWriteL(const TDesC8& aDes,TInt aMaxLength,TRequestStatus& aStatus);
williamr@2
   269
	virtual IMPORT_C TStreamTransfer DoWriteL(MStreamOutput& anOutput,TStreamTransfer aTransfer);
williamr@2
   270
	virtual IMPORT_C TStreamPos DoSeekL(TMark aMark,TStreamLocation aLocation,TInt anOffset);
williamr@2
   271
	};
williamr@2
   272
williamr@2
   273
/**
williamr@2
   274
 * @publishedAll 
williamr@2
   275
 * @released
williamr@2
   276
 * An interface to an object that acts as a target for read operations from 
williamr@2
   277
a stream. The object behaves as a generic data sink.
williamr@2
   278
williamr@2
   279
A stream input object can act as an intelligent buffer, and is useful for 
williamr@2
   280
performing filtering, compression or any other general kind of conversion 
williamr@2
   281
operation that might be needed after reading from a stream.
williamr@2
   282
williamr@2
   283
The class is pure interface and requires an implementation.
williamr@2
   284
williamr@2
   285
@see MStreamBuf::ReadL()  
williamr@2
   286
*/
williamr@2
   287
class MStreamInput
williamr@2
   288
	{
williamr@2
   289
public:
williamr@2
   290
	/** Reads data from an intermediate buffer into this stream input object.
williamr@2
   291
	
williamr@2
   292
	This function is called by the default implementation of 
williamr@2
   293
	TStreamBuf::DoReadL(MStreamInput&,TStreamTransfer) 
williamr@2
   294
	and assumes that the source is a stream buffer's intermediate buffer.
williamr@2
   295
	
williamr@2
   296
	@param aPtr A pointer into the intermediate buffer from which the read 
williamr@2
   297
	operation starts.
williamr@2
   298
	@param aMaxLength The maximum amount of data to be read.
williamr@2
   299
	@return The amount of data read.
williamr@2
   300
	@see TStreamBuf::DoReadL()
williamr@2
   301
	@see TStreamBuf */
williamr@2
   302
	virtual TInt PushL(const TAny* aPtr,TInt aMaxLength)=0;
williamr@2
   303
williamr@2
   304
	/** Reads data from the specified stream into this stream input object.
williamr@2
   305
	
williamr@2
   306
	This function is called by the default implementation of
williamr@2
   307
	MStreamBuf::DoReadL(MStreamInput&,TStreamTransfer). 
williamr@2
   308
	It may also be called by TStreamBuf::DoReadL(MStreamInput&,TStreamTransfer), 
williamr@2
   309
	depending on the amount of data to be transferred and the nature of the 
williamr@2
   310
	buffering scheme.
williamr@2
   311
	
williamr@2
   312
	@param aSource The stream from which data is to be read.
williamr@2
   313
	@param aTransfer Defines the amount of data available to be read.
williamr@2
   314
	@return The amount of data that was not consumed.
williamr@2
   315
	@see MStreamBuf::DoReadL()
williamr@2
   316
	@see TStreamBuf::DoReadL() */
williamr@2
   317
	virtual	TStreamTransfer ReadFromL(MStreamBuf& aSource,TStreamTransfer aTransfer)=0;
williamr@2
   318
	};
williamr@2
   319
williamr@2
   320
/**
williamr@2
   321
 * @publishedAll 
williamr@2
   322
 * @released
williamr@2
   323
 * An interface to an object that acts as source for write operations to a 
williamr@2
   324
stream. The object behaves as a generic data source.
williamr@2
   325
williamr@2
   326
A stream output object can act as an intelligent buffer, and is useful for 
williamr@2
   327
performing filtering, compression or any other general kind of conversion 
williamr@2
   328
operation that might be needed before writing to a stream.
williamr@2
   329
williamr@2
   330
The class is pure interface and requires an implementation.
williamr@2
   331
williamr@2
   332
@see MStreamBuf::WriteL()  
williamr@2
   333
*/
williamr@2
   334
class MStreamOutput
williamr@2
   335
	{
williamr@2
   336
public:
williamr@2
   337
	/** Writes data to an intermediate buffer from this stream output object.
williamr@2
   338
	
williamr@2
   339
	This function is called by the default implementation of 
williamr@2
   340
	TStreamBuf::DoWriteL(MStreamOutput&,TStreamTransfer) 
williamr@2
   341
	and assumes that the target is a stream buffer's intermediate buffer.
williamr@2
   342
	
williamr@2
   343
	@param aPtr A pointer into the intermediate buffer where the write operation 
williamr@2
   344
	starts.
williamr@2
   345
	@param aMaxLength The maximum amount of data to be written.
williamr@2
   346
	@return The amount of data written.
williamr@2
   347
	@see TStreamBuf::DoWriteL()
williamr@2
   348
	@see TStreamBuf */
williamr@2
   349
	virtual TInt PullL(TAny* aPtr,TInt aMaxLength)=0;
williamr@2
   350
williamr@2
   351
	/** Writes data to the specified stream from this stream output object.
williamr@2
   352
	
williamr@2
   353
	This function is called by the default implementation of 
williamr@2
   354
	MStreamBuf::DoWriteL(MStreamOutput&,TStreamTransfer). 
williamr@2
   355
	It may also be called by TStreamBuf::DoWriteL(MStreamOutput&,TStreamTransfer), 
williamr@2
   356
	depending on the amount of data to be transferred and the nature of the 
williamr@2
   357
	buffering scheme.
williamr@2
   358
	
williamr@2
   359
	@param aSink The stream to which data is to be written.
williamr@2
   360
	@param aTransfer Defines the amount of data available to be written.
williamr@2
   361
	@return The amount of data that was not consumed.
williamr@2
   362
	@see MStreamBuf::DoWriteL()
williamr@2
   363
	@see TStreamBuf::DoWriteL() */
williamr@2
   364
	virtual TStreamTransfer WriteToL(MStreamBuf& aSink,TStreamTransfer aTransfer)=0;
williamr@2
   365
	};
williamr@2
   366
williamr@2
   367
/**
williamr@2
   368
 * @publishedAll 
williamr@2
   369
 * @released
williamr@2
   370
 * Adds buffering capabilities to a stream buffer
williamr@2
   371
williamr@2
   372
The class provides pointers to mark out the current read and write areas within 
williamr@2
   373
the intermediate buffer. The class also defines the pure virtual functions 
williamr@2
   374
UnderflowL() and OverflowL() which must be provided by a derived class.
williamr@2
   375
williamr@2
   376
Streams which have buffering capabilities derive from this class, otherwise 
williamr@2
   377
they derive from MStreamBuf.
williamr@2
   378
williamr@2
   379
Note that the class does not provide the buffer; this is left to the class 
williamr@2
   380
derived from it. For example, the memory buffer classes use the memory area 
williamr@2
   381
directly, the file buffer class allocate a heap cell to use as a buffer.
williamr@2
   382
williamr@2
   383
@see UnderflowL()
williamr@2
   384
@see OverflowL()  
williamr@2
   385
*/
williamr@2
   386
class TStreamBuf : public MStreamBuf
williamr@2
   387
	{
williamr@2
   388
protected:
williamr@2
   389
	/** Used to identify the type of area within an intermediate buffer.
williamr@2
   390
williamr@2
   391
	The type is used by functions of this class that set or get pointers into 
williamr@2
   392
	the intermediate buffer.
williamr@2
   393
williamr@2
   394
	The type uses the ERead and EWrite enumeration values, as bit flags, to 
williamr@2
   395
	identify the read and write areas respectively.
williamr@2
   396
williamr@2
   397
	ERead is an MStreamBuf::TRead enumerator. EWrite is an MStreamBuf::EWrite 
williamr@2
   398
	enumerator.
williamr@2
   399
williamr@2
   400
	@see MStreamBuf::TRead
williamr@2
   401
	@see MStreamBuf::TWrite */
williamr@2
   402
	typedef TInt TArea;
williamr@2
   403
protected:
williamr@2
   404
	IMPORT_C TStreamBuf();
williamr@2
   405
//
williamr@2
   406
	IMPORT_C void SetBuf(TArea anArea,TUint8* aPtr,TUint8* anEnd);
williamr@2
   407
	IMPORT_C void SetPtr(TArea anArea,TUint8* aPtr);
williamr@2
   408
	IMPORT_C void SetEnd(TArea anArea,TUint8* anEnd);
williamr@2
   409
	IMPORT_C TUint8* Ptr(TArea anArea) const;
williamr@2
   410
	IMPORT_C TUint8* End(TArea anArea) const;
williamr@2
   411
	IMPORT_C TInt Avail(TArea anArea) const;
williamr@2
   412
//
williamr@2
   413
	IMPORT_C TInt DoReadL(TAny* aPtr,TInt aMaxLength);
williamr@2
   414
	IMPORT_C TStreamTransfer DoReadL(MStreamInput& anInput,TStreamTransfer aTransfer);
williamr@2
   415
	IMPORT_C void DoWriteL(const TAny* aPtr,TInt aLength);
williamr@2
   416
	IMPORT_C TStreamTransfer DoWriteL(MStreamOutput& anOutput,TStreamTransfer aTransfer);
williamr@2
   417
//
williamr@2
   418
	inline void SetBuf(TRead,TUint8* aPtr,TUint8* anEnd);
williamr@2
   419
	inline void SetBuf(TWrite,TUint8* aPtr,TUint8* anEnd);
williamr@2
   420
	inline void SetPtr(TRead,TUint8* aPtr);
williamr@2
   421
	inline void SetPtr(TWrite,TUint8* aPtr);
williamr@2
   422
	inline void SetEnd(TRead,TUint8* anEnd);
williamr@2
   423
	inline void SetEnd(TWrite,TUint8* anEnd);
williamr@2
   424
	inline TUint8* Ptr(TRead) const;
williamr@2
   425
	inline TUint8* Ptr(TWrite) const;
williamr@2
   426
	inline TUint8* End(TRead) const;
williamr@2
   427
	inline TUint8* End(TWrite) const;
williamr@2
   428
	inline TInt Avail(TRead) const;
williamr@2
   429
	inline TInt Avail(TWrite) const;
williamr@2
   430
private:
williamr@2
   431
	/** Re-fills the intermediate buffer and resets the start and end points 
williamr@2
   432
	of the read area.
williamr@2
   433
	
williamr@2
   434
	The implementation of this function depends on the way the stream itself is 
williamr@2
   435
	implemented. For example, the in-memory streams have simple implementations.
williamr@2
   436
	
williamr@2
   437
	@param aMaxLength The maximum amount of data required for the intermediate 
williamr@2
   438
	buffer.
williamr@2
   439
	@return The amount of data available in the intermediate buffer. */
williamr@2
   440
	virtual TInt UnderflowL(TInt aMaxLength)=0;
williamr@2
   441
williamr@2
   442
	/** Empties the intermediate buffer and resets the start and end points 
williamr@2
   443
	of the write area.
williamr@2
   444
	
williamr@2
   445
	The implementation of this function depends on the way the stream itself is 
williamr@2
   446
	implemented. For example, the in-memory streams have simple implementations. */
williamr@2
   447
	virtual void OverflowL()=0;
williamr@2
   448
private:
williamr@2
   449
	TUint8* iRPtr;
williamr@2
   450
	TUint8* iREnd;
williamr@2
   451
	TUint8* iWPtr;
williamr@2
   452
	TUint8* iWEnd;
williamr@2
   453
	};
williamr@2
   454
williamr@2
   455
/**
williamr@2
   456
 * @publishedAll 
williamr@2
   457
 * @released
williamr@2
   458
 * Interface to a stream filter.
williamr@2
   459
williamr@2
   460
A stream filter is an object that allows stream data to be filtered after 
williamr@2
   461
retrieval from a host or filtered before being written to a host.
williamr@2
   462
williamr@2
   463
The class is abstract and a derived class must be defined an implemented.  
williamr@2
   464
*/
williamr@2
   465
class TStreamFilter : public MStreamBuf
williamr@2
   466
	{
williamr@2
   467
public:
williamr@2
   468
	enum {EAttached=0x10};
williamr@2
   469
protected:
williamr@2
   470
	IMPORT_C TStreamFilter();
williamr@2
   471
	inline void Set(MStreamBuf* aHost,TInt aMode);
williamr@2
   472
	inline void Committed();
williamr@2
   473
	inline TBool IsCommitted() const;
williamr@2
   474
	IMPORT_C void EmitL(const TAny* aPtr,TInt aLength);
williamr@2
   475
//
williamr@2
   476
	IMPORT_C void DoRelease();
williamr@2
   477
	IMPORT_C void DoSynchL();
williamr@2
   478
	IMPORT_C TInt DoReadL(TAny* aPtr,TInt aMaxLength);
williamr@2
   479
	IMPORT_C void DoWriteL(const TAny* aPtr,TInt aLength);
williamr@2
   480
private:
williamr@2
   481
	/** Calculates the maximum size of unfiltered data necessary to give the 
williamr@2
   482
	specified amount of filtered data.
williamr@2
   483
	
williamr@2
   484
	@param aMaxLength The amount of filtered data required.
williamr@2
   485
	@return The maximum amount of unfiltered data guaranteed not to generate 
williamr@2
   486
	more than aMaxLength bytes of filtered output. */
williamr@2
   487
	virtual TInt Capacity(TInt aMaxLength)=0;
williamr@2
   488
williamr@2
   489
	/** Performs the filtration process.
williamr@2
   490
	
williamr@2
   491
	@param aPtr Pointer to the output location for the filtered data.
williamr@2
   492
	@param aMaxLength The maximum amount of space available for the filtered 
williamr@2
   493
	data.
williamr@2
   494
	@param aFrom A reference to a pointer to the unfiltered data source. This 
williamr@2
   495
	pointer should be advanced as the source is consumed.
williamr@2
   496
	@param anEnd Pointer to the first byte beyond the end of the unfiltered 
williamr@2
   497
	data source.
williamr@2
   498
	@return The size of the filtered data. */
williamr@2
   499
	virtual TInt FilterL(TAny* aPtr,TInt aMaxLength,const TUint8*& aFrom,const TUint8* anEnd)=0;
williamr@2
   500
private:
williamr@2
   501
	MStreamBuf* iHost;
williamr@2
   502
	TInt iMode;
williamr@2
   503
private:
williamr@2
   504
	friend class TFilterInput;
williamr@2
   505
	friend class TFilterOutput;
williamr@2
   506
private:
williamr@2
   507
	IMPORT_C static void __DbgChkMode(TInt aMode);
williamr@2
   508
	};
williamr@2
   509
williamr@2
   510
#include <s32buf.inl>
williamr@2
   511
#endif