Added operator = (const char*) as a convenience. always copies argument string.

This commit is contained in:
beard%netscape.com 1999-09-11 23:00:38 +00:00
parent ed1120c53f
commit 87f3477863
6 changed files with 51 additions and 0 deletions

View File

@ -119,6 +119,18 @@ nsXPIDLCString::~nsXPIDLCString()
}
nsXPIDLCString& nsXPIDLCString::operator =(const char* aCString)
{
if (mBufOwner && mBuf)
XPIDL_FREE(mBuf);
mBuf = Copy(aCString);
mBufOwner = PR_TRUE;
return *this;
}
nsXPIDLCString::operator const char*()
{
return mBuf;

View File

@ -214,6 +214,11 @@ public:
virtual ~nsXPIDLCString();
/**
* Assign a single-byte string to this wrapper. Copies and owns the result.
*/
nsXPIDLCString& operator =(const char* aString);
/**
* Return a reference to the immutable single-byte string.
*/

View File

@ -119,6 +119,18 @@ nsXPIDLCString::~nsXPIDLCString()
}
nsXPIDLCString& nsXPIDLCString::operator =(const char* aCString)
{
if (mBufOwner && mBuf)
XPIDL_FREE(mBuf);
mBuf = Copy(aCString);
mBufOwner = PR_TRUE;
return *this;
}
nsXPIDLCString::operator const char*()
{
return mBuf;

View File

@ -214,6 +214,11 @@ public:
virtual ~nsXPIDLCString();
/**
* Assign a single-byte string to this wrapper. Copies and owns the result.
*/
nsXPIDLCString& operator =(const char* aString);
/**
* Return a reference to the immutable single-byte string.
*/

View File

@ -119,6 +119,18 @@ nsXPIDLCString::~nsXPIDLCString()
}
nsXPIDLCString& nsXPIDLCString::operator =(const char* aCString)
{
if (mBufOwner && mBuf)
XPIDL_FREE(mBuf);
mBuf = Copy(aCString);
mBufOwner = PR_TRUE;
return *this;
}
nsXPIDLCString::operator const char*()
{
return mBuf;

View File

@ -214,6 +214,11 @@ public:
virtual ~nsXPIDLCString();
/**
* Assign a single-byte string to this wrapper. Copies and owns the result.
*/
nsXPIDLCString& operator =(const char* aString);
/**
* Return a reference to the immutable single-byte string.
*/