not sure if this is the _best_ way to solve the problem, but I added a c-string version of |NS_NewStringInputStream|, which can't use overloading since it's |extern "C"|, so I named it |NS_NewCStringInputStream|.

This commit is contained in:
scc%netscape.com 2000-04-01 22:27:03 +00:00
Родитель 13d86b3341
Коммит f5dbd84938
2 изменённых файлов: 34 добавлений и 0 удалений

Просмотреть файл

@ -265,6 +265,12 @@ class ConstStringImpl
{ {
} }
ConstStringImpl(const nsCString& inString)
: ConstCharImpl(inString.ToNewCString(),
inString.Length())
{
}
~ConstStringImpl() ~ConstStringImpl()
{ {
Recycle((char*)mConstString); Recycle((char*)mConstString);
@ -381,6 +387,27 @@ extern "C" NS_COM nsresult NS_NewStringInputStream(
return NS_OK; return NS_OK;
} }
//----------------------------------------------------------------------------------------
extern "C" NS_COM nsresult NS_NewCStringInputStream(
nsISupports** aStreamResult,
const nsCString& aStringToRead)
// Factory method to get an nsInputStream from a cstring. Result will implement all the
// file stream interfaces in nsIFileStream.h
//----------------------------------------------------------------------------------------
{
NS_PRECONDITION(aStreamResult != nsnull, "null ptr");
if (! aStreamResult)
return NS_ERROR_NULL_POINTER;
ConstStringImpl* stream = new ConstStringImpl(aStringToRead);
if (! stream)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(stream);
*aStreamResult = (nsISupports*)(void*)stream;
return NS_OK;
}
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
extern "C" NS_COM nsresult NS_NewStringOutputStream( extern "C" NS_COM nsresult NS_NewStringOutputStream(
nsISupports** aStreamResult, nsISupports** aStreamResult,

Просмотреть файл

@ -33,6 +33,13 @@ extern "C" NS_COM nsresult NS_NewStringInputStream(
// Factory method to get an nsInputStream from a string. Result will implement all the // Factory method to get an nsInputStream from a string. Result will implement all the
// file stream interfaces in nsIFileStream.h // file stream interfaces in nsIFileStream.h
//----------------------------------------------------------------------------------------
extern "C" NS_COM nsresult NS_NewCStringInputStream(
nsISupports** aStreamResult,
const nsCString& aStringToRead);
// 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( extern "C" NS_COM nsresult NS_NewStringOutputStream(
nsISupports** aStreamResult, nsISupports** aStreamResult,