Replace nsString with nsCString. Add routines for setting the ext froma comma delimenated list

This commit is contained in:
davidm%netscape.com 2000-04-19 04:45:30 +00:00
Родитель 5534d7ffa5
Коммит 699af3fa09
5 изменённых файлов: 46 добавлений и 10 удалений

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

@ -53,6 +53,10 @@ interface nsIMIMEInfo : nsISupports {
void GetFileExtensions(out PRInt32 elementCount,
[array, size_is(elementCount)] out string extensions);
/* Set File Extensions. Input is a comma deliminated list of extensions
*/
void SetFileExtensions( in string aExtensions );
/* Returns whether or not the given extension is
* associated with this MIME info.
*

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

@ -31,9 +31,8 @@ nsMIMEInfoImpl::nsMIMEInfoImpl() {
NS_INIT_REFCNT();
}
nsMIMEInfoImpl::nsMIMEInfoImpl(const char *aMIMEType) {
nsMIMEInfoImpl::nsMIMEInfoImpl(const char *aMIMEType) :mMIMEType( aMIMEType ){
NS_INIT_REFCNT();
mMIMEType.AssignWithConversion(aMIMEType);
}
PRUint32
@ -50,7 +49,7 @@ nsMIMEInfoImpl::GetFileExtensions(PRInt32 *elementCount, char ***extensions) {
if (!_retExts) return NS_ERROR_OUT_OF_MEMORY;
for (PRUint8 i=0; i < *elementCount; i++) {
nsString* ext = (nsString*)mExtensions.CStringAt(i);
nsCString* ext = mExtensions.CStringAt(i);
_retExts[i] = ext->ToNewCString();
if (!_retExts[i]) return NS_ERROR_OUT_OF_MEMORY;
}
@ -110,7 +109,7 @@ NS_IMETHODIMP
nsMIMEInfoImpl::SetMIMEType(const char* aMIMEType) {
if (!aMIMEType) return NS_ERROR_NULL_POINTER;
mMIMEType.AssignWithConversion(aMIMEType);
mMIMEType=aMIMEType;
return NS_OK;
}
@ -170,3 +169,20 @@ NS_IMETHODIMP nsMIMEInfoImpl::SetMacCreator(PRUint32 aMacCreator)
mMacCreator = aMacCreator;
return NS_OK;
}
NS_IMETHODIMP nsMIMEInfoImpl::SetFileExtensions( const char* aExtensions )
{
mExtensions.Clear();
nsCString extList( aExtensions );
PRInt32 breakLocation = -1;
while ( (breakLocation= extList.FindCharInSet( ",",0 ) )!= -1)
{
nsCString ext( extList, breakLocation );
mExtensions.AppendCString( ext );
extList.Cut(0, breakLocation+1 );
}
if ( extList.Length() )
mExtensions.AppendCString( extList );
return NS_OK;
}

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

@ -45,7 +45,7 @@ class nsMIMEInfoImpl : public nsIMIMEInfo {
nsCOMPtr<nsIURI> mURI; // URI pointing to data associated w/ this obj
PRUint32 mMacType, mMacCreator; // Mac file type and creator
protected:
nsString mMIMEType;
nsCString mMIMEType;
};

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

@ -31,9 +31,8 @@ nsMIMEInfoImpl::nsMIMEInfoImpl() {
NS_INIT_REFCNT();
}
nsMIMEInfoImpl::nsMIMEInfoImpl(const char *aMIMEType) {
nsMIMEInfoImpl::nsMIMEInfoImpl(const char *aMIMEType) :mMIMEType( aMIMEType ){
NS_INIT_REFCNT();
mMIMEType.AssignWithConversion(aMIMEType);
}
PRUint32
@ -50,7 +49,7 @@ nsMIMEInfoImpl::GetFileExtensions(PRInt32 *elementCount, char ***extensions) {
if (!_retExts) return NS_ERROR_OUT_OF_MEMORY;
for (PRUint8 i=0; i < *elementCount; i++) {
nsString* ext = (nsString*)mExtensions.CStringAt(i);
nsCString* ext = mExtensions.CStringAt(i);
_retExts[i] = ext->ToNewCString();
if (!_retExts[i]) return NS_ERROR_OUT_OF_MEMORY;
}
@ -110,7 +109,7 @@ NS_IMETHODIMP
nsMIMEInfoImpl::SetMIMEType(const char* aMIMEType) {
if (!aMIMEType) return NS_ERROR_NULL_POINTER;
mMIMEType.AssignWithConversion(aMIMEType);
mMIMEType=aMIMEType;
return NS_OK;
}
@ -170,3 +169,20 @@ NS_IMETHODIMP nsMIMEInfoImpl::SetMacCreator(PRUint32 aMacCreator)
mMacCreator = aMacCreator;
return NS_OK;
}
NS_IMETHODIMP nsMIMEInfoImpl::SetFileExtensions( const char* aExtensions )
{
mExtensions.Clear();
nsCString extList( aExtensions );
PRInt32 breakLocation = -1;
while ( (breakLocation= extList.FindCharInSet( ",",0 ) )!= -1)
{
nsCString ext( extList, breakLocation );
mExtensions.AppendCString( ext );
extList.Cut(0, breakLocation+1 );
}
if ( extList.Length() )
mExtensions.AppendCString( extList );
return NS_OK;
}

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

@ -45,7 +45,7 @@ class nsMIMEInfoImpl : public nsIMIMEInfo {
nsCOMPtr<nsIURI> mURI; // URI pointing to data associated w/ this obj
PRUint32 mMacType, mMacCreator; // Mac file type and creator
protected:
nsString mMIMEType;
nsCString mMIMEType;
};