Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
nsBufferedStream Class Reference

#include <nsBufferedStreams.h>

Inheritance diagram for nsBufferedStream:
Inheritance graph
[legend]
Collaboration diagram for nsBufferedStream:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSISEEKABLESTREAM 
nsBufferedStream ()
virtual ~nsBufferedStream ()
nsresult Close ()
void seek (in long whence, in long long offset)
 seek
long long tell ()
 tell
void setEOF ()
 setEOF

Public Attributes

const PRInt32 NS_SEEK_SET = 0
const PRInt32 NS_SEEK_CUR = 1
const PRInt32 NS_SEEK_END = 2

Protected Member Functions

nsresult Init (nsISupports *stream, PRUint32 bufferSize)
NS_IMETHOD Fill ()=0
NS_IMETHOD Flush ()=0

Protected Attributes

PRUint32 mBufferSize
char * mBuffer
nsInt64 mBufferStartOffset
PRUint32 mCursor
PRUint32 mFillPoint
nsISupports * mStream
PRPackedBool mBufferDisabled
PRUint8 mGetBufferCount

Detailed Description

Definition at line 51 of file nsBufferedStreams.h.


Constructor & Destructor Documentation

Definition at line 80 of file nsBufferedStreams.cpp.

{
    Close();
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 104 of file nsBufferedStreams.cpp.

{
    NS_IF_RELEASE(mStream);
    if (mBuffer) {
        delete[] mBuffer;
        mBuffer = nsnull;
        mBufferSize = 0;
        mBufferStartOffset = 0;
        mCursor = 0;
        mFillPoint = 0;
    }
#ifdef METERING
    {
        static FILE *tfp;
        if (!tfp) {
            tfp = fopen("/tmp/bufstats", "w");
            if (tfp)
                setvbuf(tfp, NULL, _IOLBF, 0);
        }
        if (tfp) {
            fprintf(tfp, "seeks within buffer:    %u\n",
                    bufstats.mSeeksWithinBuffer);
            fprintf(tfp, "seeks outside buffer:   %u\n",
                    bufstats.mSeeksOutsideBuffer);
            fprintf(tfp, "buffer read on seek:    %u\n",
                    bufstats.mBufferReadUponSeek);
            fprintf(tfp, "buffer unread on seek:  %u\n",
                    bufstats.mBufferUnreadUponSeek);
            fprintf(tfp, "bytes read from buffer: %u\n",
                    bufstats.mBytesReadFromBuffer);
            for (PRUint32 i = 0; i < bufstats.mBigSeekIndex; i++) {
                fprintf(tfp, "bigseek[%u] = {old: %u, new: %u}\n",
                        i,
                        bufstats.mBigSeek[i].mOldOffset,
                        bufstats.mBigSeek[i].mNewOffset);
            }
        }
    }
#endif
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHOD nsBufferedStream::Fill ( ) [protected, pure virtual]
NS_IMETHOD nsBufferedStream::Flush ( ) [protected, pure virtual]

Implemented in nsBufferedInputStream.

nsresult nsBufferedStream::Init ( nsISupports *  stream,
PRUint32  bufferSize 
) [protected]

Definition at line 88 of file nsBufferedStreams.cpp.

{
    NS_ASSERTION(stream, "need to supply a stream");
    NS_ASSERTION(mStream == nsnull, "already inited");
    mStream = stream;
    NS_IF_ADDREF(mStream);
    mBufferSize = bufferSize;
    mBufferStartOffset = 0;
    mCursor = 0;
    mBuffer = new char[bufferSize];
    if (mBuffer == nsnull)
        return NS_ERROR_OUT_OF_MEMORY;
    return NS_OK;
}
void nsISeekableStream::seek ( in long  whence,
in long long  offset 
) [inherited]

seek

This method moves the stream offset of the steam implementing this interface.

Parameters:
whencespecifies how to interpret the 'offset' parameter in setting the stream offset associated with the implementing stream.
offsetspecifies a value, in bytes, that is used in conjunction with the 'whence' parameter to set the stream offset of the implementing stream. A negative value causes seeking in the reverse direction.

setEOF

This method truncates the stream at the current offset.

tell

This method reports the current offset, in bytes, from the start of the stream.


Member Data Documentation

char* nsBufferedStream::mBuffer [protected]

Definition at line 68 of file nsBufferedStreams.h.

Definition at line 84 of file nsBufferedStreams.h.

Definition at line 67 of file nsBufferedStreams.h.

Definition at line 71 of file nsBufferedStreams.h.

Definition at line 75 of file nsBufferedStreams.h.

Definition at line 80 of file nsBufferedStreams.h.

Definition at line 85 of file nsBufferedStreams.h.

nsISupports* nsBufferedStream::mStream [protected]

Definition at line 82 of file nsBufferedStreams.h.

Definition at line 62 of file nsISeekableStream.idl.

Definition at line 68 of file nsISeekableStream.idl.

Definition at line 56 of file nsISeekableStream.idl.


The documentation for this class was generated from the following files: