Back to index

lightning-sunbird  0.9+nobinonly
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes
nsMultiplexInputStream Class Reference

The multiplex stream concatenates a list of input streams into a single stream. More...

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

List of all members.

Classes

struct  ReadSegmentsState

Public Member Functions

 nsMultiplexInputStream ()
void appendStream (in nsIInputStream stream)
 Appends a stream to the end of the streams.
void insertStream (in nsIInputStream stream, in unsigned long index)
 Insert a stream at specified index.
void removeStream (in unsigned long index)
 Remove stream at specified index.
nsIInputStream getStream (in unsigned long index)
 Get stream at specified index.
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 ()
void seek (in long whence, in long long offset)
 seek
long long tell ()
 tell
void setEOF ()
 setEOF

Static Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSIINPUTSTREAM
NS_DECL_NSIMULTIPLEXINPUTSTREAM
static
NS_DECL_NSISEEKABLESTREAM
NS_METHOD 
Create (nsISupports *outer, REFNSIID iid, void **result)

Public Attributes

readonly attribute unsigned long count
 Number of streams in this multiplex-stream.
const PRInt32 NS_SEEK_SET = 0
const PRInt32 NS_SEEK_CUR = 1
const PRInt32 NS_SEEK_END = 2

Private Member Functions

 ~nsMultiplexInputStream ()

Static Private Member Functions

static NS_METHOD ReadSegCb (nsIInputStream *aIn, void *aClosure, const char *aFromRawSegment, PRUint32 aToOffset, PRUint32 aCount, PRUint32 *aWriteCount)

Private Attributes

nsSupportsArray mStreams
PRUint32 mCurrentStream
PRBool mStartedReadingCurrent

Detailed Description

The multiplex stream concatenates a list of input streams into a single stream.

Definition at line 50 of file nsMultiplexInputStream.cpp.


Class Documentation

struct nsMultiplexInputStream::ReadSegmentsState

Definition at line 67 of file nsMultiplexInputStream.cpp.

Collaboration diagram for nsMultiplexInputStream::ReadSegmentsState:
Class Members
void * mClosure
PRBool mDone
PRUint32 mOffset
nsIInputStream * mThisStream
nsWriteSegmentFun mWriter

Constructor & Destructor Documentation

Definition at line 64 of file nsMultiplexInputStream.cpp.

{}

Member Function Documentation

Appends a stream to the end of the streams.

The cursor of the stream should be located at the beginning of the stream if the implementation of this nsIMultiplexInputStream also is used as an nsISeekableStream.

Parameters:
streamstream to append
unsigned long nsIInputStream::available ( ) [inherited]
Returns:
number of bytes currently available in the stream
void nsIInputStream::close ( ) [inherited]

Close the stream.

NS_DECL_ISUPPORTS NS_DECL_NSIINPUTSTREAM NS_DECL_NSIMULTIPLEXINPUTSTREAM static NS_DECL_NSISEEKABLESTREAM NS_METHOD nsMultiplexInputStream::Create ( nsISupports *  outer,
REFNSIID  iid,
void **  result 
) [static]
nsIInputStream nsIMultiplexInputStream::getStream ( in unsigned long  index) [inherited]

Get stream at specified index.

Parameters:
indexreturn stream at this index, must be < count
Returns:
stream at specified index
void nsIMultiplexInputStream::insertStream ( in nsIInputStream  stream,
in unsigned long  index 
) [inherited]

Insert a stream at specified index.

If the cursor of this stream is at the beginning of the stream at index, the cursor will be placed at the beginning of the inserted stream instead. The cursor of the new stream should be located at the beginning of the stream if the implementation of this nsIMultiplexInputStream also is used as an nsISeekableStream.

Parameters:
streamstream to insert
indexindex to insert stream at, must be <= count
Returns:
true if stream is non-blocking
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_METHOD nsMultiplexInputStream::ReadSegCb ( nsIInputStream aIn,
void aClosure,
const char *  aFromRawSegment,
PRUint32  aToOffset,
PRUint32  aCount,
PRUint32 aWriteCount 
) [static, private]

Definition at line 276 of file nsMultiplexInputStream.cpp.

{
    nsresult rv;
    ReadSegmentsState* state = (ReadSegmentsState*)aClosure;
    rv = (state->mWriter)(state->mThisStream,
                          state->mClosure,
                          aFromRawSegment,
                          aToOffset + state->mOffset,
                          aCount,
                          aWriteCount);
    if (NS_FAILED(rv))
        state->mDone = PR_TRUE;
    return rv;
}
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).

void nsIMultiplexInputStream::removeStream ( in unsigned long  index) [inherited]

Remove stream at specified index.

If this stream is the one currently being read the readcursor is moved to the beginning of the next stream

Parameters:
indexremove stream at this index, must be < count
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

readonly attribute unsigned long nsIMultiplexInputStream::count [inherited]

Number of streams in this multiplex-stream.

Definition at line 52 of file nsIMultiplexInputStream.idl.

Definition at line 80 of file nsMultiplexInputStream.cpp.

Definition at line 81 of file nsMultiplexInputStream.cpp.

nsSupportsArray nsMultiplexInputStream::mStreams [private]

Definition at line 79 of file nsMultiplexInputStream.cpp.

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 file: