Back to index

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

List of all members.

Public Member Functions

 nsStringInputStream ()
void setData (in string data, in long dataLen)
 SetData - assign data to the input stream (copied on assignment).
void adoptData (in charPtr data, in long dataLen)
 NOTE: the following methods are designed to give C++ code added control over the ownership and lifetime of the stream data.
void shareData (in string data, in long dataLen)
 ShareData - assign data to the input stream.
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

PRInt32 LengthRemaining () const
void Clear ()

Protected Attributes

PRUint32 mOffset
nsresult mLastResult
PRPackedBool mEOF
PRPackedBool mOwned
const char * mConstString
PRUint32 mLength

Private Member Functions

 ~nsStringInputStream ()

Detailed Description

Definition at line 77 of file nsStringStream.cpp.


Constructor & Destructor Documentation

Definition at line 82 of file nsStringStream.cpp.

Definition at line 92 of file nsStringStream.cpp.

    {
        if (mOwned)
            nsMemory::Free((char*)mConstString);
    }

Member Function Documentation

void nsIStringInputStream::adoptData ( in charPtr  data,
in long  dataLen 
) [inherited]

NOTE: the following methods are designed to give C++ code added control over the ownership and lifetime of the stream data.

Use with care :-) AdoptData - assign data to the input stream. the input stream takes ownership of the given data buffer and will nsMemory::Free it when the input stream is destroyed.

Parameters:
data- stream data
dataLen- stream data length (-1 if length should be computed)
unsigned long nsIInputStream::available ( ) [inherited]
Returns:
number of bytes currently available in the stream
void nsStringInputStream::Clear ( void  ) [inline, protected]

Definition at line 110 of file nsStringStream.cpp.

    {
        NS_ASSERTION(mConstString || !mOwned,
                     "Can't have mOwned set and have a null string!");
        if (mOwned)
            nsMemory::Free((char*)mConstString);

        // We're about to get a new string; clear the members that
        // would no longer have valid values.
        mOffset = 0;
        mLastResult = NS_OK;
        mEOF = PR_FALSE;
    }
void nsIInputStream::close ( ) [inherited]

Close the stream.

Returns:
true if stream is non-blocking
PRInt32 nsStringInputStream::LengthRemaining ( ) const [inline, protected]

Definition at line 105 of file nsStringStream.cpp.

    {
        return mLength - mOffset;
    }
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.
void nsIStringInputStream::setData ( in string  data,
in long  dataLen 
) [inherited]

SetData - assign data to the input stream (copied on assignment).

Parameters:
data- stream data
dataLen- stream data length (-1 if length should be computed)

NOTE: C++ code should consider using AdoptData or ShareData to avoid making an extra copy of the stream data.

setEOF

This method truncates the stream at the current offset.

void nsIStringInputStream::shareData ( in string  data,
in long  dataLen 
) [inherited]

ShareData - assign data to the input stream.

the input stream references the given data buffer until the input stream is destroyed. the given data buffer must outlive the input stream.

Parameters:
data- stream data
dataLen- stream data length (-1 if length should be computed)

tell

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


Member Data Documentation

Definition at line 128 of file nsStringStream.cpp.

Definition at line 126 of file nsStringStream.cpp.

Definition at line 125 of file nsStringStream.cpp.

Definition at line 129 of file nsStringStream.cpp.

Definition at line 124 of file nsStringStream.cpp.

Definition at line 127 of file nsStringStream.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: