Back to index

lightning-sunbird  0.9+nobinonly
Classes | Typedefs | Functions
nsIUnicharInputStream.idl File Reference
import "nsISupports.idl";
#include "nsStringFwd.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

interface  nsIUnicharInputStream
 Abstract unicode character input stream. More...

Typedefs

typedef NS_CALLBACKnsWriteUnicharSegmentFun )(nsIUnicharInputStream *aInStream, void *aClosure, const PRUnichar *aFromSegment, PRUint32 aToOffset, PRUint32 aCount, PRUint32 *aWriteCount)
 The signature of the writer function passed to ReadSegments.

Functions

native nsWriteUnicharSegmentFun (nsWriteUnicharSegmentFun)
NS_COM nsresult NS_NewStringUnicharInputStream (nsIUnicharInputStream **aInstancePtrResult, const nsAString *aString, PRBool aTakeOwnership)
 Create a nsIUnicharInputStream that wraps up a string.
NS_COM nsresult NS_NewUTF8ConverterStream (nsIUnicharInputStream **aInstancePtrResult, nsIInputStream *aStreamToWrap, PRInt32 aBufferSize=0)
 Create a new nsUnicharInputStream that provides a converter for the byte input stream aStreamToWrap.

Typedef Documentation

typedef NS_CALLBACK( nsWriteUnicharSegmentFun)(nsIUnicharInputStream *aInStream, void *aClosure, const PRUnichar *aFromSegment, PRUint32 aToOffset, PRUint32 aCount, PRUint32 *aWriteCount)

The signature of the writer function passed to ReadSegments.

This is the "consumer" of data that gets read from the stream's buffer.

Parameters:
aInStreamstream being read
aClosureopaque parameter passed to ReadSegments
aFromSegmentpointer to memory owned by the input stream
aToOffsetamount already read (since ReadSegments was called)
aCountlength of fromSegment
aWriteCountnumber of bytes read

Implementers should return the following:

Returns:
NS_OK and (*aWriteCount > 0) if consumed some data
<any-error> if not interested in consuming any data

Errors are never passed to the caller of ReadSegments.

NOTE: returning NS_OK and (*aWriteCount = 0) has undefined behavior.

Definition at line 63 of file nsIUnicharInputStream.idl.


Function Documentation

NS_COM nsresult NS_NewStringUnicharInputStream ( nsIUnicharInputStream **  aInstancePtrResult,
const nsAString *  aString,
PRBool  aTakeOwnership 
)

Create a nsIUnicharInputStream that wraps up a string.

Data is fed from the string out until the done. When this object is destroyed it destroys the string by calling |delete| on the pointer if aTakeOwnership is set. If aTakeOwnership is not set, you must ensure that the string outlives the stream!

Definition at line 176 of file nsUnicharInputStream.cpp.

{
  NS_ENSURE_ARG_POINTER(aString);
  NS_PRECONDITION(aInstancePtrResult, "null ptr");

  StringUnicharInputStream* it = new StringUnicharInputStream(aString,
                                                              aTakeOwnership);
  if (!it) {
    return NS_ERROR_OUT_OF_MEMORY;
  }

  NS_ADDREF(*aInstancePtrResult = it);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_COM nsresult NS_NewUTF8ConverterStream ( nsIUnicharInputStream **  aInstancePtrResult,
nsIInputStream aStreamToWrap,
PRInt32  aBufferSize = 0 
)

Create a new nsUnicharInputStream that provides a converter for the byte input stream aStreamToWrap.

If no converter can be found then nsnull is returned and the error code is set to NS_INPUTSTREAM_NO_CONVERTER.

Definition at line 443 of file nsUnicharInputStream.cpp.

{
  // Create converter input stream
  UTF8InputStream* it = new UTF8InputStream();
  if (nsnull == it) {
    return NS_ERROR_OUT_OF_MEMORY;
  }

  nsresult rv = it->Init(aStreamToWrap, aBufferSize);
  if (NS_FAILED(rv))
    return rv;

  return it->QueryInterface(NS_GET_IID(nsIUnicharInputStream), 
                            (void **) aInstancePtrResult);
}

Here is the call graph for this function:

Here is the caller graph for this function: