diff --git a/xpcom/io/nsFileStream.cpp b/xpcom/io/nsFileStream.cpp index f38ec090d5a5..ad2d8dee7181 100644 --- a/xpcom/io/nsFileStream.cpp +++ b/xpcom/io/nsFileStream.cpp @@ -266,33 +266,6 @@ nsInputStringStream::nsInputStringStream(const nsString& stringToRead) mStore = do_QueryInterface(mInputStream); } -//======================================================================================== -// nsOutputStringStream -//======================================================================================== - -//---------------------------------------------------------------------------------------- -nsOutputStringStream::nsOutputStringStream(char*& stringToChange) -//---------------------------------------------------------------------------------------- -{ - nsISupports* stream; - if (NS_FAILED(NS_NewCharOutputStream(&stream, &stringToChange))) - return; - mOutputStream = do_QueryInterface(stream); - mStore = do_QueryInterface(stream); - NS_RELEASE(stream); -} - -//---------------------------------------------------------------------------------------- -nsOutputStringStream::nsOutputStringStream(nsString& stringToChange) -//---------------------------------------------------------------------------------------- -{ - nsISupports* stream; - if (NS_FAILED(NS_NewStringOutputStream(&stream, stringToChange))) - return; - mOutputStream = do_QueryInterface(stream); - mStore = do_QueryInterface(stream); - NS_RELEASE(stream); -} //======================================================================================== // nsInputFileStream diff --git a/xpcom/io/nsFileStream.h b/xpcom/io/nsFileStream.h index 3ccc1713a7ca..8cc9250b226c 100644 --- a/xpcom/io/nsFileStream.h +++ b/xpcom/io/nsFileStream.h @@ -607,43 +607,6 @@ private: }; // class nsRandomAccessOutputStream -//======================================================================================== -class NS_COM nsOutputStringStream -//======================================================================================== -: public nsRandomAccessOutputStream -{ -public: - nsOutputStringStream(char*& stringToChange); - nsOutputStringStream(nsString& stringToChange); - - // Output streamers. Unfortunately, they don't inherit! - nsOutputStream& operator << (const char* buf) - { return nsOutputStream::operator << (buf); } - nsOutputStream& operator << (char ch) - { return nsOutputStream::operator << (ch); } - nsOutputStream& operator << (short val) - { return nsOutputStream::operator << (val); } - nsOutputStream& operator << (unsigned short val) - { return nsOutputStream::operator << (val); } - nsOutputStream& operator << (long val) - { return nsOutputStream::operator << (val); } - nsOutputStream& operator << (unsigned long val) - { return nsOutputStream::operator << (val); } - nsOutputStream& operator << (int val) - { return nsOutputStream::operator << (val); } - nsOutputStream& operator << (unsigned int val) - { return nsOutputStream::operator << (val); } - nsOutputStream& operator << (nsOutputStream& (*pf)(nsOutputStream&)) - { return nsOutputStream::operator << (pf); } - -private: - - // private and unimplemented to disallow copies and assigns - nsOutputStringStream(const nsOutputStringStream& rhs); - nsOutputStringStream& operator=(const nsOutputStringStream& rhs); - -}; // class nsOutputStringStream - //======================================================================================== class NS_COM nsOutputFileStream // Please read the comments at the top of this file diff --git a/xpcom/io/nsIStringStream.idl b/xpcom/io/nsIStringStream.idl index 0567bba38b70..93d98d4b585f 100644 --- a/xpcom/io/nsIStringStream.idl +++ b/xpcom/io/nsIStringStream.idl @@ -115,13 +115,6 @@ extern "C" NS_COM nsresult NS_NewCStringInputStream( // Factory method to get an nsInputStream from a cstring. Result will implement all the // file stream interfaces in nsIFileStream.h -//---------------------------------------------------------------------------------------- -extern "C" NS_COM nsresult NS_NewStringOutputStream( - nsISupports** aStreamResult, - nsString& aStringToChange); - // Factory method to get an nsOutputStream from a string. Result will implement all the - // file stream interfaces in nsIFileStream.h - //---------------------------------------------------------------------------------------- extern "C" NS_COM nsresult NS_NewCharInputStream( nsISupports** aStreamResult, @@ -136,19 +129,6 @@ extern "C" NS_COM nsresult NS_NewCharOutputStream( // Factory method to get an nsOutputStream to a string. Result will implement all the // file stream interfaces in nsIFileStream.h -//---------------------------------------------------------------------------------------- -extern "C" NS_COM nsresult NS_NewStringIOStream( - nsISupports** aStreamResult, - nsString& aStringToChange); - // Factory method to get an nsOutputStream to a string. Result will implement all the -// file stream interfaces in nsIFileStream.h - -//---------------------------------------------------------------------------------------- -extern "C" NS_COM nsresult NS_NewCharIOStream( - nsISupports** aStreamResult, - char** aStringToChange); - // Factory method to get an nsOutputStream to a string. Result will implement all the - // file stream interfaces in nsIFileStream.h //---------------------------------------------------------------------------------------- extern "C" NS_COM nsresult NS_NewByteInputStream( diff --git a/xpcom/io/nsStringStream.cpp b/xpcom/io/nsStringStream.cpp index 2d78e9f5b3e4..ec41d418021d 100644 --- a/xpcom/io/nsStringStream.cpp +++ b/xpcom/io/nsStringStream.cpp @@ -157,7 +157,7 @@ NS_IMETHODIMP BasicStringImpl::Seek(PRInt32 whence, PRInt32 offset) } mOffset = newPosition; return NS_OK; -} // StringImpl::Seek +} // BasicStringImpl::Seek //---------------------------------------------------------------------------------------- NS_IMETHODIMP BasicStringImpl::Tell(PRUint32* outWhere) @@ -329,77 +329,6 @@ class ConstCharImpl }; // class ConstCharImpl -//======================================================================================== -class CharImpl - : public ConstCharImpl -//======================================================================================== -{ - enum { kAllocQuantum = 256 }; - - public: - CharImpl(char** inString, PRInt32 inLength = -1) - : ConstCharImpl(*inString, inLength) - , mString(*inString) - , mAllocLength(mLength + 1) - , mOriginalLength(mLength) - { - if (!mString) - { - mAllocLength = kAllocQuantum; - mString = new char[mAllocLength]; - if (!mString) - { - mLastResult = NS_ERROR_OUT_OF_MEMORY; - return; - } - mConstString = mString; - *mString = '\0'; - - } - } - - ~CharImpl() - { - if (mString) - { - delete [] mString; - } - } - - virtual PRInt32 write(const char* buf, PRUint32 aCount) - { - if (!buf) - return 0; - PRInt32 maxCount = mAllocLength - 1 - mOffset; - if ((PRInt32)aCount > maxCount) - { - mAllocLength = aCount + 1 + mOffset + kAllocQuantum; - char* newString = new char[mAllocLength]; - if (!newString) - { - mLastResult = NS_ERROR_OUT_OF_MEMORY; - return 0; - } - memcpy(newString, mString, mLength); - delete [] mString; - mString = newString; - mConstString = newString; - } - memcpy(mString + mOffset, buf, aCount); - mOffset += aCount; - mLength += aCount; - if (mOffset > mOriginalLength) - mString[mOffset] = 0; - return aCount; - } - protected: - - char*& mString; - size_t mAllocLength; - size_t mOriginalLength; - -}; // class CharImpl - //======================================================================================== class ConstStringImpl : public ConstCharImpl @@ -430,49 +359,6 @@ class ConstStringImpl }; // class ConstStringImpl -//======================================================================================== -class StringImpl - : public ConstStringImpl -// This is wrong, since it really converts to 1-char strings. -//======================================================================================== -{ - public: - StringImpl(nsString& inString) - : ConstStringImpl(inString) - , mString(inString) - { - } - - protected: - - virtual PRInt32 write(const char* buf, PRUint32 count) - { - if (!buf) - return 0; - // Clone our string as chars - char* cstring = ToNewCString(mString); - // Make a CharImpl and do the write - CharImpl chars(&cstring, mString.Length()); - chars.Seek(PR_SEEK_SET, mOffset); - // Get the bytecount and result from the CharImpl - PRInt32 result = chars.write(buf,count); - mLastResult = chars.get_result(); - // Set our string to match the new chars - chars.Seek(PR_SEEK_SET, 0); - PRUint32 newLength; - chars.Available(&newLength); - mString.AssignWithConversion(cstring, newLength); - // Set our const string also... - delete [] (char*)mConstString; - mConstString = cstring; - return result; - } - protected: - - nsString& mString; - -}; // class StringImpl - NS_IMPL_THREADSAFE_ADDREF(BasicStringImpl) NS_IMPL_THREADSAFE_RELEASE(BasicStringImpl) @@ -525,27 +411,6 @@ extern "C" NS_COM nsresult NS_NewCStringInputStream( return NS_OK; } -//---------------------------------------------------------------------------------------- -extern "C" NS_COM nsresult NS_NewStringOutputStream( - nsISupports** aStreamResult, - nsString& aStringToChange) - // Factory method to get an nsOutputStream from a string. Result will implement all the - // file stream interfaces in nsIFileStream.h -//---------------------------------------------------------------------------------------- -{ - NS_PRECONDITION(aStreamResult != nsnull, "null ptr"); - if (! aStreamResult) - return NS_ERROR_NULL_POINTER; - - StringImpl* stream = new StringImpl(aStringToChange); - if (! stream) - return NS_ERROR_OUT_OF_MEMORY; - - NS_ADDREF(stream); - *aStreamResult = (nsISupports*)(void*)stream; - return NS_OK; -} - //---------------------------------------------------------------------------------------- extern "C" NS_COM nsresult NS_NewCharInputStream( nsISupports** aStreamResult, @@ -567,50 +432,6 @@ extern "C" NS_COM nsresult NS_NewCharInputStream( return NS_OK; } -//---------------------------------------------------------------------------------------- -extern "C" NS_COM nsresult NS_NewCharOutputStream( - nsISupports** aStreamResult, - char** aStringToChange) - // Factory method to get an nsOutputStream to a string. Result will implement all the - // file stream interfaces in nsIFileStream.h -//---------------------------------------------------------------------------------------- -{ - NS_PRECONDITION(aStreamResult != nsnull, "null ptr"); - NS_PRECONDITION(aStringToChange != nsnull, "null ptr"); - if (!aStreamResult || !aStringToChange) - return NS_ERROR_NULL_POINTER; - - CharImpl* stream = new CharImpl(aStringToChange); - if (! stream) - return NS_ERROR_OUT_OF_MEMORY; - - NS_ADDREF(stream); - *aStreamResult = (nsISupports*)(void*)stream; - return NS_OK; -} - -//---------------------------------------------------------------------------------------- -extern "C" NS_COM nsresult NS_NewStringIOStream( - nsISupports** aStreamResult, - nsString& aStringToChange) - // Factory method to get an nsOutputStream to a string. Result will implement all the -// file stream interfaces in nsIFileStream.h -//---------------------------------------------------------------------------------------- -{ - return NS_NewStringOutputStream(aStreamResult, aStringToChange); -} - -//---------------------------------------------------------------------------------------- -extern "C" NS_COM nsresult NS_NewCharIOStream( - nsISupports** aStreamResult, - char** aStringToChange) - // Factory method to get an nsOutputStream to a string. Result will implement all the - // file stream interfaces in nsIFileStream.h -//---------------------------------------------------------------------------------------- -{ - return NS_NewCharOutputStream(aStreamResult, aStringToChange); -} - //---------------------------------------------------------------------------------------- extern "C" NS_COM nsresult NS_NewByteInputStream( nsISupports** aStreamResult,