bug #53071: r=danm, sr=alecf. Eliminate redundant implemenations, resolve resulting ambiguities.

This commit is contained in:
scc%mozilla.org 2001-02-06 23:07:24 +00:00
parent 7d29116ef0
commit 89f6b7263b
19 changed files with 49 additions and 748 deletions

View File

@ -1121,7 +1121,7 @@ nsStringBundleService::FormatStatusMessage(nsresult aStatus,
// format the arguments:
nsAutoString args(aStatusArg);
argCount = args.CountChar('\n') + 1;
argCount = args.CountChar(PRUnichar('\n')) + 1;
NS_ENSURE_ARG(argCount <= 10); // enforce 10-parameter limit
PRUnichar* argArray[10];

View File

@ -156,7 +156,7 @@ PRBool nsStr::GrowCapacity(nsStr& aDest,PRUint32 aNewLength) {
*/
void nsStr::StrAssign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount){
if(&aDest!=&aSource){
Truncate(aDest,0);
StrTruncate(aDest,0);
StrAppend(aDest,aSource,anOffset,aCount);
}
}
@ -288,7 +288,7 @@ void nsStr::Delete(nsStr& aDest,PRUint32 aDestOffset,PRUint32 aCount){
AddNullTerminator(aDest);
NSSTR_SEEN(aDest);
}
else Truncate(aDest,aDestOffset);
else StrTruncate(aDest,aDestOffset);
}//if
}
@ -298,7 +298,7 @@ void nsStr::Delete(nsStr& aDest,PRUint32 aDestOffset,PRUint32 aCount){
* @param aDest is the nsStr to be truncated
* @param aDestOffset is where in aDest truncation is to occur
*/
void nsStr::Truncate(nsStr& aDest,PRUint32 aDestOffset){
void nsStr::StrTruncate(nsStr& aDest,PRUint32 aDestOffset){
if(aDest.mCapacity && aDestOffset<=aDest.mCapacity){
aDest.mLength=aDestOffset;
AddNullTerminator(aDest);
@ -348,7 +348,7 @@ void nsStr::Trim(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool a
if(theIndex<theMax) {
Delete(aDest,0,theIndex);
}
else Truncate(aDest,0);
else StrTruncate(aDest,0);
}
}
@ -363,7 +363,7 @@ void nsStr::Trim(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool a
else break;
}
if(theNewLen<theMax) {
Truncate(aDest,theNewLen);
StrTruncate(aDest,theNewLen);
}
}

View File

@ -334,7 +334,7 @@ struct NS_COM nsStr {
* @param aSrcOffset tells us where in source to start copying
* @param anAgent is the allocator to be used for alloc/free operations
*/
static void Truncate(nsStr& aDest,PRUint32 aDestOffset);
static void StrTruncate(nsStr& aDest,PRUint32 aDestOffset);
/**
* This method is used to perform a case conversion on the given string

View File

@ -59,7 +59,7 @@ static void CSubsume(nsStr& aDest,nsStr& aSource){
nsStr::StrAssign(aDest,aSource,0,aSource.mLength);
}
}
else nsStr::Truncate(aDest,0);
else nsStr::StrTruncate(aDest,0);
}
@ -189,7 +189,7 @@ void nsCString::SetLength(PRUint32 anIndex) {
// |SetCapacity| normally doesn't guarantee the use we are putting it to here (see its interface comment in nsAWritableString.h),
// we can only use it since our local implementation, |nsCString::SetCapacity|, is known to do what we want
nsStr::Truncate(*this,anIndex);
nsStr::StrTruncate(*this,anIndex);
}
@ -456,25 +456,6 @@ nsCString::ReplaceSubstring(const nsCString& aTarget,const nsCString& aNewValue)
}
}
/**
* This method is used to replace all occurances of the
* given source char with the given dest char
*
* @param
* @return *this
*/
PRInt32 nsCString::CountChar(PRUnichar aChar) const {
PRInt32 theIndex=0;
PRInt32 theCount=0;
PRInt32 theLen=(PRInt32)mLength;
for(theIndex=0;theIndex<theLen;theIndex++){
PRUnichar theChar=GetCharAt(*this,theIndex);
if(theChar==aChar)
theCount++;
}
return theCount;
}
/**
* This method trims characters found in aTrimSet from
* either end of the underlying string.
@ -760,7 +741,7 @@ PRInt32 nsCString::ToInteger(PRInt32* anErrorCode,PRUint32 aRadix) const {
* @return this
*/
void nsCString::AssignWithConversion(const PRUnichar* aString,PRInt32 aCount) {
nsStr::Truncate(*this,0);
nsStr::StrTruncate(*this,0);
if(aString && aCount){
nsStr temp;
@ -792,7 +773,7 @@ void nsCString::AssignWithConversion( const nsString& aString ) {
}
void nsCString::AssignWithConversion( const nsAReadableString& aString ) {
nsStr::Truncate(*this,0);
nsStr::StrTruncate(*this,0);
PRInt32 count = aString.Length();
if(count){
@ -845,7 +826,7 @@ void nsCString::AppendWithConversion( const nsAReadableString& aString ) {
* @return this
*/
void nsCString::AssignWithConversion(PRUnichar aChar) {
nsStr::Truncate(*this,0);
nsStr::StrTruncate(*this,0);
AppendWithConversion(aChar);
}
@ -961,53 +942,6 @@ void nsCString::AppendWithConversion(const nsString& aString,PRInt32 aCount) {
}
/*
* Copies n characters from this left of this string to given string,
*
* @update gess 4/1/98
* @param aDest -- Receiving string
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 nsCString::Left(nsCString& aDest,PRInt32 aCount) const{
if(aCount<0)
aCount=mLength;
else aCount=MinInt(aCount,mLength);
StrAssign(aDest,*this,0,aCount);
return aDest.mLength;
}
/*
* Copies n characters from this string to from given offset
*
* @update gess 4/1/98
* @param aDest -- Receiving string
* @param anOffset -- where copying should begin
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 nsCString::Mid(nsCString& aDest,PRUint32 anOffset,PRInt32 aCount) const{
if(aCount<0)
aCount=mLength;
else aCount=MinInt(aCount,mLength);
StrAssign(aDest,*this,anOffset,aCount);
return aDest.mLength;
}
/*
* Copies last n characters from this string to given string,
*
* @update gess 4/1/98
* @param aDest -- Receiving string
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 nsCString::Right(nsCString& aDest,PRInt32 aCount) const{
PRInt32 offset=MaxInt(mLength-aCount,0);
return Mid(aDest,offset,aCount);
}
/**
* Insert a single unichar into this string at a specified offset.
*

View File

@ -117,18 +117,6 @@ public:
*/
void SetCapacity(PRUint32 aLength);
/**
* This method truncates this string to given length.
*
* @param anIndex -- new length of string
* @return nada
*/
void Truncate(PRUint32 anIndex=0) {
NS_ASSERTION(anIndex<=mLength, "Can't use |Truncate()| to make a string longer.");
if ( anIndex < mLength )
SetLength(anIndex);
}
/**********************************************************************
Accessor methods...
*********************************************************************/
@ -206,8 +194,6 @@ public:
void ReplaceSubstring(const nsCString& aTarget,const nsCString& aNewValue);
void ReplaceSubstring(const char* aTarget,const char* aNewValue);
PRInt32 CountChar(PRUnichar aChar) const;
/**
* This method trims characters found in aTrimSet from
* either end of the underlying string.
@ -341,39 +327,6 @@ public:
void AppendFloat( double aFloat );
virtual void do_AppendFromReadable( const nsAReadableCString& );
/*
* Copies n characters from this string to given string,
* starting at the leftmost offset.
*
*
* @param aCopy -- Receiving string
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 Left(nsCString& aCopy,PRInt32 aCount) const;
/*
* Copies n characters from this string to given string,
* starting at the given offset.
*
*
* @param aCopy -- Receiving string
* @param aCount -- number of chars to copy
* @param anOffset -- position where copying begins
* @return number of chars copied
*/
PRUint32 Mid(nsCString& aCopy,PRUint32 anOffset,PRInt32 aCount) const;
/*
* Copies n characters from this string to given string,
* starting at rightmost char.
*
*
* @param aCopy -- Receiving string
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 Right(nsCString& aCopy,PRInt32 aCount) const;
void InsertWithConversion(PRUnichar aChar,PRUint32 anOffset);
// Why no |InsertWithConversion(PRUnichar*)|?

View File

@ -56,7 +56,7 @@ static void Subsume(nsStr& aDest,nsStr& aSource){
nsStr::StrAssign(aDest,aSource,0,aSource.mLength);
}
}
else nsStr::Truncate(aDest,0);
else nsStr::StrTruncate(aDest,0);
}
@ -188,7 +188,7 @@ void nsString::SetLength(PRUint32 anIndex) {
SetCapacity(anIndex);
// |SetCapacity| normally doesn't guarantee the use we are putting it to here (see its interface comment in nsAWritableString.h),
// we can only use it since our local implementation, |nsString::SetCapacity|, is known to do what we want
nsStr::Truncate(*this,anIndex);
nsStr::StrTruncate(*this,anIndex);
}
@ -493,25 +493,6 @@ nsString::ReplaceSubstring(const nsString& aTarget,const nsString& aNewValue){
}
}
/**
* This method is used to replace all occurances of the
* given source char with the given dest char
*
* @param
* @return *this
*/
PRInt32 nsString::CountChar(PRUnichar aChar) const {
PRInt32 theIndex=0;
PRInt32 theCount=0;
PRInt32 theLen=(PRInt32)mLength;
for(theIndex=0;theIndex<theLen;theIndex++){
PRUnichar theChar=GetCharAt(*this,theIndex);
if(theChar==aChar)
theCount++;
}
return theCount;
}
/**
* This method trims characters found in aTrimSet from
* either end of the underlying string.
@ -827,14 +808,14 @@ PRInt32 nsString::ToInteger(PRInt32* anErrorCode,PRUint32 aRadix) const {
* @return this
*/
void nsString::AssignWithConversion(const char* aCString,PRInt32 aCount) {
nsStr::Truncate(*this,0);
nsStr::StrTruncate(*this,0);
if(aCString){
AppendWithConversion(aCString,aCount);
}
}
void nsString::AssignWithConversion(const char* aCString) {
nsStr::Truncate(*this,0);
nsStr::StrTruncate(*this,0);
if(aCString){
AppendWithConversion(aCString);
}
@ -848,7 +829,7 @@ void nsString::AssignWithConversion(const char* aCString) {
* @return this
*/
void nsString::AssignWithConversion(char aChar) {
nsStr::Truncate(*this,0);
nsStr::StrTruncate(*this,0);
AppendWithConversion(aChar);
}
@ -961,57 +942,6 @@ void nsString::AppendFloat(double aFloat){
/*
* Copies n characters from this left of this string to given string,
*
* @update gess 4/1/98
* @param aDest -- Receiving string
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 nsString::Left(nsString& aDest,PRInt32 aCount) const{
if(aCount<0)
aCount=mLength;
else aCount=MinInt(aCount,mLength);
nsStr::StrAssign(aDest,*this,0,aCount);
return aDest.mLength;
}
/*
* Copies n characters from this string to from given offset
*
* @update gess 4/1/98
* @param aDest -- Receiving string
* @param anOffset -- where copying should begin
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 nsString::Mid(nsString& aDest,PRUint32 anOffset,PRInt32 aCount) const{
if(aCount<0)
aCount=mLength;
else aCount=MinInt(aCount,mLength);
nsStr::StrAssign(aDest,*this,anOffset,aCount);
return aDest.mLength;
}
/*
* Copies last n characters from this string to given string,
*
* @update gess 4/1/98
* @param aDest -- Receiving string
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 nsString::Right(nsString& aDest,PRInt32 aCount) const{
PRInt32 offset=MaxInt(mLength-aCount,0);
return Mid(aDest,offset,aCount);
}
/**
* Insert a char* into this string at a specified offset.
*

View File

@ -136,19 +136,6 @@ public:
void SetCapacity(PRUint32 aLength);
/**
* This method truncates this string to given length.
*
* @param anIndex -- new length of string
* @return nada
*/
void Truncate(PRUint32 anIndex=0) {
NS_ASSERTION(anIndex<=mLength, "Can't use |Truncate()| to make a string longer.");
if ( anIndex < mLength )
SetLength(anIndex);
}
/**
* Determine whether or not the characters in this
* string are in store as 1 or 2 byte (unicode) strings.
@ -242,8 +229,6 @@ public:
void ReplaceSubstring( const nsString& aTarget, const nsString& aNewValue );
void ReplaceSubstring( const PRUnichar* aTarget, const PRUnichar* aNewValue );
PRInt32 CountChar( PRUnichar aChar ) const;
/**
* This method trims characters found in aTrimSet from
* either end of the underlying string.
@ -374,41 +359,6 @@ public:
virtual void do_AppendFromElement( PRUnichar );
/*
* Copies n characters from this string to given string,
* starting at the leftmost offset.
*
*
* @param aCopy -- Receiving string
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 Left(nsString& aCopy,PRInt32 aCount) const;
/*
* Copies n characters from this string to given string,
* starting at the given offset.
*
*
* @param aCopy -- Receiving string
* @param aCount -- number of chars to copy
* @param anOffset -- position where copying begins
* @return number of chars copied
*/
PRUint32 Mid(nsString& aCopy,PRUint32 anOffset,PRInt32 aCount) const;
/*
* Copies n characters from this string to given string,
* starting at rightmost char.
*
*
* @param aCopy -- Receiving string
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 Right(nsString& aCopy,PRInt32 aCount) const;
//void InsertWithConversion(char);
void InsertWithConversion(const char*, PRUint32, PRInt32=-1);

View File

@ -156,7 +156,7 @@ PRBool nsStr::GrowCapacity(nsStr& aDest,PRUint32 aNewLength) {
*/
void nsStr::StrAssign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount){
if(&aDest!=&aSource){
Truncate(aDest,0);
StrTruncate(aDest,0);
StrAppend(aDest,aSource,anOffset,aCount);
}
}
@ -288,7 +288,7 @@ void nsStr::Delete(nsStr& aDest,PRUint32 aDestOffset,PRUint32 aCount){
AddNullTerminator(aDest);
NSSTR_SEEN(aDest);
}
else Truncate(aDest,aDestOffset);
else StrTruncate(aDest,aDestOffset);
}//if
}
@ -298,7 +298,7 @@ void nsStr::Delete(nsStr& aDest,PRUint32 aDestOffset,PRUint32 aCount){
* @param aDest is the nsStr to be truncated
* @param aDestOffset is where in aDest truncation is to occur
*/
void nsStr::Truncate(nsStr& aDest,PRUint32 aDestOffset){
void nsStr::StrTruncate(nsStr& aDest,PRUint32 aDestOffset){
if(aDest.mCapacity && aDestOffset<=aDest.mCapacity){
aDest.mLength=aDestOffset;
AddNullTerminator(aDest);
@ -348,7 +348,7 @@ void nsStr::Trim(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool a
if(theIndex<theMax) {
Delete(aDest,0,theIndex);
}
else Truncate(aDest,0);
else StrTruncate(aDest,0);
}
}
@ -363,7 +363,7 @@ void nsStr::Trim(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool a
else break;
}
if(theNewLen<theMax) {
Truncate(aDest,theNewLen);
StrTruncate(aDest,theNewLen);
}
}

View File

@ -334,7 +334,7 @@ struct NS_COM nsStr {
* @param aSrcOffset tells us where in source to start copying
* @param anAgent is the allocator to be used for alloc/free operations
*/
static void Truncate(nsStr& aDest,PRUint32 aDestOffset);
static void StrTruncate(nsStr& aDest,PRUint32 aDestOffset);
/**
* This method is used to perform a case conversion on the given string

View File

@ -59,7 +59,7 @@ static void CSubsume(nsStr& aDest,nsStr& aSource){
nsStr::StrAssign(aDest,aSource,0,aSource.mLength);
}
}
else nsStr::Truncate(aDest,0);
else nsStr::StrTruncate(aDest,0);
}
@ -189,7 +189,7 @@ void nsCString::SetLength(PRUint32 anIndex) {
// |SetCapacity| normally doesn't guarantee the use we are putting it to here (see its interface comment in nsAWritableString.h),
// we can only use it since our local implementation, |nsCString::SetCapacity|, is known to do what we want
nsStr::Truncate(*this,anIndex);
nsStr::StrTruncate(*this,anIndex);
}
@ -456,25 +456,6 @@ nsCString::ReplaceSubstring(const nsCString& aTarget,const nsCString& aNewValue)
}
}
/**
* This method is used to replace all occurances of the
* given source char with the given dest char
*
* @param
* @return *this
*/
PRInt32 nsCString::CountChar(PRUnichar aChar) const {
PRInt32 theIndex=0;
PRInt32 theCount=0;
PRInt32 theLen=(PRInt32)mLength;
for(theIndex=0;theIndex<theLen;theIndex++){
PRUnichar theChar=GetCharAt(*this,theIndex);
if(theChar==aChar)
theCount++;
}
return theCount;
}
/**
* This method trims characters found in aTrimSet from
* either end of the underlying string.
@ -760,7 +741,7 @@ PRInt32 nsCString::ToInteger(PRInt32* anErrorCode,PRUint32 aRadix) const {
* @return this
*/
void nsCString::AssignWithConversion(const PRUnichar* aString,PRInt32 aCount) {
nsStr::Truncate(*this,0);
nsStr::StrTruncate(*this,0);
if(aString && aCount){
nsStr temp;
@ -792,7 +773,7 @@ void nsCString::AssignWithConversion( const nsString& aString ) {
}
void nsCString::AssignWithConversion( const nsAReadableString& aString ) {
nsStr::Truncate(*this,0);
nsStr::StrTruncate(*this,0);
PRInt32 count = aString.Length();
if(count){
@ -845,7 +826,7 @@ void nsCString::AppendWithConversion( const nsAReadableString& aString ) {
* @return this
*/
void nsCString::AssignWithConversion(PRUnichar aChar) {
nsStr::Truncate(*this,0);
nsStr::StrTruncate(*this,0);
AppendWithConversion(aChar);
}
@ -961,53 +942,6 @@ void nsCString::AppendWithConversion(const nsString& aString,PRInt32 aCount) {
}
/*
* Copies n characters from this left of this string to given string,
*
* @update gess 4/1/98
* @param aDest -- Receiving string
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 nsCString::Left(nsCString& aDest,PRInt32 aCount) const{
if(aCount<0)
aCount=mLength;
else aCount=MinInt(aCount,mLength);
StrAssign(aDest,*this,0,aCount);
return aDest.mLength;
}
/*
* Copies n characters from this string to from given offset
*
* @update gess 4/1/98
* @param aDest -- Receiving string
* @param anOffset -- where copying should begin
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 nsCString::Mid(nsCString& aDest,PRUint32 anOffset,PRInt32 aCount) const{
if(aCount<0)
aCount=mLength;
else aCount=MinInt(aCount,mLength);
StrAssign(aDest,*this,anOffset,aCount);
return aDest.mLength;
}
/*
* Copies last n characters from this string to given string,
*
* @update gess 4/1/98
* @param aDest -- Receiving string
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 nsCString::Right(nsCString& aDest,PRInt32 aCount) const{
PRInt32 offset=MaxInt(mLength-aCount,0);
return Mid(aDest,offset,aCount);
}
/**
* Insert a single unichar into this string at a specified offset.
*

View File

@ -117,18 +117,6 @@ public:
*/
void SetCapacity(PRUint32 aLength);
/**
* This method truncates this string to given length.
*
* @param anIndex -- new length of string
* @return nada
*/
void Truncate(PRUint32 anIndex=0) {
NS_ASSERTION(anIndex<=mLength, "Can't use |Truncate()| to make a string longer.");
if ( anIndex < mLength )
SetLength(anIndex);
}
/**********************************************************************
Accessor methods...
*********************************************************************/
@ -206,8 +194,6 @@ public:
void ReplaceSubstring(const nsCString& aTarget,const nsCString& aNewValue);
void ReplaceSubstring(const char* aTarget,const char* aNewValue);
PRInt32 CountChar(PRUnichar aChar) const;
/**
* This method trims characters found in aTrimSet from
* either end of the underlying string.
@ -341,39 +327,6 @@ public:
void AppendFloat( double aFloat );
virtual void do_AppendFromReadable( const nsAReadableCString& );
/*
* Copies n characters from this string to given string,
* starting at the leftmost offset.
*
*
* @param aCopy -- Receiving string
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 Left(nsCString& aCopy,PRInt32 aCount) const;
/*
* Copies n characters from this string to given string,
* starting at the given offset.
*
*
* @param aCopy -- Receiving string
* @param aCount -- number of chars to copy
* @param anOffset -- position where copying begins
* @return number of chars copied
*/
PRUint32 Mid(nsCString& aCopy,PRUint32 anOffset,PRInt32 aCount) const;
/*
* Copies n characters from this string to given string,
* starting at rightmost char.
*
*
* @param aCopy -- Receiving string
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 Right(nsCString& aCopy,PRInt32 aCount) const;
void InsertWithConversion(PRUnichar aChar,PRUint32 anOffset);
// Why no |InsertWithConversion(PRUnichar*)|?

View File

@ -56,7 +56,7 @@ static void Subsume(nsStr& aDest,nsStr& aSource){
nsStr::StrAssign(aDest,aSource,0,aSource.mLength);
}
}
else nsStr::Truncate(aDest,0);
else nsStr::StrTruncate(aDest,0);
}
@ -188,7 +188,7 @@ void nsString::SetLength(PRUint32 anIndex) {
SetCapacity(anIndex);
// |SetCapacity| normally doesn't guarantee the use we are putting it to here (see its interface comment in nsAWritableString.h),
// we can only use it since our local implementation, |nsString::SetCapacity|, is known to do what we want
nsStr::Truncate(*this,anIndex);
nsStr::StrTruncate(*this,anIndex);
}
@ -493,25 +493,6 @@ nsString::ReplaceSubstring(const nsString& aTarget,const nsString& aNewValue){
}
}
/**
* This method is used to replace all occurances of the
* given source char with the given dest char
*
* @param
* @return *this
*/
PRInt32 nsString::CountChar(PRUnichar aChar) const {
PRInt32 theIndex=0;
PRInt32 theCount=0;
PRInt32 theLen=(PRInt32)mLength;
for(theIndex=0;theIndex<theLen;theIndex++){
PRUnichar theChar=GetCharAt(*this,theIndex);
if(theChar==aChar)
theCount++;
}
return theCount;
}
/**
* This method trims characters found in aTrimSet from
* either end of the underlying string.
@ -827,14 +808,14 @@ PRInt32 nsString::ToInteger(PRInt32* anErrorCode,PRUint32 aRadix) const {
* @return this
*/
void nsString::AssignWithConversion(const char* aCString,PRInt32 aCount) {
nsStr::Truncate(*this,0);
nsStr::StrTruncate(*this,0);
if(aCString){
AppendWithConversion(aCString,aCount);
}
}
void nsString::AssignWithConversion(const char* aCString) {
nsStr::Truncate(*this,0);
nsStr::StrTruncate(*this,0);
if(aCString){
AppendWithConversion(aCString);
}
@ -848,7 +829,7 @@ void nsString::AssignWithConversion(const char* aCString) {
* @return this
*/
void nsString::AssignWithConversion(char aChar) {
nsStr::Truncate(*this,0);
nsStr::StrTruncate(*this,0);
AppendWithConversion(aChar);
}
@ -961,57 +942,6 @@ void nsString::AppendFloat(double aFloat){
/*
* Copies n characters from this left of this string to given string,
*
* @update gess 4/1/98
* @param aDest -- Receiving string
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 nsString::Left(nsString& aDest,PRInt32 aCount) const{
if(aCount<0)
aCount=mLength;
else aCount=MinInt(aCount,mLength);
nsStr::StrAssign(aDest,*this,0,aCount);
return aDest.mLength;
}
/*
* Copies n characters from this string to from given offset
*
* @update gess 4/1/98
* @param aDest -- Receiving string
* @param anOffset -- where copying should begin
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 nsString::Mid(nsString& aDest,PRUint32 anOffset,PRInt32 aCount) const{
if(aCount<0)
aCount=mLength;
else aCount=MinInt(aCount,mLength);
nsStr::StrAssign(aDest,*this,anOffset,aCount);
return aDest.mLength;
}
/*
* Copies last n characters from this string to given string,
*
* @update gess 4/1/98
* @param aDest -- Receiving string
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 nsString::Right(nsString& aDest,PRInt32 aCount) const{
PRInt32 offset=MaxInt(mLength-aCount,0);
return Mid(aDest,offset,aCount);
}
/**
* Insert a char* into this string at a specified offset.
*

View File

@ -136,19 +136,6 @@ public:
void SetCapacity(PRUint32 aLength);
/**
* This method truncates this string to given length.
*
* @param anIndex -- new length of string
* @return nada
*/
void Truncate(PRUint32 anIndex=0) {
NS_ASSERTION(anIndex<=mLength, "Can't use |Truncate()| to make a string longer.");
if ( anIndex < mLength )
SetLength(anIndex);
}
/**
* Determine whether or not the characters in this
* string are in store as 1 or 2 byte (unicode) strings.
@ -242,8 +229,6 @@ public:
void ReplaceSubstring( const nsString& aTarget, const nsString& aNewValue );
void ReplaceSubstring( const PRUnichar* aTarget, const PRUnichar* aNewValue );
PRInt32 CountChar( PRUnichar aChar ) const;
/**
* This method trims characters found in aTrimSet from
* either end of the underlying string.
@ -374,41 +359,6 @@ public:
virtual void do_AppendFromElement( PRUnichar );
/*
* Copies n characters from this string to given string,
* starting at the leftmost offset.
*
*
* @param aCopy -- Receiving string
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 Left(nsString& aCopy,PRInt32 aCount) const;
/*
* Copies n characters from this string to given string,
* starting at the given offset.
*
*
* @param aCopy -- Receiving string
* @param aCount -- number of chars to copy
* @param anOffset -- position where copying begins
* @return number of chars copied
*/
PRUint32 Mid(nsString& aCopy,PRUint32 anOffset,PRInt32 aCount) const;
/*
* Copies n characters from this string to given string,
* starting at rightmost char.
*
*
* @param aCopy -- Receiving string
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 Right(nsString& aCopy,PRInt32 aCount) const;
//void InsertWithConversion(char);
void InsertWithConversion(const char*, PRUint32, PRInt32=-1);

View File

@ -156,7 +156,7 @@ PRBool nsStr::GrowCapacity(nsStr& aDest,PRUint32 aNewLength) {
*/
void nsStr::StrAssign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount){
if(&aDest!=&aSource){
Truncate(aDest,0);
StrTruncate(aDest,0);
StrAppend(aDest,aSource,anOffset,aCount);
}
}
@ -288,7 +288,7 @@ void nsStr::Delete(nsStr& aDest,PRUint32 aDestOffset,PRUint32 aCount){
AddNullTerminator(aDest);
NSSTR_SEEN(aDest);
}
else Truncate(aDest,aDestOffset);
else StrTruncate(aDest,aDestOffset);
}//if
}
@ -298,7 +298,7 @@ void nsStr::Delete(nsStr& aDest,PRUint32 aDestOffset,PRUint32 aCount){
* @param aDest is the nsStr to be truncated
* @param aDestOffset is where in aDest truncation is to occur
*/
void nsStr::Truncate(nsStr& aDest,PRUint32 aDestOffset){
void nsStr::StrTruncate(nsStr& aDest,PRUint32 aDestOffset){
if(aDest.mCapacity && aDestOffset<=aDest.mCapacity){
aDest.mLength=aDestOffset;
AddNullTerminator(aDest);
@ -348,7 +348,7 @@ void nsStr::Trim(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool a
if(theIndex<theMax) {
Delete(aDest,0,theIndex);
}
else Truncate(aDest,0);
else StrTruncate(aDest,0);
}
}
@ -363,7 +363,7 @@ void nsStr::Trim(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool a
else break;
}
if(theNewLen<theMax) {
Truncate(aDest,theNewLen);
StrTruncate(aDest,theNewLen);
}
}

View File

@ -334,7 +334,7 @@ struct NS_COM nsStr {
* @param aSrcOffset tells us where in source to start copying
* @param anAgent is the allocator to be used for alloc/free operations
*/
static void Truncate(nsStr& aDest,PRUint32 aDestOffset);
static void StrTruncate(nsStr& aDest,PRUint32 aDestOffset);
/**
* This method is used to perform a case conversion on the given string

View File

@ -59,7 +59,7 @@ static void CSubsume(nsStr& aDest,nsStr& aSource){
nsStr::StrAssign(aDest,aSource,0,aSource.mLength);
}
}
else nsStr::Truncate(aDest,0);
else nsStr::StrTruncate(aDest,0);
}
@ -189,7 +189,7 @@ void nsCString::SetLength(PRUint32 anIndex) {
// |SetCapacity| normally doesn't guarantee the use we are putting it to here (see its interface comment in nsAWritableString.h),
// we can only use it since our local implementation, |nsCString::SetCapacity|, is known to do what we want
nsStr::Truncate(*this,anIndex);
nsStr::StrTruncate(*this,anIndex);
}
@ -456,25 +456,6 @@ nsCString::ReplaceSubstring(const nsCString& aTarget,const nsCString& aNewValue)
}
}
/**
* This method is used to replace all occurances of the
* given source char with the given dest char
*
* @param
* @return *this
*/
PRInt32 nsCString::CountChar(PRUnichar aChar) const {
PRInt32 theIndex=0;
PRInt32 theCount=0;
PRInt32 theLen=(PRInt32)mLength;
for(theIndex=0;theIndex<theLen;theIndex++){
PRUnichar theChar=GetCharAt(*this,theIndex);
if(theChar==aChar)
theCount++;
}
return theCount;
}
/**
* This method trims characters found in aTrimSet from
* either end of the underlying string.
@ -760,7 +741,7 @@ PRInt32 nsCString::ToInteger(PRInt32* anErrorCode,PRUint32 aRadix) const {
* @return this
*/
void nsCString::AssignWithConversion(const PRUnichar* aString,PRInt32 aCount) {
nsStr::Truncate(*this,0);
nsStr::StrTruncate(*this,0);
if(aString && aCount){
nsStr temp;
@ -792,7 +773,7 @@ void nsCString::AssignWithConversion( const nsString& aString ) {
}
void nsCString::AssignWithConversion( const nsAReadableString& aString ) {
nsStr::Truncate(*this,0);
nsStr::StrTruncate(*this,0);
PRInt32 count = aString.Length();
if(count){
@ -845,7 +826,7 @@ void nsCString::AppendWithConversion( const nsAReadableString& aString ) {
* @return this
*/
void nsCString::AssignWithConversion(PRUnichar aChar) {
nsStr::Truncate(*this,0);
nsStr::StrTruncate(*this,0);
AppendWithConversion(aChar);
}
@ -961,53 +942,6 @@ void nsCString::AppendWithConversion(const nsString& aString,PRInt32 aCount) {
}
/*
* Copies n characters from this left of this string to given string,
*
* @update gess 4/1/98
* @param aDest -- Receiving string
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 nsCString::Left(nsCString& aDest,PRInt32 aCount) const{
if(aCount<0)
aCount=mLength;
else aCount=MinInt(aCount,mLength);
StrAssign(aDest,*this,0,aCount);
return aDest.mLength;
}
/*
* Copies n characters from this string to from given offset
*
* @update gess 4/1/98
* @param aDest -- Receiving string
* @param anOffset -- where copying should begin
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 nsCString::Mid(nsCString& aDest,PRUint32 anOffset,PRInt32 aCount) const{
if(aCount<0)
aCount=mLength;
else aCount=MinInt(aCount,mLength);
StrAssign(aDest,*this,anOffset,aCount);
return aDest.mLength;
}
/*
* Copies last n characters from this string to given string,
*
* @update gess 4/1/98
* @param aDest -- Receiving string
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 nsCString::Right(nsCString& aDest,PRInt32 aCount) const{
PRInt32 offset=MaxInt(mLength-aCount,0);
return Mid(aDest,offset,aCount);
}
/**
* Insert a single unichar into this string at a specified offset.
*

View File

@ -117,18 +117,6 @@ public:
*/
void SetCapacity(PRUint32 aLength);
/**
* This method truncates this string to given length.
*
* @param anIndex -- new length of string
* @return nada
*/
void Truncate(PRUint32 anIndex=0) {
NS_ASSERTION(anIndex<=mLength, "Can't use |Truncate()| to make a string longer.");
if ( anIndex < mLength )
SetLength(anIndex);
}
/**********************************************************************
Accessor methods...
*********************************************************************/
@ -206,8 +194,6 @@ public:
void ReplaceSubstring(const nsCString& aTarget,const nsCString& aNewValue);
void ReplaceSubstring(const char* aTarget,const char* aNewValue);
PRInt32 CountChar(PRUnichar aChar) const;
/**
* This method trims characters found in aTrimSet from
* either end of the underlying string.
@ -341,39 +327,6 @@ public:
void AppendFloat( double aFloat );
virtual void do_AppendFromReadable( const nsAReadableCString& );
/*
* Copies n characters from this string to given string,
* starting at the leftmost offset.
*
*
* @param aCopy -- Receiving string
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 Left(nsCString& aCopy,PRInt32 aCount) const;
/*
* Copies n characters from this string to given string,
* starting at the given offset.
*
*
* @param aCopy -- Receiving string
* @param aCount -- number of chars to copy
* @param anOffset -- position where copying begins
* @return number of chars copied
*/
PRUint32 Mid(nsCString& aCopy,PRUint32 anOffset,PRInt32 aCount) const;
/*
* Copies n characters from this string to given string,
* starting at rightmost char.
*
*
* @param aCopy -- Receiving string
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 Right(nsCString& aCopy,PRInt32 aCount) const;
void InsertWithConversion(PRUnichar aChar,PRUint32 anOffset);
// Why no |InsertWithConversion(PRUnichar*)|?

View File

@ -56,7 +56,7 @@ static void Subsume(nsStr& aDest,nsStr& aSource){
nsStr::StrAssign(aDest,aSource,0,aSource.mLength);
}
}
else nsStr::Truncate(aDest,0);
else nsStr::StrTruncate(aDest,0);
}
@ -188,7 +188,7 @@ void nsString::SetLength(PRUint32 anIndex) {
SetCapacity(anIndex);
// |SetCapacity| normally doesn't guarantee the use we are putting it to here (see its interface comment in nsAWritableString.h),
// we can only use it since our local implementation, |nsString::SetCapacity|, is known to do what we want
nsStr::Truncate(*this,anIndex);
nsStr::StrTruncate(*this,anIndex);
}
@ -493,25 +493,6 @@ nsString::ReplaceSubstring(const nsString& aTarget,const nsString& aNewValue){
}
}
/**
* This method is used to replace all occurances of the
* given source char with the given dest char
*
* @param
* @return *this
*/
PRInt32 nsString::CountChar(PRUnichar aChar) const {
PRInt32 theIndex=0;
PRInt32 theCount=0;
PRInt32 theLen=(PRInt32)mLength;
for(theIndex=0;theIndex<theLen;theIndex++){
PRUnichar theChar=GetCharAt(*this,theIndex);
if(theChar==aChar)
theCount++;
}
return theCount;
}
/**
* This method trims characters found in aTrimSet from
* either end of the underlying string.
@ -827,14 +808,14 @@ PRInt32 nsString::ToInteger(PRInt32* anErrorCode,PRUint32 aRadix) const {
* @return this
*/
void nsString::AssignWithConversion(const char* aCString,PRInt32 aCount) {
nsStr::Truncate(*this,0);
nsStr::StrTruncate(*this,0);
if(aCString){
AppendWithConversion(aCString,aCount);
}
}
void nsString::AssignWithConversion(const char* aCString) {
nsStr::Truncate(*this,0);
nsStr::StrTruncate(*this,0);
if(aCString){
AppendWithConversion(aCString);
}
@ -848,7 +829,7 @@ void nsString::AssignWithConversion(const char* aCString) {
* @return this
*/
void nsString::AssignWithConversion(char aChar) {
nsStr::Truncate(*this,0);
nsStr::StrTruncate(*this,0);
AppendWithConversion(aChar);
}
@ -961,57 +942,6 @@ void nsString::AppendFloat(double aFloat){
/*
* Copies n characters from this left of this string to given string,
*
* @update gess 4/1/98
* @param aDest -- Receiving string
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 nsString::Left(nsString& aDest,PRInt32 aCount) const{
if(aCount<0)
aCount=mLength;
else aCount=MinInt(aCount,mLength);
nsStr::StrAssign(aDest,*this,0,aCount);
return aDest.mLength;
}
/*
* Copies n characters from this string to from given offset
*
* @update gess 4/1/98
* @param aDest -- Receiving string
* @param anOffset -- where copying should begin
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 nsString::Mid(nsString& aDest,PRUint32 anOffset,PRInt32 aCount) const{
if(aCount<0)
aCount=mLength;
else aCount=MinInt(aCount,mLength);
nsStr::StrAssign(aDest,*this,anOffset,aCount);
return aDest.mLength;
}
/*
* Copies last n characters from this string to given string,
*
* @update gess 4/1/98
* @param aDest -- Receiving string
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 nsString::Right(nsString& aDest,PRInt32 aCount) const{
PRInt32 offset=MaxInt(mLength-aCount,0);
return Mid(aDest,offset,aCount);
}
/**
* Insert a char* into this string at a specified offset.
*

View File

@ -136,19 +136,6 @@ public:
void SetCapacity(PRUint32 aLength);
/**
* This method truncates this string to given length.
*
* @param anIndex -- new length of string
* @return nada
*/
void Truncate(PRUint32 anIndex=0) {
NS_ASSERTION(anIndex<=mLength, "Can't use |Truncate()| to make a string longer.");
if ( anIndex < mLength )
SetLength(anIndex);
}
/**
* Determine whether or not the characters in this
* string are in store as 1 or 2 byte (unicode) strings.
@ -242,8 +229,6 @@ public:
void ReplaceSubstring( const nsString& aTarget, const nsString& aNewValue );
void ReplaceSubstring( const PRUnichar* aTarget, const PRUnichar* aNewValue );
PRInt32 CountChar( PRUnichar aChar ) const;
/**
* This method trims characters found in aTrimSet from
* either end of the underlying string.
@ -374,41 +359,6 @@ public:
virtual void do_AppendFromElement( PRUnichar );
/*
* Copies n characters from this string to given string,
* starting at the leftmost offset.
*
*
* @param aCopy -- Receiving string
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 Left(nsString& aCopy,PRInt32 aCount) const;
/*
* Copies n characters from this string to given string,
* starting at the given offset.
*
*
* @param aCopy -- Receiving string
* @param aCount -- number of chars to copy
* @param anOffset -- position where copying begins
* @return number of chars copied
*/
PRUint32 Mid(nsString& aCopy,PRUint32 anOffset,PRInt32 aCount) const;
/*
* Copies n characters from this string to given string,
* starting at rightmost char.
*
*
* @param aCopy -- Receiving string
* @param aCount -- number of chars to copy
* @return number of chars copied
*/
PRUint32 Right(nsString& aCopy,PRInt32 aCount) const;
//void InsertWithConversion(char);
void InsertWithConversion(const char*, PRUint32, PRInt32=-1);