Back to index

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

List of all members.

Public Member Functions

 nsStorageInputStream (nsStorageStream *aStorageStream, PRUint32 aSegmentSize)
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

Public Attributes

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

Protected Member Functions

NS_METHOD Seek (PRUint32 aPosition)

Private Member Functions

 ~nsStorageInputStream ()
PRUint32 SegNum (PRUint32 aPosition)
PRUint32 SegOffset (PRUint32 aPosition)

Private Attributes

nsStorageStreammStorageStream
const char * mReadCursor
const char * mSegmentEnd
PRUint32 mSegmentNum
PRUint32 mSegmentSize
PRUint32 mLogicalCursor

Friends

class nsStorageStream

Detailed Description

Definition at line 353 of file nsStorageStream.cpp.


Constructor & Destructor Documentation

nsStorageInputStream::nsStorageInputStream ( nsStorageStream aStorageStream,
PRUint32  aSegmentSize 
) [inline]

Definition at line 357 of file nsStorageStream.cpp.

        : mStorageStream(aStorageStream), mReadCursor(0),
          mSegmentEnd(0), mSegmentNum(0),
          mSegmentSize(aSegmentSize), mLogicalCursor(0)
       {
        NS_ADDREF(mStorageStream);
       }

Here is the call graph for this function:

Definition at line 370 of file nsStorageStream.cpp.


Member Function Documentation

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

Close the stream.

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
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 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.
NS_METHOD nsStorageInputStream::Seek ( PRUint32  aPosition) [protected]

Definition at line 519 of file nsStorageStream.cpp.

{
    nsInt64 pos = aOffset;

    switch (aWhence) {
    case NS_SEEK_SET:
        break;
    case NS_SEEK_CUR:
        pos += mLogicalCursor;
        break;
    case NS_SEEK_END:
        pos += mStorageStream->mLogicalLength;
        break;
    default:
        NS_NOTREACHED("unexpected whence value");
        return NS_ERROR_UNEXPECTED;
    }
    nsInt64 logicalCursor(mLogicalCursor);
    if (pos == logicalCursor)
        return NS_OK;

    return Seek(pos);
}

Here is the caller graph for this function:

PRUint32 nsStorageInputStream::SegNum ( PRUint32  aPosition) [inline, private]

Definition at line 388 of file nsStorageStream.cpp.

{return aPosition >> mStorageStream->mSegmentSizeLog2;}
PRUint32 nsStorageInputStream::SegOffset ( PRUint32  aPosition) [inline, private]

Definition at line 389 of file nsStorageStream.cpp.

{return aPosition & (mSegmentSize - 1);}

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.


Friends And Related Function Documentation

friend class nsStorageStream [friend]

Definition at line 378 of file nsStorageStream.cpp.


Member Data Documentation

Definition at line 386 of file nsStorageStream.cpp.

Definition at line 382 of file nsStorageStream.cpp.

Definition at line 383 of file nsStorageStream.cpp.

Definition at line 384 of file nsStorageStream.cpp.

Definition at line 385 of file nsStorageStream.cpp.

Definition at line 381 of file nsStorageStream.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: