more work bringing |ns[C]String| into line with the new implementations. Again, this is no change when |NEW_STRING_APIS| is not defined.

This commit is contained in:
scc%netscape.com 2000-03-31 07:26:13 +00:00
Родитель 6ce1fbbb34
Коммит f563b72b38
18 изменённых файлов: 606 добавлений и 414 удалений

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

@ -592,7 +592,7 @@ PRInt32 nsStr::RFindCharInSet(const nsStr& aDest,const nsStr& aSet,PRBool aIgnor
* @param aIgnorecase tells us whether to search with case sensitivity
* @return aDest<aSource=-1;aDest==aSource==0;aDest>aSource=1
*/
PRInt32 nsStr::Compare(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase) {
PRInt32 nsStr::StrCompare(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase) {
PRInt32 result=0;
if(aCount) {
@ -850,7 +850,7 @@ nsStr_Compare(const void *v1, const void *v2)
{
nsStr* str1 = (nsStr*)v1;
nsStr* str2 = (nsStr*)v2;
return nsStr::Compare(*str1, *str2, -1, PR_FALSE) == 0;
return nsStr::StrCompare(*str1, *str2, -1, PR_FALSE) == 0;
}
nsStringInfo*

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

@ -310,18 +310,6 @@ struct NS_COM nsStr {
*/
static void StrInsert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount);
#ifndef NEW_STRING_APIS
static void Append(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount) {
StrAppend(aDest, aSource, anOffset, aCount);
}
static void Assign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount) {
StrAssign(aDest, aSource, anOffset, aCount);
}
static void Insert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount) {
StrInsert(aDest, aDestOffset, aSource, aSrcOffset, aCount);
}
#endif
/**
* This method deletes chars from the given str.
* The given allocator may choose to resize the str as well.
@ -402,7 +390,7 @@ struct NS_COM nsStr {
* @param aIgnorecase tells us whether to use a case-sensitive comparison
* @return -1,0,1 depending on <,==,>
*/
static PRInt32 Compare(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase);
static PRInt32 StrCompare(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase);
/**
* These methods scan the given string for 1 or more chars in a given direction
@ -431,6 +419,22 @@ struct NS_COM nsStr {
*/
static PRUint32 HashCode(const nsStr& aDest);
#ifndef NEW_STRING_APIS
static void Append(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount) {
StrAppend(aDest, aSource, anOffset, aCount);
}
static void Assign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount) {
StrAssign(aDest, aSource, anOffset, aCount);
}
static void Insert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount) {
StrInsert(aDest, aDestOffset, aSource, aSrcOffset, aCount);
}
static PRInt32 Compare(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase) {
return StrCompare(aDest, aSource, aCount, aIgnoreCase);
}
#endif
#ifdef NS_STR_STATS
/**
* Prints an nsStr. If truncate is true, the string is only printed up to

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

@ -1518,27 +1518,6 @@ PRInt32 nsCString::RFindCharInSet(const nsStr& aSet,PRInt32 anOffset) const{
**************************************************************/
/**
* Compares given cstring to this string.
* @update gess 01/04/99
* @param aCString points to a cstring
* @param aIgnoreCase tells us how to treat case
* @param aCount tells us how many chars to test; -1 implies full length
* @return -1,0,1
*/
PRInt32 nsCString::Compare(const char *aCString,PRBool aIgnoreCase,PRInt32 aCount) const {
NS_ASSERTION(0!=aCString,kNullPointerError);
if(aCString) {
nsStr temp;
nsStr::Initialize(temp,eOneByte);
temp.mLength=nsCRT::strlen(aCString);
temp.mStr=(char*)aCString;
return nsStr::Compare(*this,temp,aCount,aIgnoreCase);
}
return 0;
}
/**
* Compares given unistring to this string.
* @update gess 01/04/99
@ -1547,7 +1526,7 @@ PRInt32 nsCString::Compare(const char *aCString,PRBool aIgnoreCase,PRInt32 aCoun
* @param aCount tells us how many chars to test; -1 implies full length
* @return -1,0,1
*/
PRInt32 nsCString::Compare(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 nsCString::CompareWithConversion(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
NS_ASSERTION(0!=aString,kNullPointerError);
if(aString) {
@ -1555,11 +1534,33 @@ PRInt32 nsCString::Compare(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 a
nsStr::Initialize(temp,eTwoByte);
temp.mLength=nsCRT::strlen(aString);
temp.mUStr=(PRUnichar*)aString;
return nsStr::Compare(*this,temp,aCount,aIgnoreCase);
return nsStr::StrCompare(*this,temp,aCount,aIgnoreCase);
}
return 0;
}
/**
* Compares given cstring to this string.
* @update gess 01/04/99
* @param aCString points to a cstring
* @param aIgnoreCase tells us how to treat case
* @param aCount tells us how many chars to test; -1 implies full length
* @return -1,0,1
*/
PRInt32 nsCString::CompareWithConversion(const char *aCString,PRBool aIgnoreCase,PRInt32 aCount) const {
NS_ASSERTION(0!=aCString,kNullPointerError);
if(aCString) {
nsStr temp;
nsStr::Initialize(temp,eOneByte);
temp.mLength=nsCRT::strlen(aCString);
temp.mStr=(char*)aCString;
return nsStr::StrCompare(*this,temp,aCount,aIgnoreCase);
}
return 0;
}
#ifndef NEW_STRING_APIS
/**
* Compare given nsStr with this cstring.
*
@ -1569,8 +1570,9 @@ PRInt32 nsCString::Compare(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 a
* @return -1,0,1
*/
PRInt32 nsCString::Compare(const nsStr& aString,PRBool aIgnoreCase,PRInt32 aCount) const {
return nsStr::Compare(*this,aString,aCount,aIgnoreCase);
return nsStr::StrCompare(*this,aString,aCount,aIgnoreCase);
}
#endif
#ifndef NEW_STRING_APIS
/**
@ -1601,19 +1603,22 @@ PRBool nsCString::operator>=(const char* s) const {return PRBool(Compare(s)>=0);
PRBool nsCString::operator>=(const PRUnichar* s) const {return PRBool(Compare(s)>=0);}
#endif
#ifndef NEW_STRING_APIS
PRBool nsCString::EqualsIgnoreCase(const nsStr& aString) const {
return Equals(aString,PR_TRUE);
}
#endif
PRBool nsCString::EqualsIgnoreCase(const char* aString,PRInt32 aLength) const {
return Equals(aString,PR_TRUE,aLength);
return EqualsWithConversion(aString,PR_TRUE,aLength);
}
PRBool nsCString::EqualsIgnoreCase(const PRUnichar* aString,PRInt32 aLength) const {
return Equals(aString,PR_TRUE,aLength);
return EqualsWithConversion(aString,PR_TRUE,aLength);
}
#ifndef NEW_STRING_APIS
/**
* Compare this to given string; note that we compare full strings here.
*
@ -1624,10 +1629,11 @@ PRBool nsCString::EqualsIgnoreCase(const PRUnichar* aString,PRInt32 aLength) con
* @return TRUE if equal
*/
PRBool nsCString::Equals(const nsStr& aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=nsStr::Compare(*this,aString,aCount,aIgnoreCase);
PRInt32 theAnswer=nsStr::StrCompare(*this,aString,aCount,aIgnoreCase);
PRBool result=PRBool(0==theAnswer);
return result;
}
#endif
/**
* Compare this to given string; note that we compare full strings here.
@ -1638,14 +1644,14 @@ PRBool nsCString::Equals(const nsStr& aString,PRBool aIgnoreCase,PRInt32 aCount)
* @param aCount tells us how many chars to test; -1 implies full length
* @return TRUE if equal
*/
PRBool nsCString::Equals(const char* aCString,PRBool aIgnoreCase,PRInt32 aCount) const{
PRInt32 theAnswer=Compare(aCString,aIgnoreCase,aCount);
PRBool nsCString::EqualsWithConversion(const char* aCString,PRBool aIgnoreCase,PRInt32 aCount) const{
PRInt32 theAnswer=CompareWithConversion(aCString,aIgnoreCase,aCount);
PRBool result=PRBool(0==theAnswer);
return result;
}
PRBool nsCString::Equals(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=Compare(aString,aIgnoreCase,aCount);
PRBool nsCString::EqualsWithConversion(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=CompareWithConversion(aString,aIgnoreCase,aCount);
PRBool result=PRBool(0==theAnswer);
return result;
}

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

@ -655,11 +655,52 @@ public:
* @param aCount tells us how many chars to compare
* @return -1,0,1
*/
virtual PRInt32 Compare(const nsStr &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
virtual PRInt32 Compare(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
virtual PRInt32 Compare(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRInt32 CompareWithConversion(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRInt32 CompareWithConversion(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool EqualsWithConversion(const nsString &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool EqualsWithConversion(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool EqualsWithConversion(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool EqualsIgnoreCase(const char* aString,PRInt32 aCount=-1) const;
PRBool EqualsIgnoreCase(const PRUnichar* aString,PRInt32 aCount=-1) const;
#ifndef NEW_STRING_APIS
virtual PRInt32 Compare(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return CompareWithConversion(aString,aIgnoreCase,aCount);
}
virtual PRInt32 Compare(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return CompareWithConversion(aString,aIgnoreCase,aCount);
}
virtual PRInt32 Compare(const nsStr &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
/**
* Compare this to given string; note that we compare full strings here.
* The optional length argument just lets us know how long the given string is.
* If you provide a length, it is compared to length of this string as an
* optimization.
*
* @param aString -- the string to compare to this
* @param aCount -- number of chars in given string you want to compare
* @return TRUE if equal
*/
PRBool Equals(const nsString &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return EqualsWithConversion(aString,aIgnoreCase,aCount);
}
PRBool Equals(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return EqualsWithConversion(aString,aIgnoreCase,aCount);
}
PRBool Equals(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return EqualsWithConversion(aString,aIgnoreCase,aCount);
}
PRBool Equals(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool EqualsIgnoreCase(const nsStr& aString) const;
/**
* These methods compare a given string type to this one
* @param aString is the string to be compared to this
@ -715,25 +756,6 @@ public:
PRBool operator>=(const PRUnichar* aString) const;
#endif // !defined(NEW_STRING_APIS)
/**
* Compare this to given string; note that we compare full strings here.
* The optional length argument just lets us know how long the given string is.
* If you provide a length, it is compared to length of this string as an
* optimization.
*
* @param aString -- the string to compare to this
* @param aCount -- number of chars in given string you want to compare
* @return TRUE if equal
*/
PRBool Equals(const nsString &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool Equals(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool Equals(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool Equals(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool EqualsIgnoreCase(const nsStr& aString) const;
PRBool EqualsIgnoreCase(const char* aString,PRInt32 aCount=-1) const;
PRBool EqualsIgnoreCase(const PRUnichar* aString,PRInt32 aCount=-1) const;
void DebugDump(void) const;

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

@ -1807,9 +1807,20 @@ PRInt32 nsString::RFindCharInSet(const PRUnichar* aStringSet,PRInt32 anOffset) c
* @param aCount tells us how many chars to test; -1 implies full length
* @return -1,0,1
*/
PRInt32 nsString::Compare(const nsString& aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 result=nsStr::Compare(*this,aString,aCount,aIgnoreCase);
return result;
PRInt32 nsString::CompareWithConversion(const char *aCString,PRBool aIgnoreCase,PRInt32 aCount) const {
NS_ASSERTION(0!=aCString,kNullPointerError);
if(aCString) {
nsStr temp;
nsStr::Initialize(temp,eOneByte);
temp.mLength= (0<aCount) ? aCount : nsCRT::strlen(aCString);
temp.mStr=(char*)aCString;
return nsStr::StrCompare(*this,temp,aCount,aIgnoreCase);
}
return 0;
}
/**
@ -1820,20 +1831,9 @@ PRInt32 nsString::Compare(const nsString& aString,PRBool aIgnoreCase,PRInt32 aCo
* @param aCount tells us how many chars to test; -1 implies full length
* @return -1,0,1
*/
PRInt32 nsString::Compare(const char *aCString,PRBool aIgnoreCase,PRInt32 aCount) const {
NS_ASSERTION(0!=aCString,kNullPointerError);
if(aCString) {
nsStr temp;
nsStr::Initialize(temp,eOneByte);
temp.mLength= (0<aCount) ? aCount : nsCRT::strlen(aCString);
temp.mStr=(char*)aCString;
return nsStr::Compare(*this,temp,aCount,aIgnoreCase);
}
return 0;
PRInt32 nsString::CompareWithConversion(const nsString& aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 result=nsStr::StrCompare(*this,aString,aCount,aIgnoreCase);
return result;
}
/**
@ -1844,7 +1844,7 @@ PRInt32 nsString::Compare(const char *aCString,PRBool aIgnoreCase,PRInt32 aCount
* @param aCount tells us how many chars to test; -1 implies full length
* @return -1,0,1
*/
PRInt32 nsString::Compare(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 nsString::CompareWithConversion(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
NS_ASSERTION(0!=aString,kNullPointerError);
if(aString) {
@ -1852,12 +1852,13 @@ PRInt32 nsString::Compare(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aC
nsStr::Initialize(temp,eTwoByte);
temp.mLength=nsCRT::strlen(aString);
temp.mUStr=(PRUnichar*)aString;
return nsStr::Compare(*this,temp,aCount,aIgnoreCase);
return nsStr::StrCompare(*this,temp,aCount,aIgnoreCase);
}
return 0;
}
#ifndef NEW_STRING_APIS
/**
* Compare given nsStr with this cstring.
*
@ -1867,9 +1868,9 @@ PRInt32 nsString::Compare(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aC
* @return -1,0,1
*/
PRInt32 nsString::Compare(const nsStr& aString,PRBool aIgnoreCase,PRInt32 aCount) const {
return nsStr::Compare(*this,aString,aCount,aIgnoreCase);
return nsStr::StrCompare(*this,aString,aCount,aIgnoreCase);
}
#endif
#ifndef NEW_STRING_APIS
/**
@ -1908,13 +1909,14 @@ PRBool nsString::operator>=(const PRUnichar* s) const {return PRBool(Compare(s)>
#endif // !defined(NEW_STRING_APIS)
PRBool nsString::EqualsIgnoreCase(const nsString& aString) const {
return Equals(aString,PR_TRUE);
return EqualsWithConversion(aString,PR_TRUE);
}
PRBool nsString::EqualsIgnoreCase(const char* aString,PRInt32 aLength) const {
return Equals(aString,PR_TRUE,aLength);
return EqualsWithConversion(aString,PR_TRUE,aLength);
}
#ifndef NEW_STRING_APIS
PRBool nsString::EqualsIgnoreCase(/*FIX: const */nsIAtom *aAtom) const {
return Equals(aAtom,PR_TRUE);
}
@ -1922,7 +1924,7 @@ PRBool nsString::EqualsIgnoreCase(/*FIX: const */nsIAtom *aAtom) const {
PRBool nsString::EqualsIgnoreCase(const PRUnichar* s1, const PRUnichar* s2) const {
return Equals(s1,s2,PR_TRUE);
}
#endif
/**
* Compare this to given string; note that we compare full strings here.
@ -1932,27 +1934,13 @@ PRBool nsString::EqualsIgnoreCase(const PRUnichar* s1, const PRUnichar* s2) cons
* @param aCount tells us how many chars to test; -1 implies full length
* @return TRUE if equal
*/
PRBool nsString::Equals(const nsString& aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=nsStr::Compare(*this,aString,aCount,aIgnoreCase);
PRBool nsString::EqualsWithConversion(const nsString& aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=nsStr::StrCompare(*this,aString,aCount,aIgnoreCase);
PRBool result=PRBool(0==theAnswer);
return result;
}
/**
* Compare this to given string; note that we compare full strings here.
*
* @update gess 01/04/99
* @param aString is the other nsString to be compared to
* @param aCount tells us how many chars to test; -1 implies full length
* @return TRUE if equal
*/
PRBool nsString::Equals(const nsStr& aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=nsStr::Compare(*this,aString,aCount,aIgnoreCase);
PRBool result=PRBool(0==theAnswer);
return result;
}
/**
* Compare this to given c-string; note that we compare full strings here.
*
@ -1961,8 +1949,8 @@ PRBool nsString::Equals(const nsStr& aString,PRBool aIgnoreCase,PRInt32 aCount)
* @param aCount tells us how many chars to test; -1 implies full length
* @return TRUE if equal
*/
PRBool nsString::Equals(const char* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=Compare(aString,aIgnoreCase,aCount);
PRBool nsString::EqualsWithConversion(const char* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=CompareWithConversion(aString,aIgnoreCase,aCount);
PRBool result=PRBool(0==theAnswer);
return result;
}
@ -1975,8 +1963,23 @@ PRBool nsString::Equals(const char* aString,PRBool aIgnoreCase,PRInt32 aCount) c
* @param aCount tells us how many chars to test; -1 implies full length
* @return TRUE if equal
*/
PRBool nsString::Equals(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=Compare(aString,aIgnoreCase,aCount);
PRBool nsString::EqualsWithConversion(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=CompareWithConversion(aString,aIgnoreCase,aCount);
PRBool result=PRBool(0==theAnswer);
return result;
}
#ifndef NEW_STRING_APIS
/**
* Compare this to given string; note that we compare full strings here.
*
* @update gess 01/04/99
* @param aString is the other nsString to be compared to
* @param aCount tells us how many chars to test; -1 implies full length
* @return TRUE if equal
*/
PRBool nsString::Equals(const nsStr& aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=nsStr::StrCompare(*this,aString,aCount,aIgnoreCase);
PRBool result=PRBool(0==theAnswer);
return result;
}
@ -2028,6 +2031,7 @@ PRBool nsString::Equals(const PRUnichar* s1, const PRUnichar* s2,PRBool aIgnoreC
return result;
}
#endif
/**
* Determine if given char in valid alpha range

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

@ -709,12 +709,62 @@ public:
* @param aCount tells us how many chars to compare
* @return -1,0,1
*/
virtual PRInt32 Compare(const nsString& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
virtual PRInt32 Compare(const nsStr &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
virtual PRInt32 Compare(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
virtual PRInt32 Compare(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRInt32 CompareWithConversion(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRInt32 CompareWithConversion(const nsString& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRInt32 CompareWithConversion(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool EqualsWithConversion(const nsString &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool EqualsWithConversion(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool EqualsWithConversion(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool EqualsIgnoreCase(const nsString& aString) const;
PRBool EqualsIgnoreCase(const char* aString,PRInt32 aCount=-1) const;
PRBool EqualsIgnoreCase(/*FIX: const */nsIAtom *aAtom) const;
PRBool EqualsIgnoreCase(const PRUnichar* s1, const PRUnichar* s2) const;
#ifndef NEW_STRING_APIS
virtual PRInt32 Compare(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return CompareWithConversion(aString,aIgnoreCase,aCount);
}
virtual PRInt32 Compare(const nsString& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return CompareWithConversion(aString,aIgnoreCase,aCount);
}
virtual PRInt32 Compare(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return CompareWithConversion(aString,aIgnoreCase,aCount);
}
virtual PRInt32 Compare(const nsStr &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
/**
* Compare this to given string; note that we compare full strings here.
* The optional length argument just lets us know how long the given string is.
* If you provide a length, it is compared to length of this string as an
* optimization.
*
* @param aString -- the string to compare to this
* @param aCount -- number of chars to be compared.
* @return TRUE if equal
*/
PRBool Equals(const nsString &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return EqualsWithConversion(aString,aIgnoreCase,aCount);
}
PRBool Equals(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return EqualsWithConversion(aString,aIgnoreCase,aCount);
}
PRBool Equals(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return EqualsWithConversion(aString,aIgnoreCase,aCount);
}
PRBool Equals(/*FIX: const */nsIAtom* anAtom,PRBool aIgnoreCase) const;
PRBool Equals(const PRUnichar* s1, const PRUnichar* s2,PRBool aIgnoreCase=PR_FALSE) const;
PRBool Equals(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
/**
* These methods compare a given string type to this one
* @param aString is the string to be compared to this
@ -776,28 +826,6 @@ public:
PRBool operator>=(const PRUnichar* aString) const;
#endif // !defined(NEW_STRING_APIS)
/**
* Compare this to given string; note that we compare full strings here.
* The optional length argument just lets us know how long the given string is.
* If you provide a length, it is compared to length of this string as an
* optimization.
*
* @param aString -- the string to compare to this
* @param aCount -- number of chars to be compared.
* @return TRUE if equal
*/
PRBool Equals(const nsString &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool Equals(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool Equals(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool Equals(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool Equals(/*FIX: const */nsIAtom* anAtom,PRBool aIgnoreCase) const;
PRBool Equals(const PRUnichar* s1, const PRUnichar* s2,PRBool aIgnoreCase=PR_FALSE) const;
PRBool EqualsIgnoreCase(const nsString& aString) const;
PRBool EqualsIgnoreCase(const char* aString,PRInt32 aCount=-1) const;
PRBool EqualsIgnoreCase(/*FIX: const */nsIAtom *aAtom) const;
PRBool EqualsIgnoreCase(const PRUnichar* s1, const PRUnichar* s2) const;
/**
* Determine if given buffer is plain ascii
*

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

@ -592,7 +592,7 @@ PRInt32 nsStr::RFindCharInSet(const nsStr& aDest,const nsStr& aSet,PRBool aIgnor
* @param aIgnorecase tells us whether to search with case sensitivity
* @return aDest<aSource=-1;aDest==aSource==0;aDest>aSource=1
*/
PRInt32 nsStr::Compare(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase) {
PRInt32 nsStr::StrCompare(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase) {
PRInt32 result=0;
if(aCount) {
@ -850,7 +850,7 @@ nsStr_Compare(const void *v1, const void *v2)
{
nsStr* str1 = (nsStr*)v1;
nsStr* str2 = (nsStr*)v2;
return nsStr::Compare(*str1, *str2, -1, PR_FALSE) == 0;
return nsStr::StrCompare(*str1, *str2, -1, PR_FALSE) == 0;
}
nsStringInfo*

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

@ -310,18 +310,6 @@ struct NS_COM nsStr {
*/
static void StrInsert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount);
#ifndef NEW_STRING_APIS
static void Append(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount) {
StrAppend(aDest, aSource, anOffset, aCount);
}
static void Assign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount) {
StrAssign(aDest, aSource, anOffset, aCount);
}
static void Insert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount) {
StrInsert(aDest, aDestOffset, aSource, aSrcOffset, aCount);
}
#endif
/**
* This method deletes chars from the given str.
* The given allocator may choose to resize the str as well.
@ -402,7 +390,7 @@ struct NS_COM nsStr {
* @param aIgnorecase tells us whether to use a case-sensitive comparison
* @return -1,0,1 depending on <,==,>
*/
static PRInt32 Compare(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase);
static PRInt32 StrCompare(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase);
/**
* These methods scan the given string for 1 or more chars in a given direction
@ -431,6 +419,22 @@ struct NS_COM nsStr {
*/
static PRUint32 HashCode(const nsStr& aDest);
#ifndef NEW_STRING_APIS
static void Append(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount) {
StrAppend(aDest, aSource, anOffset, aCount);
}
static void Assign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount) {
StrAssign(aDest, aSource, anOffset, aCount);
}
static void Insert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount) {
StrInsert(aDest, aDestOffset, aSource, aSrcOffset, aCount);
}
static PRInt32 Compare(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase) {
return StrCompare(aDest, aSource, aCount, aIgnoreCase);
}
#endif
#ifdef NS_STR_STATS
/**
* Prints an nsStr. If truncate is true, the string is only printed up to

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

@ -1518,27 +1518,6 @@ PRInt32 nsCString::RFindCharInSet(const nsStr& aSet,PRInt32 anOffset) const{
**************************************************************/
/**
* Compares given cstring to this string.
* @update gess 01/04/99
* @param aCString points to a cstring
* @param aIgnoreCase tells us how to treat case
* @param aCount tells us how many chars to test; -1 implies full length
* @return -1,0,1
*/
PRInt32 nsCString::Compare(const char *aCString,PRBool aIgnoreCase,PRInt32 aCount) const {
NS_ASSERTION(0!=aCString,kNullPointerError);
if(aCString) {
nsStr temp;
nsStr::Initialize(temp,eOneByte);
temp.mLength=nsCRT::strlen(aCString);
temp.mStr=(char*)aCString;
return nsStr::Compare(*this,temp,aCount,aIgnoreCase);
}
return 0;
}
/**
* Compares given unistring to this string.
* @update gess 01/04/99
@ -1547,7 +1526,7 @@ PRInt32 nsCString::Compare(const char *aCString,PRBool aIgnoreCase,PRInt32 aCoun
* @param aCount tells us how many chars to test; -1 implies full length
* @return -1,0,1
*/
PRInt32 nsCString::Compare(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 nsCString::CompareWithConversion(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
NS_ASSERTION(0!=aString,kNullPointerError);
if(aString) {
@ -1555,11 +1534,33 @@ PRInt32 nsCString::Compare(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 a
nsStr::Initialize(temp,eTwoByte);
temp.mLength=nsCRT::strlen(aString);
temp.mUStr=(PRUnichar*)aString;
return nsStr::Compare(*this,temp,aCount,aIgnoreCase);
return nsStr::StrCompare(*this,temp,aCount,aIgnoreCase);
}
return 0;
}
/**
* Compares given cstring to this string.
* @update gess 01/04/99
* @param aCString points to a cstring
* @param aIgnoreCase tells us how to treat case
* @param aCount tells us how many chars to test; -1 implies full length
* @return -1,0,1
*/
PRInt32 nsCString::CompareWithConversion(const char *aCString,PRBool aIgnoreCase,PRInt32 aCount) const {
NS_ASSERTION(0!=aCString,kNullPointerError);
if(aCString) {
nsStr temp;
nsStr::Initialize(temp,eOneByte);
temp.mLength=nsCRT::strlen(aCString);
temp.mStr=(char*)aCString;
return nsStr::StrCompare(*this,temp,aCount,aIgnoreCase);
}
return 0;
}
#ifndef NEW_STRING_APIS
/**
* Compare given nsStr with this cstring.
*
@ -1569,8 +1570,9 @@ PRInt32 nsCString::Compare(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 a
* @return -1,0,1
*/
PRInt32 nsCString::Compare(const nsStr& aString,PRBool aIgnoreCase,PRInt32 aCount) const {
return nsStr::Compare(*this,aString,aCount,aIgnoreCase);
return nsStr::StrCompare(*this,aString,aCount,aIgnoreCase);
}
#endif
#ifndef NEW_STRING_APIS
/**
@ -1601,19 +1603,22 @@ PRBool nsCString::operator>=(const char* s) const {return PRBool(Compare(s)>=0);
PRBool nsCString::operator>=(const PRUnichar* s) const {return PRBool(Compare(s)>=0);}
#endif
#ifndef NEW_STRING_APIS
PRBool nsCString::EqualsIgnoreCase(const nsStr& aString) const {
return Equals(aString,PR_TRUE);
}
#endif
PRBool nsCString::EqualsIgnoreCase(const char* aString,PRInt32 aLength) const {
return Equals(aString,PR_TRUE,aLength);
return EqualsWithConversion(aString,PR_TRUE,aLength);
}
PRBool nsCString::EqualsIgnoreCase(const PRUnichar* aString,PRInt32 aLength) const {
return Equals(aString,PR_TRUE,aLength);
return EqualsWithConversion(aString,PR_TRUE,aLength);
}
#ifndef NEW_STRING_APIS
/**
* Compare this to given string; note that we compare full strings here.
*
@ -1624,10 +1629,11 @@ PRBool nsCString::EqualsIgnoreCase(const PRUnichar* aString,PRInt32 aLength) con
* @return TRUE if equal
*/
PRBool nsCString::Equals(const nsStr& aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=nsStr::Compare(*this,aString,aCount,aIgnoreCase);
PRInt32 theAnswer=nsStr::StrCompare(*this,aString,aCount,aIgnoreCase);
PRBool result=PRBool(0==theAnswer);
return result;
}
#endif
/**
* Compare this to given string; note that we compare full strings here.
@ -1638,14 +1644,14 @@ PRBool nsCString::Equals(const nsStr& aString,PRBool aIgnoreCase,PRInt32 aCount)
* @param aCount tells us how many chars to test; -1 implies full length
* @return TRUE if equal
*/
PRBool nsCString::Equals(const char* aCString,PRBool aIgnoreCase,PRInt32 aCount) const{
PRInt32 theAnswer=Compare(aCString,aIgnoreCase,aCount);
PRBool nsCString::EqualsWithConversion(const char* aCString,PRBool aIgnoreCase,PRInt32 aCount) const{
PRInt32 theAnswer=CompareWithConversion(aCString,aIgnoreCase,aCount);
PRBool result=PRBool(0==theAnswer);
return result;
}
PRBool nsCString::Equals(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=Compare(aString,aIgnoreCase,aCount);
PRBool nsCString::EqualsWithConversion(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=CompareWithConversion(aString,aIgnoreCase,aCount);
PRBool result=PRBool(0==theAnswer);
return result;
}

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

@ -655,11 +655,52 @@ public:
* @param aCount tells us how many chars to compare
* @return -1,0,1
*/
virtual PRInt32 Compare(const nsStr &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
virtual PRInt32 Compare(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
virtual PRInt32 Compare(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRInt32 CompareWithConversion(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRInt32 CompareWithConversion(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool EqualsWithConversion(const nsString &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool EqualsWithConversion(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool EqualsWithConversion(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool EqualsIgnoreCase(const char* aString,PRInt32 aCount=-1) const;
PRBool EqualsIgnoreCase(const PRUnichar* aString,PRInt32 aCount=-1) const;
#ifndef NEW_STRING_APIS
virtual PRInt32 Compare(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return CompareWithConversion(aString,aIgnoreCase,aCount);
}
virtual PRInt32 Compare(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return CompareWithConversion(aString,aIgnoreCase,aCount);
}
virtual PRInt32 Compare(const nsStr &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
/**
* Compare this to given string; note that we compare full strings here.
* The optional length argument just lets us know how long the given string is.
* If you provide a length, it is compared to length of this string as an
* optimization.
*
* @param aString -- the string to compare to this
* @param aCount -- number of chars in given string you want to compare
* @return TRUE if equal
*/
PRBool Equals(const nsString &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return EqualsWithConversion(aString,aIgnoreCase,aCount);
}
PRBool Equals(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return EqualsWithConversion(aString,aIgnoreCase,aCount);
}
PRBool Equals(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return EqualsWithConversion(aString,aIgnoreCase,aCount);
}
PRBool Equals(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool EqualsIgnoreCase(const nsStr& aString) const;
/**
* These methods compare a given string type to this one
* @param aString is the string to be compared to this
@ -715,25 +756,6 @@ public:
PRBool operator>=(const PRUnichar* aString) const;
#endif // !defined(NEW_STRING_APIS)
/**
* Compare this to given string; note that we compare full strings here.
* The optional length argument just lets us know how long the given string is.
* If you provide a length, it is compared to length of this string as an
* optimization.
*
* @param aString -- the string to compare to this
* @param aCount -- number of chars in given string you want to compare
* @return TRUE if equal
*/
PRBool Equals(const nsString &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool Equals(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool Equals(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool Equals(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool EqualsIgnoreCase(const nsStr& aString) const;
PRBool EqualsIgnoreCase(const char* aString,PRInt32 aCount=-1) const;
PRBool EqualsIgnoreCase(const PRUnichar* aString,PRInt32 aCount=-1) const;
void DebugDump(void) const;

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

@ -1807,9 +1807,20 @@ PRInt32 nsString::RFindCharInSet(const PRUnichar* aStringSet,PRInt32 anOffset) c
* @param aCount tells us how many chars to test; -1 implies full length
* @return -1,0,1
*/
PRInt32 nsString::Compare(const nsString& aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 result=nsStr::Compare(*this,aString,aCount,aIgnoreCase);
return result;
PRInt32 nsString::CompareWithConversion(const char *aCString,PRBool aIgnoreCase,PRInt32 aCount) const {
NS_ASSERTION(0!=aCString,kNullPointerError);
if(aCString) {
nsStr temp;
nsStr::Initialize(temp,eOneByte);
temp.mLength= (0<aCount) ? aCount : nsCRT::strlen(aCString);
temp.mStr=(char*)aCString;
return nsStr::StrCompare(*this,temp,aCount,aIgnoreCase);
}
return 0;
}
/**
@ -1820,20 +1831,9 @@ PRInt32 nsString::Compare(const nsString& aString,PRBool aIgnoreCase,PRInt32 aCo
* @param aCount tells us how many chars to test; -1 implies full length
* @return -1,0,1
*/
PRInt32 nsString::Compare(const char *aCString,PRBool aIgnoreCase,PRInt32 aCount) const {
NS_ASSERTION(0!=aCString,kNullPointerError);
if(aCString) {
nsStr temp;
nsStr::Initialize(temp,eOneByte);
temp.mLength= (0<aCount) ? aCount : nsCRT::strlen(aCString);
temp.mStr=(char*)aCString;
return nsStr::Compare(*this,temp,aCount,aIgnoreCase);
}
return 0;
PRInt32 nsString::CompareWithConversion(const nsString& aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 result=nsStr::StrCompare(*this,aString,aCount,aIgnoreCase);
return result;
}
/**
@ -1844,7 +1844,7 @@ PRInt32 nsString::Compare(const char *aCString,PRBool aIgnoreCase,PRInt32 aCount
* @param aCount tells us how many chars to test; -1 implies full length
* @return -1,0,1
*/
PRInt32 nsString::Compare(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 nsString::CompareWithConversion(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
NS_ASSERTION(0!=aString,kNullPointerError);
if(aString) {
@ -1852,12 +1852,13 @@ PRInt32 nsString::Compare(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aC
nsStr::Initialize(temp,eTwoByte);
temp.mLength=nsCRT::strlen(aString);
temp.mUStr=(PRUnichar*)aString;
return nsStr::Compare(*this,temp,aCount,aIgnoreCase);
return nsStr::StrCompare(*this,temp,aCount,aIgnoreCase);
}
return 0;
}
#ifndef NEW_STRING_APIS
/**
* Compare given nsStr with this cstring.
*
@ -1867,9 +1868,9 @@ PRInt32 nsString::Compare(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aC
* @return -1,0,1
*/
PRInt32 nsString::Compare(const nsStr& aString,PRBool aIgnoreCase,PRInt32 aCount) const {
return nsStr::Compare(*this,aString,aCount,aIgnoreCase);
return nsStr::StrCompare(*this,aString,aCount,aIgnoreCase);
}
#endif
#ifndef NEW_STRING_APIS
/**
@ -1908,13 +1909,14 @@ PRBool nsString::operator>=(const PRUnichar* s) const {return PRBool(Compare(s)>
#endif // !defined(NEW_STRING_APIS)
PRBool nsString::EqualsIgnoreCase(const nsString& aString) const {
return Equals(aString,PR_TRUE);
return EqualsWithConversion(aString,PR_TRUE);
}
PRBool nsString::EqualsIgnoreCase(const char* aString,PRInt32 aLength) const {
return Equals(aString,PR_TRUE,aLength);
return EqualsWithConversion(aString,PR_TRUE,aLength);
}
#ifndef NEW_STRING_APIS
PRBool nsString::EqualsIgnoreCase(/*FIX: const */nsIAtom *aAtom) const {
return Equals(aAtom,PR_TRUE);
}
@ -1922,7 +1924,7 @@ PRBool nsString::EqualsIgnoreCase(/*FIX: const */nsIAtom *aAtom) const {
PRBool nsString::EqualsIgnoreCase(const PRUnichar* s1, const PRUnichar* s2) const {
return Equals(s1,s2,PR_TRUE);
}
#endif
/**
* Compare this to given string; note that we compare full strings here.
@ -1932,27 +1934,13 @@ PRBool nsString::EqualsIgnoreCase(const PRUnichar* s1, const PRUnichar* s2) cons
* @param aCount tells us how many chars to test; -1 implies full length
* @return TRUE if equal
*/
PRBool nsString::Equals(const nsString& aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=nsStr::Compare(*this,aString,aCount,aIgnoreCase);
PRBool nsString::EqualsWithConversion(const nsString& aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=nsStr::StrCompare(*this,aString,aCount,aIgnoreCase);
PRBool result=PRBool(0==theAnswer);
return result;
}
/**
* Compare this to given string; note that we compare full strings here.
*
* @update gess 01/04/99
* @param aString is the other nsString to be compared to
* @param aCount tells us how many chars to test; -1 implies full length
* @return TRUE if equal
*/
PRBool nsString::Equals(const nsStr& aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=nsStr::Compare(*this,aString,aCount,aIgnoreCase);
PRBool result=PRBool(0==theAnswer);
return result;
}
/**
* Compare this to given c-string; note that we compare full strings here.
*
@ -1961,8 +1949,8 @@ PRBool nsString::Equals(const nsStr& aString,PRBool aIgnoreCase,PRInt32 aCount)
* @param aCount tells us how many chars to test; -1 implies full length
* @return TRUE if equal
*/
PRBool nsString::Equals(const char* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=Compare(aString,aIgnoreCase,aCount);
PRBool nsString::EqualsWithConversion(const char* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=CompareWithConversion(aString,aIgnoreCase,aCount);
PRBool result=PRBool(0==theAnswer);
return result;
}
@ -1975,8 +1963,23 @@ PRBool nsString::Equals(const char* aString,PRBool aIgnoreCase,PRInt32 aCount) c
* @param aCount tells us how many chars to test; -1 implies full length
* @return TRUE if equal
*/
PRBool nsString::Equals(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=Compare(aString,aIgnoreCase,aCount);
PRBool nsString::EqualsWithConversion(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=CompareWithConversion(aString,aIgnoreCase,aCount);
PRBool result=PRBool(0==theAnswer);
return result;
}
#ifndef NEW_STRING_APIS
/**
* Compare this to given string; note that we compare full strings here.
*
* @update gess 01/04/99
* @param aString is the other nsString to be compared to
* @param aCount tells us how many chars to test; -1 implies full length
* @return TRUE if equal
*/
PRBool nsString::Equals(const nsStr& aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=nsStr::StrCompare(*this,aString,aCount,aIgnoreCase);
PRBool result=PRBool(0==theAnswer);
return result;
}
@ -2028,6 +2031,7 @@ PRBool nsString::Equals(const PRUnichar* s1, const PRUnichar* s2,PRBool aIgnoreC
return result;
}
#endif
/**
* Determine if given char in valid alpha range

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

@ -709,12 +709,62 @@ public:
* @param aCount tells us how many chars to compare
* @return -1,0,1
*/
virtual PRInt32 Compare(const nsString& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
virtual PRInt32 Compare(const nsStr &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
virtual PRInt32 Compare(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
virtual PRInt32 Compare(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRInt32 CompareWithConversion(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRInt32 CompareWithConversion(const nsString& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRInt32 CompareWithConversion(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool EqualsWithConversion(const nsString &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool EqualsWithConversion(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool EqualsWithConversion(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool EqualsIgnoreCase(const nsString& aString) const;
PRBool EqualsIgnoreCase(const char* aString,PRInt32 aCount=-1) const;
PRBool EqualsIgnoreCase(/*FIX: const */nsIAtom *aAtom) const;
PRBool EqualsIgnoreCase(const PRUnichar* s1, const PRUnichar* s2) const;
#ifndef NEW_STRING_APIS
virtual PRInt32 Compare(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return CompareWithConversion(aString,aIgnoreCase,aCount);
}
virtual PRInt32 Compare(const nsString& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return CompareWithConversion(aString,aIgnoreCase,aCount);
}
virtual PRInt32 Compare(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return CompareWithConversion(aString,aIgnoreCase,aCount);
}
virtual PRInt32 Compare(const nsStr &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
/**
* Compare this to given string; note that we compare full strings here.
* The optional length argument just lets us know how long the given string is.
* If you provide a length, it is compared to length of this string as an
* optimization.
*
* @param aString -- the string to compare to this
* @param aCount -- number of chars to be compared.
* @return TRUE if equal
*/
PRBool Equals(const nsString &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return EqualsWithConversion(aString,aIgnoreCase,aCount);
}
PRBool Equals(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return EqualsWithConversion(aString,aIgnoreCase,aCount);
}
PRBool Equals(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return EqualsWithConversion(aString,aIgnoreCase,aCount);
}
PRBool Equals(/*FIX: const */nsIAtom* anAtom,PRBool aIgnoreCase) const;
PRBool Equals(const PRUnichar* s1, const PRUnichar* s2,PRBool aIgnoreCase=PR_FALSE) const;
PRBool Equals(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
/**
* These methods compare a given string type to this one
* @param aString is the string to be compared to this
@ -776,28 +826,6 @@ public:
PRBool operator>=(const PRUnichar* aString) const;
#endif // !defined(NEW_STRING_APIS)
/**
* Compare this to given string; note that we compare full strings here.
* The optional length argument just lets us know how long the given string is.
* If you provide a length, it is compared to length of this string as an
* optimization.
*
* @param aString -- the string to compare to this
* @param aCount -- number of chars to be compared.
* @return TRUE if equal
*/
PRBool Equals(const nsString &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool Equals(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool Equals(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool Equals(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool Equals(/*FIX: const */nsIAtom* anAtom,PRBool aIgnoreCase) const;
PRBool Equals(const PRUnichar* s1, const PRUnichar* s2,PRBool aIgnoreCase=PR_FALSE) const;
PRBool EqualsIgnoreCase(const nsString& aString) const;
PRBool EqualsIgnoreCase(const char* aString,PRInt32 aCount=-1) const;
PRBool EqualsIgnoreCase(/*FIX: const */nsIAtom *aAtom) const;
PRBool EqualsIgnoreCase(const PRUnichar* s1, const PRUnichar* s2) const;
/**
* Determine if given buffer is plain ascii
*

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

@ -592,7 +592,7 @@ PRInt32 nsStr::RFindCharInSet(const nsStr& aDest,const nsStr& aSet,PRBool aIgnor
* @param aIgnorecase tells us whether to search with case sensitivity
* @return aDest<aSource=-1;aDest==aSource==0;aDest>aSource=1
*/
PRInt32 nsStr::Compare(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase) {
PRInt32 nsStr::StrCompare(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase) {
PRInt32 result=0;
if(aCount) {
@ -850,7 +850,7 @@ nsStr_Compare(const void *v1, const void *v2)
{
nsStr* str1 = (nsStr*)v1;
nsStr* str2 = (nsStr*)v2;
return nsStr::Compare(*str1, *str2, -1, PR_FALSE) == 0;
return nsStr::StrCompare(*str1, *str2, -1, PR_FALSE) == 0;
}
nsStringInfo*

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

@ -310,18 +310,6 @@ struct NS_COM nsStr {
*/
static void StrInsert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount);
#ifndef NEW_STRING_APIS
static void Append(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount) {
StrAppend(aDest, aSource, anOffset, aCount);
}
static void Assign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount) {
StrAssign(aDest, aSource, anOffset, aCount);
}
static void Insert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount) {
StrInsert(aDest, aDestOffset, aSource, aSrcOffset, aCount);
}
#endif
/**
* This method deletes chars from the given str.
* The given allocator may choose to resize the str as well.
@ -402,7 +390,7 @@ struct NS_COM nsStr {
* @param aIgnorecase tells us whether to use a case-sensitive comparison
* @return -1,0,1 depending on <,==,>
*/
static PRInt32 Compare(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase);
static PRInt32 StrCompare(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase);
/**
* These methods scan the given string for 1 or more chars in a given direction
@ -431,6 +419,22 @@ struct NS_COM nsStr {
*/
static PRUint32 HashCode(const nsStr& aDest);
#ifndef NEW_STRING_APIS
static void Append(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount) {
StrAppend(aDest, aSource, anOffset, aCount);
}
static void Assign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount) {
StrAssign(aDest, aSource, anOffset, aCount);
}
static void Insert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount) {
StrInsert(aDest, aDestOffset, aSource, aSrcOffset, aCount);
}
static PRInt32 Compare(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PRBool aIgnoreCase) {
return StrCompare(aDest, aSource, aCount, aIgnoreCase);
}
#endif
#ifdef NS_STR_STATS
/**
* Prints an nsStr. If truncate is true, the string is only printed up to

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

@ -1518,27 +1518,6 @@ PRInt32 nsCString::RFindCharInSet(const nsStr& aSet,PRInt32 anOffset) const{
**************************************************************/
/**
* Compares given cstring to this string.
* @update gess 01/04/99
* @param aCString points to a cstring
* @param aIgnoreCase tells us how to treat case
* @param aCount tells us how many chars to test; -1 implies full length
* @return -1,0,1
*/
PRInt32 nsCString::Compare(const char *aCString,PRBool aIgnoreCase,PRInt32 aCount) const {
NS_ASSERTION(0!=aCString,kNullPointerError);
if(aCString) {
nsStr temp;
nsStr::Initialize(temp,eOneByte);
temp.mLength=nsCRT::strlen(aCString);
temp.mStr=(char*)aCString;
return nsStr::Compare(*this,temp,aCount,aIgnoreCase);
}
return 0;
}
/**
* Compares given unistring to this string.
* @update gess 01/04/99
@ -1547,7 +1526,7 @@ PRInt32 nsCString::Compare(const char *aCString,PRBool aIgnoreCase,PRInt32 aCoun
* @param aCount tells us how many chars to test; -1 implies full length
* @return -1,0,1
*/
PRInt32 nsCString::Compare(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 nsCString::CompareWithConversion(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
NS_ASSERTION(0!=aString,kNullPointerError);
if(aString) {
@ -1555,11 +1534,33 @@ PRInt32 nsCString::Compare(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 a
nsStr::Initialize(temp,eTwoByte);
temp.mLength=nsCRT::strlen(aString);
temp.mUStr=(PRUnichar*)aString;
return nsStr::Compare(*this,temp,aCount,aIgnoreCase);
return nsStr::StrCompare(*this,temp,aCount,aIgnoreCase);
}
return 0;
}
/**
* Compares given cstring to this string.
* @update gess 01/04/99
* @param aCString points to a cstring
* @param aIgnoreCase tells us how to treat case
* @param aCount tells us how many chars to test; -1 implies full length
* @return -1,0,1
*/
PRInt32 nsCString::CompareWithConversion(const char *aCString,PRBool aIgnoreCase,PRInt32 aCount) const {
NS_ASSERTION(0!=aCString,kNullPointerError);
if(aCString) {
nsStr temp;
nsStr::Initialize(temp,eOneByte);
temp.mLength=nsCRT::strlen(aCString);
temp.mStr=(char*)aCString;
return nsStr::StrCompare(*this,temp,aCount,aIgnoreCase);
}
return 0;
}
#ifndef NEW_STRING_APIS
/**
* Compare given nsStr with this cstring.
*
@ -1569,8 +1570,9 @@ PRInt32 nsCString::Compare(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 a
* @return -1,0,1
*/
PRInt32 nsCString::Compare(const nsStr& aString,PRBool aIgnoreCase,PRInt32 aCount) const {
return nsStr::Compare(*this,aString,aCount,aIgnoreCase);
return nsStr::StrCompare(*this,aString,aCount,aIgnoreCase);
}
#endif
#ifndef NEW_STRING_APIS
/**
@ -1601,19 +1603,22 @@ PRBool nsCString::operator>=(const char* s) const {return PRBool(Compare(s)>=0);
PRBool nsCString::operator>=(const PRUnichar* s) const {return PRBool(Compare(s)>=0);}
#endif
#ifndef NEW_STRING_APIS
PRBool nsCString::EqualsIgnoreCase(const nsStr& aString) const {
return Equals(aString,PR_TRUE);
}
#endif
PRBool nsCString::EqualsIgnoreCase(const char* aString,PRInt32 aLength) const {
return Equals(aString,PR_TRUE,aLength);
return EqualsWithConversion(aString,PR_TRUE,aLength);
}
PRBool nsCString::EqualsIgnoreCase(const PRUnichar* aString,PRInt32 aLength) const {
return Equals(aString,PR_TRUE,aLength);
return EqualsWithConversion(aString,PR_TRUE,aLength);
}
#ifndef NEW_STRING_APIS
/**
* Compare this to given string; note that we compare full strings here.
*
@ -1624,10 +1629,11 @@ PRBool nsCString::EqualsIgnoreCase(const PRUnichar* aString,PRInt32 aLength) con
* @return TRUE if equal
*/
PRBool nsCString::Equals(const nsStr& aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=nsStr::Compare(*this,aString,aCount,aIgnoreCase);
PRInt32 theAnswer=nsStr::StrCompare(*this,aString,aCount,aIgnoreCase);
PRBool result=PRBool(0==theAnswer);
return result;
}
#endif
/**
* Compare this to given string; note that we compare full strings here.
@ -1638,14 +1644,14 @@ PRBool nsCString::Equals(const nsStr& aString,PRBool aIgnoreCase,PRInt32 aCount)
* @param aCount tells us how many chars to test; -1 implies full length
* @return TRUE if equal
*/
PRBool nsCString::Equals(const char* aCString,PRBool aIgnoreCase,PRInt32 aCount) const{
PRInt32 theAnswer=Compare(aCString,aIgnoreCase,aCount);
PRBool nsCString::EqualsWithConversion(const char* aCString,PRBool aIgnoreCase,PRInt32 aCount) const{
PRInt32 theAnswer=CompareWithConversion(aCString,aIgnoreCase,aCount);
PRBool result=PRBool(0==theAnswer);
return result;
}
PRBool nsCString::Equals(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=Compare(aString,aIgnoreCase,aCount);
PRBool nsCString::EqualsWithConversion(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=CompareWithConversion(aString,aIgnoreCase,aCount);
PRBool result=PRBool(0==theAnswer);
return result;
}

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

@ -655,11 +655,52 @@ public:
* @param aCount tells us how many chars to compare
* @return -1,0,1
*/
virtual PRInt32 Compare(const nsStr &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
virtual PRInt32 Compare(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
virtual PRInt32 Compare(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRInt32 CompareWithConversion(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRInt32 CompareWithConversion(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool EqualsWithConversion(const nsString &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool EqualsWithConversion(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool EqualsWithConversion(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool EqualsIgnoreCase(const char* aString,PRInt32 aCount=-1) const;
PRBool EqualsIgnoreCase(const PRUnichar* aString,PRInt32 aCount=-1) const;
#ifndef NEW_STRING_APIS
virtual PRInt32 Compare(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return CompareWithConversion(aString,aIgnoreCase,aCount);
}
virtual PRInt32 Compare(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return CompareWithConversion(aString,aIgnoreCase,aCount);
}
virtual PRInt32 Compare(const nsStr &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
/**
* Compare this to given string; note that we compare full strings here.
* The optional length argument just lets us know how long the given string is.
* If you provide a length, it is compared to length of this string as an
* optimization.
*
* @param aString -- the string to compare to this
* @param aCount -- number of chars in given string you want to compare
* @return TRUE if equal
*/
PRBool Equals(const nsString &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return EqualsWithConversion(aString,aIgnoreCase,aCount);
}
PRBool Equals(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return EqualsWithConversion(aString,aIgnoreCase,aCount);
}
PRBool Equals(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return EqualsWithConversion(aString,aIgnoreCase,aCount);
}
PRBool Equals(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool EqualsIgnoreCase(const nsStr& aString) const;
/**
* These methods compare a given string type to this one
* @param aString is the string to be compared to this
@ -715,25 +756,6 @@ public:
PRBool operator>=(const PRUnichar* aString) const;
#endif // !defined(NEW_STRING_APIS)
/**
* Compare this to given string; note that we compare full strings here.
* The optional length argument just lets us know how long the given string is.
* If you provide a length, it is compared to length of this string as an
* optimization.
*
* @param aString -- the string to compare to this
* @param aCount -- number of chars in given string you want to compare
* @return TRUE if equal
*/
PRBool Equals(const nsString &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool Equals(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool Equals(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool Equals(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool EqualsIgnoreCase(const nsStr& aString) const;
PRBool EqualsIgnoreCase(const char* aString,PRInt32 aCount=-1) const;
PRBool EqualsIgnoreCase(const PRUnichar* aString,PRInt32 aCount=-1) const;
void DebugDump(void) const;

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

@ -1807,9 +1807,20 @@ PRInt32 nsString::RFindCharInSet(const PRUnichar* aStringSet,PRInt32 anOffset) c
* @param aCount tells us how many chars to test; -1 implies full length
* @return -1,0,1
*/
PRInt32 nsString::Compare(const nsString& aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 result=nsStr::Compare(*this,aString,aCount,aIgnoreCase);
return result;
PRInt32 nsString::CompareWithConversion(const char *aCString,PRBool aIgnoreCase,PRInt32 aCount) const {
NS_ASSERTION(0!=aCString,kNullPointerError);
if(aCString) {
nsStr temp;
nsStr::Initialize(temp,eOneByte);
temp.mLength= (0<aCount) ? aCount : nsCRT::strlen(aCString);
temp.mStr=(char*)aCString;
return nsStr::StrCompare(*this,temp,aCount,aIgnoreCase);
}
return 0;
}
/**
@ -1820,20 +1831,9 @@ PRInt32 nsString::Compare(const nsString& aString,PRBool aIgnoreCase,PRInt32 aCo
* @param aCount tells us how many chars to test; -1 implies full length
* @return -1,0,1
*/
PRInt32 nsString::Compare(const char *aCString,PRBool aIgnoreCase,PRInt32 aCount) const {
NS_ASSERTION(0!=aCString,kNullPointerError);
if(aCString) {
nsStr temp;
nsStr::Initialize(temp,eOneByte);
temp.mLength= (0<aCount) ? aCount : nsCRT::strlen(aCString);
temp.mStr=(char*)aCString;
return nsStr::Compare(*this,temp,aCount,aIgnoreCase);
}
return 0;
PRInt32 nsString::CompareWithConversion(const nsString& aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 result=nsStr::StrCompare(*this,aString,aCount,aIgnoreCase);
return result;
}
/**
@ -1844,7 +1844,7 @@ PRInt32 nsString::Compare(const char *aCString,PRBool aIgnoreCase,PRInt32 aCount
* @param aCount tells us how many chars to test; -1 implies full length
* @return -1,0,1
*/
PRInt32 nsString::Compare(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 nsString::CompareWithConversion(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
NS_ASSERTION(0!=aString,kNullPointerError);
if(aString) {
@ -1852,12 +1852,13 @@ PRInt32 nsString::Compare(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aC
nsStr::Initialize(temp,eTwoByte);
temp.mLength=nsCRT::strlen(aString);
temp.mUStr=(PRUnichar*)aString;
return nsStr::Compare(*this,temp,aCount,aIgnoreCase);
return nsStr::StrCompare(*this,temp,aCount,aIgnoreCase);
}
return 0;
}
#ifndef NEW_STRING_APIS
/**
* Compare given nsStr with this cstring.
*
@ -1867,9 +1868,9 @@ PRInt32 nsString::Compare(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aC
* @return -1,0,1
*/
PRInt32 nsString::Compare(const nsStr& aString,PRBool aIgnoreCase,PRInt32 aCount) const {
return nsStr::Compare(*this,aString,aCount,aIgnoreCase);
return nsStr::StrCompare(*this,aString,aCount,aIgnoreCase);
}
#endif
#ifndef NEW_STRING_APIS
/**
@ -1908,13 +1909,14 @@ PRBool nsString::operator>=(const PRUnichar* s) const {return PRBool(Compare(s)>
#endif // !defined(NEW_STRING_APIS)
PRBool nsString::EqualsIgnoreCase(const nsString& aString) const {
return Equals(aString,PR_TRUE);
return EqualsWithConversion(aString,PR_TRUE);
}
PRBool nsString::EqualsIgnoreCase(const char* aString,PRInt32 aLength) const {
return Equals(aString,PR_TRUE,aLength);
return EqualsWithConversion(aString,PR_TRUE,aLength);
}
#ifndef NEW_STRING_APIS
PRBool nsString::EqualsIgnoreCase(/*FIX: const */nsIAtom *aAtom) const {
return Equals(aAtom,PR_TRUE);
}
@ -1922,7 +1924,7 @@ PRBool nsString::EqualsIgnoreCase(/*FIX: const */nsIAtom *aAtom) const {
PRBool nsString::EqualsIgnoreCase(const PRUnichar* s1, const PRUnichar* s2) const {
return Equals(s1,s2,PR_TRUE);
}
#endif
/**
* Compare this to given string; note that we compare full strings here.
@ -1932,27 +1934,13 @@ PRBool nsString::EqualsIgnoreCase(const PRUnichar* s1, const PRUnichar* s2) cons
* @param aCount tells us how many chars to test; -1 implies full length
* @return TRUE if equal
*/
PRBool nsString::Equals(const nsString& aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=nsStr::Compare(*this,aString,aCount,aIgnoreCase);
PRBool nsString::EqualsWithConversion(const nsString& aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=nsStr::StrCompare(*this,aString,aCount,aIgnoreCase);
PRBool result=PRBool(0==theAnswer);
return result;
}
/**
* Compare this to given string; note that we compare full strings here.
*
* @update gess 01/04/99
* @param aString is the other nsString to be compared to
* @param aCount tells us how many chars to test; -1 implies full length
* @return TRUE if equal
*/
PRBool nsString::Equals(const nsStr& aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=nsStr::Compare(*this,aString,aCount,aIgnoreCase);
PRBool result=PRBool(0==theAnswer);
return result;
}
/**
* Compare this to given c-string; note that we compare full strings here.
*
@ -1961,8 +1949,8 @@ PRBool nsString::Equals(const nsStr& aString,PRBool aIgnoreCase,PRInt32 aCount)
* @param aCount tells us how many chars to test; -1 implies full length
* @return TRUE if equal
*/
PRBool nsString::Equals(const char* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=Compare(aString,aIgnoreCase,aCount);
PRBool nsString::EqualsWithConversion(const char* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=CompareWithConversion(aString,aIgnoreCase,aCount);
PRBool result=PRBool(0==theAnswer);
return result;
}
@ -1975,8 +1963,23 @@ PRBool nsString::Equals(const char* aString,PRBool aIgnoreCase,PRInt32 aCount) c
* @param aCount tells us how many chars to test; -1 implies full length
* @return TRUE if equal
*/
PRBool nsString::Equals(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=Compare(aString,aIgnoreCase,aCount);
PRBool nsString::EqualsWithConversion(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=CompareWithConversion(aString,aIgnoreCase,aCount);
PRBool result=PRBool(0==theAnswer);
return result;
}
#ifndef NEW_STRING_APIS
/**
* Compare this to given string; note that we compare full strings here.
*
* @update gess 01/04/99
* @param aString is the other nsString to be compared to
* @param aCount tells us how many chars to test; -1 implies full length
* @return TRUE if equal
*/
PRBool nsString::Equals(const nsStr& aString,PRBool aIgnoreCase,PRInt32 aCount) const {
PRInt32 theAnswer=nsStr::StrCompare(*this,aString,aCount,aIgnoreCase);
PRBool result=PRBool(0==theAnswer);
return result;
}
@ -2028,6 +2031,7 @@ PRBool nsString::Equals(const PRUnichar* s1, const PRUnichar* s2,PRBool aIgnoreC
return result;
}
#endif
/**
* Determine if given char in valid alpha range

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

@ -709,12 +709,62 @@ public:
* @param aCount tells us how many chars to compare
* @return -1,0,1
*/
virtual PRInt32 Compare(const nsString& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
virtual PRInt32 Compare(const nsStr &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
virtual PRInt32 Compare(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
virtual PRInt32 Compare(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRInt32 CompareWithConversion(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRInt32 CompareWithConversion(const nsString& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRInt32 CompareWithConversion(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool EqualsWithConversion(const nsString &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool EqualsWithConversion(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool EqualsWithConversion(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool EqualsIgnoreCase(const nsString& aString) const;
PRBool EqualsIgnoreCase(const char* aString,PRInt32 aCount=-1) const;
PRBool EqualsIgnoreCase(/*FIX: const */nsIAtom *aAtom) const;
PRBool EqualsIgnoreCase(const PRUnichar* s1, const PRUnichar* s2) const;
#ifndef NEW_STRING_APIS
virtual PRInt32 Compare(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return CompareWithConversion(aString,aIgnoreCase,aCount);
}
virtual PRInt32 Compare(const nsString& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return CompareWithConversion(aString,aIgnoreCase,aCount);
}
virtual PRInt32 Compare(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return CompareWithConversion(aString,aIgnoreCase,aCount);
}
virtual PRInt32 Compare(const nsStr &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
/**
* Compare this to given string; note that we compare full strings here.
* The optional length argument just lets us know how long the given string is.
* If you provide a length, it is compared to length of this string as an
* optimization.
*
* @param aString -- the string to compare to this
* @param aCount -- number of chars to be compared.
* @return TRUE if equal
*/
PRBool Equals(const nsString &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return EqualsWithConversion(aString,aIgnoreCase,aCount);
}
PRBool Equals(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return EqualsWithConversion(aString,aIgnoreCase,aCount);
}
PRBool Equals(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const {
return EqualsWithConversion(aString,aIgnoreCase,aCount);
}
PRBool Equals(/*FIX: const */nsIAtom* anAtom,PRBool aIgnoreCase) const;
PRBool Equals(const PRUnichar* s1, const PRUnichar* s2,PRBool aIgnoreCase=PR_FALSE) const;
PRBool Equals(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
/**
* These methods compare a given string type to this one
* @param aString is the string to be compared to this
@ -776,28 +826,6 @@ public:
PRBool operator>=(const PRUnichar* aString) const;
#endif // !defined(NEW_STRING_APIS)
/**
* Compare this to given string; note that we compare full strings here.
* The optional length argument just lets us know how long the given string is.
* If you provide a length, it is compared to length of this string as an
* optimization.
*
* @param aString -- the string to compare to this
* @param aCount -- number of chars to be compared.
* @return TRUE if equal
*/
PRBool Equals(const nsString &aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool Equals(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool Equals(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool Equals(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 aCount=-1) const;
PRBool Equals(/*FIX: const */nsIAtom* anAtom,PRBool aIgnoreCase) const;
PRBool Equals(const PRUnichar* s1, const PRUnichar* s2,PRBool aIgnoreCase=PR_FALSE) const;
PRBool EqualsIgnoreCase(const nsString& aString) const;
PRBool EqualsIgnoreCase(const char* aString,PRInt32 aCount=-1) const;
PRBool EqualsIgnoreCase(/*FIX: const */nsIAtom *aAtom) const;
PRBool EqualsIgnoreCase(const PRUnichar* s1, const PRUnichar* s2) const;
/**
* Determine if given buffer is plain ascii
*