Bug 414901, back out scriptable IO api, r+sr=bsmedberg,a=beltzner
git-svn-id: svn://10.0.0.236/trunk@244609 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -51,7 +51,6 @@
|
||||
#include "nsIProperties.h"
|
||||
#include "nsPersistentProperties.h"
|
||||
#include "nsScriptableInputStream.h"
|
||||
#include "nsScriptableOutputStream.h"
|
||||
#include "nsBinaryStream.h"
|
||||
#include "nsStorageStream.h"
|
||||
#include "nsPipe.h"
|
||||
@@ -245,9 +244,6 @@ NS_DECL_CLASSINFO(nsThreadManager)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsThreadPool)
|
||||
NS_DECL_CLASSINFO(nsThreadPool)
|
||||
|
||||
NS_DECL_CLASSINFO(nsScriptableInputStream)
|
||||
NS_DECL_CLASSINFO(nsScriptableOutputStream)
|
||||
|
||||
static NS_METHOD
|
||||
nsXPTIInterfaceInfoManagerGetSingleton(nsISupports* outer,
|
||||
const nsIID& aIID,
|
||||
@@ -355,10 +351,7 @@ static const nsModuleComponentInfo components[] = {
|
||||
COMPONENT(ERRORSERVICE, nsErrorService::Create),
|
||||
|
||||
COMPONENT(BYTEBUFFER, ByteBufferImpl::Create),
|
||||
COMPONENT_CI(SCRIPTABLEINPUTSTREAM, nsScriptableInputStream::Create,
|
||||
nsScriptableInputStream),
|
||||
COMPONENT_CI(SCRIPTABLEOUTPUTSTREAM, nsScriptableOutputStream::Create,
|
||||
nsScriptableOutputStream),
|
||||
COMPONENT(SCRIPTABLEINPUTSTREAM, nsScriptableInputStream::Create),
|
||||
COMPONENT(BINARYINPUTSTREAM, nsBinaryInputStreamConstructor),
|
||||
COMPONENT(BINARYOUTPUTSTREAM, nsBinaryOutputStreamConstructor),
|
||||
COMPONENT(STORAGESTREAM, nsStorageStreamConstructor),
|
||||
|
||||
@@ -73,7 +73,6 @@ CPPSRCS = \
|
||||
nsPipe3.cpp \
|
||||
nsStreamUtils.cpp \
|
||||
nsScriptableInputStream.cpp \
|
||||
nsScriptableOutputStream.cpp \
|
||||
nsSegmentedBuffer.cpp \
|
||||
SpecialSystemDirectory.cpp \
|
||||
nsStorageStream.cpp \
|
||||
@@ -174,7 +173,6 @@ SDK_XPIDLSRCS = \
|
||||
nsIInputStream.idl \
|
||||
nsIOutputStream.idl \
|
||||
nsIScriptableInputStream.idl \
|
||||
nsIScriptableStreams.idl \
|
||||
$(NULL)
|
||||
|
||||
SDK_HEADERS = \
|
||||
|
||||
@@ -51,7 +51,6 @@
|
||||
#include "nsISimpleEnumerator.h"
|
||||
#include "nsIDirectoryEnumerator.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIProgrammingLanguage.h"
|
||||
#include "prtypes.h"
|
||||
#include "prio.h"
|
||||
|
||||
@@ -616,22 +615,11 @@ nsLocalFile::nsLocalFileConstructor(nsISupports* outer, const nsIID& aIID, void*
|
||||
// nsLocalFile::nsISupports
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
NS_IMPL_THREADSAFE_ADDREF(nsLocalFile)
|
||||
NS_IMPL_THREADSAFE_RELEASE(nsLocalFile)
|
||||
NS_IMPL_QUERY_INTERFACE5_CI(nsLocalFile,
|
||||
nsILocalFile,
|
||||
nsIFile,
|
||||
nsILocalFileOS2,
|
||||
nsIHashable,
|
||||
nsIClassInfo)
|
||||
NS_IMPL_CI_INTERFACE_GETTER4(nsLocalFile,
|
||||
nsILocalFile,
|
||||
nsIFile,
|
||||
nsILocalFileOS2,
|
||||
nsIHashable)
|
||||
|
||||
NS_DECL_CLASSINFO(nsLocalFile)
|
||||
NS_IMPL_THREADSAFE_CI(nsLocalFile)
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS4(nsLocalFile,
|
||||
nsILocalFile,
|
||||
nsIFile,
|
||||
nsILocalFileOS2,
|
||||
nsIHashable)
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -73,9 +73,7 @@
|
||||
class TypeEaEnumerator;
|
||||
|
||||
class NS_COM nsLocalFile : public nsILocalFileOS2,
|
||||
public nsIHashable,
|
||||
public nsIClassInfo
|
||||
|
||||
public nsIHashable
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_CID_ACCESSOR(NS_LOCAL_FILE_CID)
|
||||
@@ -99,9 +97,6 @@ public:
|
||||
// nsIHashable interface
|
||||
NS_DECL_NSIHASHABLE
|
||||
|
||||
// nsIClassInfo interface
|
||||
NS_DECL_NSICLASSINFO
|
||||
|
||||
public:
|
||||
static void GlobalInit();
|
||||
static void GlobalShutdown();
|
||||
|
||||
@@ -48,8 +48,6 @@
|
||||
#include "nsISimpleEnumerator.h"
|
||||
#include "nsITimelineService.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsIClassInfoImpl.h"
|
||||
#include "nsIProgrammingLanguage.h"
|
||||
|
||||
#include "plbase64.h"
|
||||
#include "prmem.h"
|
||||
@@ -347,23 +345,12 @@ nsLocalFile::~nsLocalFile()
|
||||
#pragma mark -
|
||||
#pragma mark [nsISupports]
|
||||
|
||||
NS_IMPL_THREADSAFE_ADDREF(nsLocalFile)
|
||||
NS_IMPL_THREADSAFE_RELEASE(nsLocalFile)
|
||||
NS_IMPL_QUERY_INTERFACE5_CI(nsLocalFile,
|
||||
nsILocalFileMac,
|
||||
nsILocalFile,
|
||||
nsIFile,
|
||||
nsIHashable,
|
||||
nsIClassInfo)
|
||||
NS_IMPL_CI_INTERFACE_GETTER4(nsLocalFile,
|
||||
nsILocalFileMac,
|
||||
nsILocalFile,
|
||||
nsIFile,
|
||||
nsIHashable)
|
||||
|
||||
NS_DECL_CLASSINFO(nsLocalFile)
|
||||
NS_IMPL_THREADSAFE_CI(nsLocalFile)
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS4(nsLocalFile,
|
||||
nsILocalFileMac,
|
||||
nsILocalFile,
|
||||
nsIFile,
|
||||
nsIHashable)
|
||||
|
||||
NS_METHOD nsLocalFile::nsLocalFileConstructor(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aInstancePtr);
|
||||
|
||||
@@ -58,8 +58,7 @@ class nsDirEnumerator;
|
||||
//*****************************************************************************
|
||||
|
||||
class NS_COM nsLocalFile : public nsILocalFileMac,
|
||||
public nsIHashable,
|
||||
public nsIClassInfo
|
||||
public nsIHashable
|
||||
{
|
||||
friend class nsDirEnumerator;
|
||||
|
||||
@@ -75,7 +74,6 @@ public:
|
||||
NS_DECL_NSILOCALFILE
|
||||
NS_DECL_NSILOCALFILEMAC
|
||||
NS_DECL_NSIHASHABLE
|
||||
NS_DECL_NSICLASSINFO
|
||||
|
||||
public:
|
||||
|
||||
|
||||
@@ -81,7 +81,6 @@
|
||||
#include "nsIDirectoryEnumerator.h"
|
||||
#include "nsISimpleEnumerator.h"
|
||||
#include "nsITimelineService.h"
|
||||
#include "nsIProgrammingLanguage.h"
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK2
|
||||
#include "nsIGnomeVFSService.h"
|
||||
@@ -258,20 +257,10 @@ nsLocalFile::nsLocalFile(const nsLocalFile& other)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ADDREF(nsLocalFile)
|
||||
NS_IMPL_THREADSAFE_RELEASE(nsLocalFile)
|
||||
NS_IMPL_QUERY_INTERFACE4_CI(nsLocalFile,
|
||||
nsILocalFile,
|
||||
nsIFile,
|
||||
nsIHashable,
|
||||
nsIClassInfo)
|
||||
NS_IMPL_CI_INTERFACE_GETTER3(nsLocalFile,
|
||||
nsILocalFile,
|
||||
nsIFile,
|
||||
nsIHashable)
|
||||
|
||||
NS_DECL_CLASSINFO(nsLocalFile)
|
||||
NS_IMPL_THREADSAFE_CI(nsLocalFile)
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS3(nsLocalFile,
|
||||
nsIFile,
|
||||
nsILocalFile,
|
||||
nsIHashable)
|
||||
|
||||
nsresult
|
||||
nsLocalFile::nsLocalFileConstructor(nsISupports *outer,
|
||||
|
||||
@@ -83,8 +83,7 @@
|
||||
#endif
|
||||
|
||||
class NS_COM nsLocalFile : public nsILocalFile,
|
||||
public nsIHashable,
|
||||
public nsIClassInfo
|
||||
public nsIHashable
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_CID_ACCESSOR(NS_LOCAL_FILE_CID)
|
||||
@@ -105,9 +104,6 @@ public:
|
||||
// nsIHashable
|
||||
NS_DECL_NSIHASHABLE
|
||||
|
||||
// nsIClassInfo
|
||||
NS_DECL_NSICLASSINFO
|
||||
|
||||
public:
|
||||
static void GlobalInit();
|
||||
static void GlobalShutdown();
|
||||
|
||||
@@ -47,7 +47,6 @@
|
||||
#include "nsLocalFile.h"
|
||||
#include "nsIDirectoryEnumerator.h"
|
||||
#include "nsNativeCharsetUtils.h"
|
||||
#include "nsIProgrammingLanguage.h"
|
||||
|
||||
#include "nsISimpleEnumerator.h"
|
||||
#include "nsIComponentManager.h"
|
||||
@@ -747,22 +746,11 @@ nsLocalFile::nsLocalFileConstructor(nsISupports* outer, const nsIID& aIID, void*
|
||||
// nsLocalFile::nsISupports
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
NS_IMPL_THREADSAFE_ADDREF(nsLocalFile)
|
||||
NS_IMPL_THREADSAFE_RELEASE(nsLocalFile)
|
||||
NS_IMPL_QUERY_INTERFACE5_CI(nsLocalFile,
|
||||
nsILocalFile,
|
||||
nsIFile,
|
||||
nsILocalFileWin,
|
||||
nsIHashable,
|
||||
nsIClassInfo)
|
||||
NS_IMPL_CI_INTERFACE_GETTER4(nsLocalFile,
|
||||
nsILocalFile,
|
||||
nsIFile,
|
||||
nsILocalFileWin,
|
||||
nsIHashable)
|
||||
|
||||
NS_DECL_CLASSINFO(nsLocalFile)
|
||||
NS_IMPL_THREADSAFE_CI(nsLocalFile)
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS4(nsLocalFile,
|
||||
nsILocalFile,
|
||||
nsIFile,
|
||||
nsILocalFileWin,
|
||||
nsIHashable)
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -64,8 +64,7 @@ DEFINE_OLEGUID(IID_IPersistFile, 0x0000010BL, 0, 0);
|
||||
#include <sys/stat.h>
|
||||
|
||||
class nsLocalFile : public nsILocalFileWin,
|
||||
public nsIHashable,
|
||||
public nsIClassInfo
|
||||
public nsIHashable
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_CID_ACCESSOR(NS_LOCAL_FILE_CID)
|
||||
@@ -89,9 +88,6 @@ public:
|
||||
// nsIHashable interface
|
||||
NS_DECL_NSIHASHABLE
|
||||
|
||||
// nsIClassInfo interface
|
||||
NS_DECL_NSICLASSINFO
|
||||
|
||||
public:
|
||||
static void GlobalInit();
|
||||
static void GlobalShutdown();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@@ -36,335 +36,67 @@
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsScriptableInputStream.h"
|
||||
#include "nsIProgrammingLanguage.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsMemory.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIUnicharLineInputStream.h"
|
||||
#include "nsIClassInfoImpl.h"
|
||||
|
||||
// needed for NS_SWAP macros
|
||||
#include "nsIStreamBufferAccess.h"
|
||||
|
||||
NS_IMPL_THREADSAFE_ADDREF(nsScriptableInputStream)
|
||||
NS_IMPL_THREADSAFE_RELEASE(nsScriptableInputStream)
|
||||
NS_IMPL_QUERY_INTERFACE5_CI(nsScriptableInputStream,
|
||||
nsIInputStream,
|
||||
nsIScriptableInputStream,
|
||||
nsIScriptableIOInputStream,
|
||||
nsISeekableStream,
|
||||
nsIMultiplexInputStream)
|
||||
NS_IMPL_CI_INTERFACE_GETTER5(nsScriptableInputStream,
|
||||
nsIInputStream,
|
||||
nsIScriptableInputStream,
|
||||
nsIScriptableIOInputStream,
|
||||
nsISeekableStream,
|
||||
nsIMultiplexInputStream)
|
||||
NS_IMPL_ISUPPORTS1(nsScriptableInputStream, nsIScriptableInputStream)
|
||||
|
||||
// nsIBaseStream methods
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInputStream::Close(void)
|
||||
{
|
||||
if (mUnicharInputStream)
|
||||
return mUnicharInputStream->Close();
|
||||
|
||||
if (mInputStream)
|
||||
nsScriptableInputStream::Close(void) {
|
||||
if (!mInputStream) return NS_ERROR_NOT_INITIALIZED;
|
||||
return mInputStream->Close();
|
||||
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInputStream::InitWithStreams(nsIInputStream *aInputStream,
|
||||
nsIUnicharInputStream *aCharStream)
|
||||
{
|
||||
NS_ENSURE_ARG(aInputStream);
|
||||
mInputStream = aInputStream;
|
||||
mUnicharInputStream = aCharStream;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIScriptableInputStream methods
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInputStream::Init(nsIInputStream *aInputStream)
|
||||
{
|
||||
NS_ENSURE_ARG(aInputStream);
|
||||
mInputStream = aInputStream;
|
||||
mUnicharInputStream = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInputStream::Available(PRUint32 *aIsAvailable)
|
||||
{
|
||||
NS_ENSURE_TRUE(mInputStream, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
nsresult rv = mInputStream->Available(aIsAvailable);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// if there is no data left in the stream, check if the character stream
|
||||
// has more text available. This is needed because the unichar stream
|
||||
// will read a buffer from the input stream, leaving it with no remaining
|
||||
// data, yet there is still text to read
|
||||
if (!*aIsAvailable && mUnicharInputStream)
|
||||
*aIsAvailable = mUnicharInputStreamHasMore;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInputStream::Read(PRUint32 aCount, char **_retval)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
PRUint32 count = 0;
|
||||
char *buffer = nsnull;
|
||||
|
||||
NS_ENSURE_TRUE(mInputStream, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
rv = mInputStream->Available(&count);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
count = PR_MIN(count, aCount);
|
||||
buffer = (char*)NS_Alloc(count+1); // make room for '\0'
|
||||
NS_ENSURE_TRUE(buffer, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
PRUint32 amtRead = 0;
|
||||
rv = mInputStream->Read(buffer, count, &amtRead);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_Free(buffer);
|
||||
return rv;
|
||||
}
|
||||
|
||||
buffer[amtRead] = '\0';
|
||||
*_retval = buffer;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIInputStream methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInputStream::IsNonBlocking(PRBool *aIsNonBlocking)
|
||||
{
|
||||
NS_ENSURE_TRUE(mInputStream, NS_ERROR_NOT_INITIALIZED);
|
||||
return mInputStream->IsNonBlocking(aIsNonBlocking);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInputStream::Read(char* aData,
|
||||
PRUint32 aCount,
|
||||
PRUint32 *aReadCount)
|
||||
{
|
||||
if (mUnicharInputStream) {
|
||||
// XXXndeakin implement this
|
||||
nsScriptableInputStream::Init(nsIInputStream *aInputStream) {
|
||||
if (!aInputStream) return NS_ERROR_NULL_POINTER;
|
||||
mInputStream = aInputStream;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (mInputStream)
|
||||
return mInputStream->Read(aData, aCount, aReadCount);
|
||||
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInputStream::ReadSegments(nsWriteSegmentFun aFn,
|
||||
void* aClosure,
|
||||
PRUint32 aCount,
|
||||
PRUint32 *aReadCount)
|
||||
{
|
||||
NS_ENSURE_TRUE(mInputStream, NS_ERROR_NOT_INITIALIZED);
|
||||
return mInputStream->ReadSegments(aFn, aClosure, aCount, aReadCount);
|
||||
nsScriptableInputStream::Available(PRUint32 *_retval) {
|
||||
if (!mInputStream) return NS_ERROR_NOT_INITIALIZED;
|
||||
return mInputStream->Available(_retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInputStream::ReadString(PRUint32 aCount, nsAString& aString)
|
||||
{
|
||||
if (mUnicharInputStream) {
|
||||
PRUint32 readCount;
|
||||
nsresult rv = mUnicharInputStream->ReadString(aCount, aString, &readCount);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsScriptableInputStream::Read(PRUint32 aCount, char **_retval) {
|
||||
nsresult rv = NS_OK;
|
||||
PRUint32 count = 0;
|
||||
char *buffer = nsnull;
|
||||
|
||||
// If less characters are read than requested, then assume that the end
|
||||
// of the file has been reached.
|
||||
// XXXndeakin or it could be because the buffer is full
|
||||
mUnicharInputStreamHasMore = (aCount == readCount);
|
||||
if (!mInputStream) return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
rv = mInputStream->Available(&count);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
count = PR_MIN(count, aCount);
|
||||
buffer = (char*)nsMemory::Alloc(count+1); // make room for '\0'
|
||||
if (!buffer) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
PRUint32 amtRead = 0;
|
||||
rv = mInputStream->Read(buffer, count, &amtRead);
|
||||
if (NS_FAILED(rv)) {
|
||||
nsMemory::Free(buffer);
|
||||
return rv;
|
||||
}
|
||||
|
||||
buffer[amtRead] = '\0';
|
||||
*_retval = buffer;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// just call Read and convert to UTF-16
|
||||
nsXPIDLCString cstr;
|
||||
nsresult rv = Read(aCount, getter_Copies(cstr));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
aString.Assign(NS_ConvertASCIItoUTF16(cstr));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInputStream::ReadLine(nsAString& aLine)
|
||||
{
|
||||
nsCOMPtr<nsIUnicharLineInputStream> cstream = do_QueryInterface(mUnicharInputStream);
|
||||
NS_ENSURE_TRUE(cstream, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
return cstream->ReadLine(aLine, &mUnicharInputStreamHasMore);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInputStream::ReadBoolean(PRBool* aBoolean)
|
||||
{
|
||||
PRUint8 byteResult;
|
||||
nsresult rv = Read8(&byteResult);
|
||||
*aBoolean = !!byteResult;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInputStream::Read8(PRUint8* aVal)
|
||||
{
|
||||
return ReadFully(sizeof *aVal, reinterpret_cast<char*>(aVal));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInputStream::Read16(PRUint16* aVal)
|
||||
{
|
||||
nsresult rv = ReadFully(sizeof *aVal, reinterpret_cast<char*>(aVal));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
*aVal = NS_SWAP16(*aVal);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInputStream::Read32(PRUint32* aVal)
|
||||
{
|
||||
nsresult rv = ReadFully(sizeof *aVal, reinterpret_cast<char*>(aVal));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
*aVal = NS_SWAP32(*aVal);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInputStream::ReadFloat(float* aFloat)
|
||||
{
|
||||
NS_ASSERTION(sizeof(float) == sizeof (PRUint32),
|
||||
"False assumption about sizeof(float)");
|
||||
return Read32(reinterpret_cast<PRUint32*>(aFloat));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInputStream::ReadDouble(double* aDouble)
|
||||
{
|
||||
NS_ASSERTION(sizeof(double) == sizeof(PRUint64),
|
||||
"False assumption about sizeof(double)");
|
||||
|
||||
nsresult rv = ReadFully(sizeof(double), reinterpret_cast<char*>(aDouble));
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
PRUint64 i = NS_SWAP64(*reinterpret_cast<PRUint64*>(aDouble));
|
||||
*aDouble = *reinterpret_cast<double*>(&i);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInputStream::ReadByteArray(PRUint32 aCount, PRUint8 **aBytes)
|
||||
{
|
||||
char* s = reinterpret_cast<char*>(NS_Alloc(aCount));
|
||||
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
PRUint32 bytesRead;
|
||||
nsresult rv = mInputStream->Read(s, aCount, &bytesRead);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_Free(s);
|
||||
return rv;
|
||||
}
|
||||
if (bytesRead != aCount) {
|
||||
NS_Free(s);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
*aBytes = (PRUint8 *)s;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsScriptableInputStream::ReadFully(PRUint32 aCount, char* aBuf)
|
||||
{
|
||||
PRUint32 bytesRead;
|
||||
nsresult rv = Read(aBuf, aCount, &bytesRead);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return (bytesRead != aCount) ? NS_ERROR_FAILURE : NS_OK;
|
||||
}
|
||||
|
||||
// nsISeekableStream
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInputStream::Seek(PRInt32 aWhence, PRInt64 aOffset)
|
||||
{
|
||||
nsCOMPtr<nsISeekableStream> cstream = do_QueryInterface(mInputStream);
|
||||
NS_ENSURE_TRUE(cstream, NS_ERROR_NOT_AVAILABLE);
|
||||
return cstream->Seek(aWhence, aOffset);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInputStream::Tell(PRInt64* aOffset)
|
||||
{
|
||||
nsCOMPtr<nsISeekableStream> cstream = do_QueryInterface(mInputStream);
|
||||
NS_ENSURE_TRUE(cstream, NS_ERROR_NOT_AVAILABLE);
|
||||
return cstream->Tell(aOffset);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInputStream::SetEOF()
|
||||
{
|
||||
nsCOMPtr<nsISeekableStream> cstream = do_QueryInterface(mInputStream);
|
||||
NS_ENSURE_TRUE(cstream, NS_ERROR_NOT_AVAILABLE);
|
||||
return cstream->SetEOF();
|
||||
}
|
||||
|
||||
// nsIMultiplexInputStream
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInputStream::GetCount(PRUint32* aCount)
|
||||
{
|
||||
nsCOMPtr<nsIMultiplexInputStream> cstream = do_QueryInterface(mInputStream);
|
||||
NS_ENSURE_TRUE(cstream, NS_ERROR_NOT_AVAILABLE);
|
||||
return cstream->GetCount(aCount);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInputStream::GetStream(PRUint32 aIndex, nsIInputStream** aStream)
|
||||
{
|
||||
nsCOMPtr<nsIMultiplexInputStream> cstream = do_QueryInterface(mInputStream);
|
||||
NS_ENSURE_TRUE(cstream, NS_ERROR_NOT_AVAILABLE);
|
||||
return cstream->GetStream(aIndex, aStream);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInputStream::AppendStream(nsIInputStream* aStream)
|
||||
{
|
||||
nsCOMPtr<nsIMultiplexInputStream> cstream = do_QueryInterface(mInputStream);
|
||||
NS_ENSURE_TRUE(cstream, NS_ERROR_NOT_AVAILABLE);
|
||||
return cstream->AppendStream(aStream);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInputStream::InsertStream(nsIInputStream* aStream, PRUint32 aIndex)
|
||||
{
|
||||
nsCOMPtr<nsIMultiplexInputStream> cstream = do_QueryInterface(mInputStream);
|
||||
NS_ENSURE_TRUE(cstream, NS_ERROR_NOT_AVAILABLE);
|
||||
return cstream->InsertStream(aStream, aIndex);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInputStream::RemoveStream(PRUint32 aIndex)
|
||||
{
|
||||
nsCOMPtr<nsIMultiplexInputStream> cstream = do_QueryInterface(mInputStream);
|
||||
NS_ENSURE_TRUE(cstream, NS_ERROR_NOT_AVAILABLE);
|
||||
return cstream->RemoveStream(aIndex);
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsScriptableInputStream::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
if (aOuter) return NS_ERROR_NO_AGGREGATION;
|
||||
nsScriptableInputStream::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult) {
|
||||
if (aOuter) return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
nsRefPtr<nsScriptableInputStream> sis = new nsScriptableInputStream();
|
||||
NS_ENSURE_TRUE(sis, NS_ERROR_OUT_OF_MEMORY);
|
||||
return sis->QueryInterface(aIID, aResult);
|
||||
nsScriptableInputStream *sis = new nsScriptableInputStream();
|
||||
if (!sis) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(sis);
|
||||
nsresult rv = sis->QueryInterface(aIID, aResult);
|
||||
NS_RELEASE(sis);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -39,11 +39,7 @@
|
||||
#define ___nsscriptableinputstream___h_
|
||||
|
||||
#include "nsIScriptableInputStream.h"
|
||||
#include "nsIScriptableStreams.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsISeekableStream.h"
|
||||
#include "nsIMultiplexInputStream.h"
|
||||
#include "nsIUnicharInputStream.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#define NS_SCRIPTABLEINPUTSTREAM_CID \
|
||||
@@ -52,41 +48,16 @@
|
||||
#define NS_SCRIPTABLEINPUTSTREAM_CONTRACTID "@mozilla.org/scriptableinputstream;1"
|
||||
#define NS_SCRIPTABLEINPUTSTREAM_CLASSNAME "Scriptable Input Stream"
|
||||
|
||||
class nsScriptableInputStream : public nsIScriptableInputStream,
|
||||
public nsIScriptableIOInputStream,
|
||||
public nsISeekableStream,
|
||||
public nsIMultiplexInputStream
|
||||
{
|
||||
class nsScriptableInputStream : public nsIScriptableInputStream {
|
||||
public:
|
||||
// nsISupports methods
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIScriptableIOInputStream methods
|
||||
NS_DECL_NSISCRIPTABLEIOINPUTSTREAM
|
||||
|
||||
// nsISeekableStream methods
|
||||
NS_DECL_NSISEEKABLESTREAM
|
||||
|
||||
// nsIMultiplexInputStream methods
|
||||
NS_DECL_NSIMULTIPLEXINPUTSTREAM
|
||||
|
||||
// nsIInputStream and nsIScriptableInputStream methods
|
||||
NS_IMETHOD Available(PRUint32 *aAvailable);
|
||||
NS_IMETHOD Close();
|
||||
NS_IMETHOD IsNonBlocking(PRBool *aIsNonBlocking);
|
||||
NS_IMETHOD Read(char* aData,
|
||||
PRUint32 aCount,
|
||||
PRUint32 *aReadCount);
|
||||
NS_IMETHOD ReadSegments(nsWriteSegmentFun aFn,
|
||||
void* aClosure,
|
||||
PRUint32 aCount,
|
||||
PRUint32 *aReadCount);
|
||||
NS_IMETHOD Init(nsIInputStream* aInputStream);
|
||||
NS_IMETHOD Read(PRUint32 aCount, char** aData);
|
||||
// nsIScriptableInputStream methods
|
||||
NS_DECL_NSISCRIPTABLEINPUTSTREAM
|
||||
|
||||
// nsScriptableInputStream methods
|
||||
nsScriptableInputStream() :
|
||||
mUnicharInputStreamHasMore(PR_TRUE) {}
|
||||
nsScriptableInputStream() {}
|
||||
|
||||
static NS_METHOD
|
||||
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
|
||||
@@ -94,11 +65,7 @@ public:
|
||||
private:
|
||||
~nsScriptableInputStream() {}
|
||||
|
||||
nsresult ReadFully(PRUint32 aCount, char* aBuf);
|
||||
|
||||
PRBool mUnicharInputStreamHasMore;
|
||||
nsCOMPtr<nsIInputStream> mInputStream;
|
||||
nsCOMPtr<nsIUnicharInputStream> mUnicharInputStream;
|
||||
};
|
||||
|
||||
#endif // ___nsscriptableinputstream___h_
|
||||
|
||||
@@ -1,261 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsScriptableOutputStream.h"
|
||||
#include "nsIProgrammingLanguage.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsMemory.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIClassInfoImpl.h"
|
||||
|
||||
// needed for NS_SWAP macros
|
||||
#include "nsIStreamBufferAccess.h"
|
||||
|
||||
NS_IMPL_THREADSAFE_ADDREF(nsScriptableOutputStream)
|
||||
NS_IMPL_THREADSAFE_RELEASE(nsScriptableOutputStream)
|
||||
NS_IMPL_QUERY_INTERFACE3_CI(nsScriptableOutputStream,
|
||||
nsIOutputStream,
|
||||
nsIScriptableIOOutputStream,
|
||||
nsISeekableStream)
|
||||
NS_IMPL_CI_INTERFACE_GETTER3(nsScriptableOutputStream,
|
||||
nsIOutputStream,
|
||||
nsIScriptableIOOutputStream,
|
||||
nsISeekableStream)
|
||||
|
||||
// nsIBaseStream methods
|
||||
NS_IMETHODIMP
|
||||
nsScriptableOutputStream::Close(void)
|
||||
{
|
||||
if (mUnicharOutputStream)
|
||||
return mUnicharOutputStream->Close();
|
||||
|
||||
if (mOutputStream)
|
||||
return mOutputStream->Close();
|
||||
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableOutputStream::Flush(void)
|
||||
{
|
||||
if (mUnicharOutputStream)
|
||||
return mUnicharOutputStream->Flush();
|
||||
|
||||
if (mOutputStream)
|
||||
return mOutputStream->Flush();
|
||||
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
// nsIScriptableIOOutputStream methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableOutputStream::InitWithStreams(nsIOutputStream* aOutputStream,
|
||||
nsIUnicharOutputStream *aCharStream)
|
||||
{
|
||||
NS_ENSURE_ARG(aOutputStream);
|
||||
|
||||
mOutputStream = aOutputStream;
|
||||
mUnicharOutputStream = aCharStream;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIOutputStream methods
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableOutputStream::IsNonBlocking(PRBool *aIsNonBlocking)
|
||||
{
|
||||
if (mOutputStream)
|
||||
return mOutputStream->IsNonBlocking(aIsNonBlocking);
|
||||
|
||||
if (mUnicharOutputStream) {
|
||||
*aIsNonBlocking = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableOutputStream::Write(const char* aBuffer, PRUint32 aCount, PRUint32 *aWriteCount)
|
||||
{
|
||||
if (mUnicharOutputStream) {
|
||||
nsAutoString str(NS_ConvertASCIItoUTF16(aBuffer, aCount));
|
||||
PRBool ok;
|
||||
mUnicharOutputStream->WriteString(str, &ok);
|
||||
*aWriteCount = ok ? aCount : 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (mOutputStream)
|
||||
return mOutputStream->Write(aBuffer, aCount, aWriteCount);
|
||||
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableOutputStream::WriteFrom(nsIInputStream *aStream, PRUint32 aCount, PRUint32 *aWriteCount)
|
||||
{
|
||||
if (mOutputStream)
|
||||
return mOutputStream->WriteFrom(aStream, aCount, aWriteCount);
|
||||
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableOutputStream::WriteSegments(nsReadSegmentFun aFn,
|
||||
void* aClosure,
|
||||
PRUint32 aCount,
|
||||
PRUint32 *aReadCount)
|
||||
{
|
||||
NS_ENSURE_TRUE(mOutputStream, NS_ERROR_NOT_INITIALIZED);
|
||||
return mOutputStream->WriteSegments(aFn, aClosure, aCount, aReadCount);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableOutputStream::WriteString(const nsAString& aString, PRBool *aOK)
|
||||
{
|
||||
if (mUnicharOutputStream)
|
||||
return mUnicharOutputStream->WriteString(aString, aOK);
|
||||
|
||||
if (!mOutputStream)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
// just convert to ASCII and call Write
|
||||
nsCAutoString cstr = NS_LossyConvertUTF16toASCII(aString);
|
||||
PRUint32 count;
|
||||
nsresult rv = mOutputStream->Write(cstr.get(), (PRUint32)cstr.Length(), &count);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
*aOK = (count == cstr.Length());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableOutputStream::WriteBoolean(PRBool aBoolean)
|
||||
{
|
||||
return Write8(aBoolean);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableOutputStream::Write8(PRUint8 aByte)
|
||||
{
|
||||
return WriteFully((const char *)&aByte, sizeof aByte);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableOutputStream::Write16(PRUint16 a16)
|
||||
{
|
||||
a16 = NS_SWAP16(a16);
|
||||
return WriteFully((const char *)&a16, sizeof a16);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableOutputStream::Write32(PRUint32 a32)
|
||||
{
|
||||
a32 = NS_SWAP32(a32);
|
||||
return WriteFully((const char *)&a32, sizeof a32);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableOutputStream::WriteFloat(float aFloat)
|
||||
{
|
||||
NS_ASSERTION(sizeof(float) == sizeof (PRUint32),
|
||||
"False assumption about sizeof(float)");
|
||||
return Write32(*reinterpret_cast<PRUint32*>(&aFloat));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableOutputStream::WriteDouble(double aDouble)
|
||||
{
|
||||
NS_ASSERTION(sizeof(double) == sizeof(PRUint64),
|
||||
"False assumption about sizeof(double)");
|
||||
|
||||
PRUint64 val = NS_SWAP64(*reinterpret_cast<PRUint64*>(&aDouble));
|
||||
return WriteFully(reinterpret_cast<char*>(&val), sizeof val);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableOutputStream::WriteByteArray(PRUint8 *aBytes, PRUint32 aCount)
|
||||
{
|
||||
return WriteFully((char *)aBytes, aCount);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsScriptableOutputStream::WriteFully(const char *aBuf, PRUint32 aCount)
|
||||
{
|
||||
NS_ENSURE_TRUE(mOutputStream, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
PRUint32 bytesWritten;
|
||||
nsresult rv = mOutputStream->Write(aBuf, aCount, &bytesWritten);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return (bytesWritten != aCount) ? NS_ERROR_FAILURE : NS_OK;
|
||||
}
|
||||
|
||||
// nsISeekableStream
|
||||
NS_IMETHODIMP
|
||||
nsScriptableOutputStream::Seek(PRInt32 aWhence, PRInt64 aOffset)
|
||||
{
|
||||
nsCOMPtr<nsISeekableStream> cstream = do_QueryInterface(mOutputStream);
|
||||
NS_ENSURE_TRUE(cstream, NS_ERROR_NOT_AVAILABLE);
|
||||
return cstream->Seek(aWhence, aOffset);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableOutputStream::Tell(PRInt64* aOffset)
|
||||
{
|
||||
nsCOMPtr<nsISeekableStream> cstream = do_QueryInterface(mOutputStream);
|
||||
NS_ENSURE_TRUE(cstream, NS_ERROR_NOT_AVAILABLE);
|
||||
return cstream->Tell(aOffset);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableOutputStream::SetEOF()
|
||||
{
|
||||
nsCOMPtr<nsISeekableStream> cstream = do_QueryInterface(mOutputStream);
|
||||
NS_ENSURE_TRUE(cstream, NS_ERROR_NOT_AVAILABLE);
|
||||
return cstream->SetEOF();
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsScriptableOutputStream::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
if (aOuter) return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
nsRefPtr<nsScriptableOutputStream> sos = new nsScriptableOutputStream();
|
||||
NS_ENSURE_TRUE(sos, NS_ERROR_OUT_OF_MEMORY);
|
||||
return sos->QueryInterface(aIID, aResult);
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef ___nsscriptableoutputstream___h_
|
||||
#define ___nsscriptableoutputstream___h_
|
||||
|
||||
#include "nsIScriptableStreams.h"
|
||||
#include "nsIOutputStream.h"
|
||||
#include "nsISeekableStream.h"
|
||||
#include "nsIUnicharOutputStream.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#define NS_SCRIPTABLEOUTPUTSTREAM_CID \
|
||||
{ 0xaea1cfe2, 0xf727, 0x4b94, { 0x93, 0xff, 0x41, 0x8d, 0x96, 0x87, 0x94, 0xd1 } }
|
||||
|
||||
#define NS_SCRIPTABLEOUTPUTSTREAM_CONTRACTID "@mozilla.org/scriptableoutputstream;1"
|
||||
#define NS_SCRIPTABLEOUTPUTSTREAM_CLASSNAME "Scriptable Output Stream"
|
||||
|
||||
class nsScriptableOutputStream : public nsIScriptableIOOutputStream,
|
||||
public nsISeekableStream,
|
||||
public nsIOutputStream
|
||||
{
|
||||
public:
|
||||
// nsISupports methods
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIOutputStream methods
|
||||
NS_DECL_NSIOUTPUTSTREAM
|
||||
|
||||
// nsIScriptableIOOutputStream methods
|
||||
NS_DECL_NSISCRIPTABLEIOOUTPUTSTREAM
|
||||
|
||||
// nsISeekableStream methods
|
||||
NS_DECL_NSISEEKABLESTREAM
|
||||
|
||||
// nsScriptableOutputStream methods
|
||||
nsScriptableOutputStream() {}
|
||||
|
||||
static NS_METHOD
|
||||
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
|
||||
|
||||
private:
|
||||
~nsScriptableOutputStream() {}
|
||||
|
||||
nsresult WriteFully(const char *aBuf, PRUint32 aCount);
|
||||
|
||||
nsCOMPtr<nsIOutputStream> mOutputStream;
|
||||
nsCOMPtr<nsIUnicharOutputStream> mUnicharOutputStream;
|
||||
};
|
||||
|
||||
#endif // ___nsscriptableoutputstream___h_
|
||||
Reference in New Issue
Block a user