Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions
nsUnicharInputStream.cpp File Reference
#include "nsIUnicharInputStream.h"
#include "nsIInputStream.h"
#include "nsIByteBuffer.h"
#include "nsIUnicharBuffer.h"
#include "nsIServiceManager.h"
#include "nsString.h"
#include "nsCRT.h"
#include "nsUTF8Utils.h"
#include <fcntl.h>
#include <unistd.h>

Go to the source code of this file.

Classes

class  StringUnicharInputStream
class  UTF8InputStream

Functions

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)
 Create a new nsUnicharInputStream that provides a converter for the byte input stream aStreamToWrap.

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: