Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Attributes
ProxyStream Class Reference
Inheritance diagram for ProxyStream:
Inheritance graph
[legend]
Collaboration diagram for ProxyStream:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ProxyStream (void)
virtual ~ProxyStream (void)
NS_DECL_ISUPPORTS NS_IMETHOD Close (void)
NS_IMETHOD Available (PRUint32 *aLength)
NS_IMETHOD Read (char *aBuf, PRUint32 aCount, PRUint32 *aReadCount)
NS_IMETHOD ReadSegments (nsWriteSegmentFun writer, void *closure, PRUint32 count, PRUint32 *_retval)
NS_IMETHOD IsNonBlocking (PRBool *aNonBlocking)
void SetBuffer (const char *aBuffer, PRUint32 aSize)
void close ()
 Close the stream.
unsigned long available ()
unsigned long read (in charPtr aBuf, in unsigned long aCount)
 Read data from the stream.
unsigned long readSegments (in nsWriteSegmentFun aWriter, in voidPtr aClosure, in unsigned long aCount)
 Low-level read method that has access to the stream's underlying buffer.
boolean isNonBlocking ()

Private Attributes

const char * mBuffer
PRUint32 mSize
PRUint32 mIndex

Detailed Description

Definition at line 144 of file nsRDFXMLDataSource.cpp.


Constructor & Destructor Documentation

Definition at line 152 of file nsRDFXMLDataSource.cpp.

                      : mBuffer(nsnull)
    {
    }
virtual ProxyStream::~ProxyStream ( void  ) [inline, virtual]

Definition at line 156 of file nsRDFXMLDataSource.cpp.

                               {
    }

Member Function Documentation

unsigned long nsIInputStream::available ( ) [inherited]
Returns:
number of bytes currently available in the stream
NS_IMETHOD ProxyStream::Available ( PRUint32 aLength) [inline]

Definition at line 168 of file nsRDFXMLDataSource.cpp.

                                            {
        *aLength = mSize - mIndex;
        return NS_OK;
    }
void nsIInputStream::close ( ) [inherited]

Close the stream.

Definition at line 163 of file nsRDFXMLDataSource.cpp.

                           {
        return NS_OK;
    }

Here is the caller graph for this function:

Returns:
true if stream is non-blocking
NS_IMETHOD ProxyStream::IsNonBlocking ( PRBool aNonBlocking) [inline]

Definition at line 196 of file nsRDFXMLDataSource.cpp.

                                                   {
        *aNonBlocking = PR_TRUE;
        return NS_OK;
    }
unsigned long nsIInputStream::read ( in charPtr  aBuf,
in unsigned long  aCount 
) [inherited]

Read data from the stream.

Parameters:
aBufthe buffer into which the data is to be read
aCountthe maximum number of bytes to be read
Returns:
number of bytes read (may be less than aCount).
0 if reached end of file
Exceptions:
NS_BASE_STREAM_WOULD_BLOCKif reading from the input stream would block the calling thread (non-blocking mode only)
<other-error>on failure
NS_IMETHOD ProxyStream::Read ( char *  aBuf,
PRUint32  aCount,
PRUint32 aReadCount 
) [inline]

Definition at line 173 of file nsRDFXMLDataSource.cpp.

                                                                       {
        PRUint32 readCount = PR_MIN(aCount, (mSize-mIndex));
        
        memcpy(aBuf, mBuffer+mIndex, readCount);
        mIndex += readCount;
        
        *aReadCount = readCount;
        
        return NS_OK;
    }

Here is the call graph for this function:

unsigned long nsIInputStream::readSegments ( in nsWriteSegmentFun  aWriter,
in voidPtr  aClosure,
in unsigned long  aCount 
) [inherited]

Low-level read method that has access to the stream's underlying buffer.

The writer function may be called multiple times for segmented buffers. ReadSegments is expected to keep calling the writer until either there is nothing left to read or the writer returns an error. ReadSegments should not call the writer with zero bytes to consume.

Parameters:
aWriterthe "consumer" of the data to be read
aClosureopaque parameter passed to writer
aCountthe maximum number of bytes to be read
Returns:
number of bytes read (may be less than aCount)
0 if reached end of file (or if aWriter refused to consume data)
Exceptions:
NS_BASE_STREAM_WOULD_BLOCKif reading from the input stream would block the calling thread (non-blocking mode only)
<other-error>on failure

NOTE: this function may be unimplemented if a stream has no underlying buffer (e.g., socket input stream).

NS_IMETHOD ProxyStream::ReadSegments ( nsWriteSegmentFun  writer,
void closure,
PRUint32  count,
PRUint32 _retval 
) [inline]

Definition at line 184 of file nsRDFXMLDataSource.cpp.

                                                                                                         {
        PRUint32 readCount = PR_MIN(count, (mSize-mIndex));

        *_retval = 0;
        nsresult rv = writer (this, closure, mBuffer+mIndex, mIndex, readCount, _retval);
        if (NS_SUCCEEDED(rv))
            mIndex += *_retval;

        // do not propogate errors returned from writer!
        return NS_OK;
    }

Here is the call graph for this function:

void ProxyStream::SetBuffer ( const char *  aBuffer,
PRUint32  aSize 
) [inline]

Definition at line 202 of file nsRDFXMLDataSource.cpp.

                                                        {
        mBuffer = aBuffer;
        mSize = aSize;
        mIndex = 0;
    }

Here is the caller graph for this function:


Member Data Documentation

const char* ProxyStream::mBuffer [private]

Definition at line 147 of file nsRDFXMLDataSource.cpp.

Definition at line 149 of file nsRDFXMLDataSource.cpp.

Definition at line 148 of file nsRDFXMLDataSource.cpp.


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