fixed25049; r=harishd
git-svn-id: svn://10.0.0.236/trunk@60477 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -37,7 +37,6 @@
|
||||
#include <stdio.h> //only used for printf
|
||||
#include "nsCRT.h"
|
||||
#include "nsDeque.h"
|
||||
|
||||
|
||||
//static const char* kCallFindChar = "For better performance, call FindChar() for targets whose length==1.";
|
||||
//static const char* kCallRFindChar = "For better performance, call RFindChar() for targets whose length==1.";
|
||||
@@ -327,7 +326,7 @@ void nsStr::Trim(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool a
|
||||
if(aEliminateLeading) {
|
||||
while(++theIndex<=theMax) {
|
||||
PRUnichar theChar=GetCharAt(aDest,theIndex);
|
||||
PRInt32 thePos=gFindChars[eOneByte](aSet,theSetLen,0,theChar,PR_FALSE);
|
||||
PRInt32 thePos=gFindChars[eOneByte](aSet,theSetLen,0,theChar,PR_FALSE,theSetLen);
|
||||
if(kNotFound==thePos)
|
||||
break;
|
||||
}
|
||||
@@ -344,7 +343,7 @@ void nsStr::Trim(nsStr& aDest,const char* aSet,PRBool aEliminateLeading,PRBool a
|
||||
PRInt32 theNewLen=theIndex;
|
||||
while(--theIndex>0) {
|
||||
PRUnichar theChar=GetCharAt(aDest,theIndex); //read at end now...
|
||||
PRInt32 thePos=gFindChars[eOneByte](aSet,theSetLen,0,theChar,PR_FALSE);
|
||||
PRInt32 thePos=gFindChars[eOneByte](aSet,theSetLen,0,theChar,PR_FALSE,theSetLen);
|
||||
if(kNotFound<thePos)
|
||||
theNewLen=theIndex;
|
||||
else break;
|
||||
@@ -394,61 +393,65 @@ void nsStr::StripChars(nsStr& aDest,const char* aSet){
|
||||
/**
|
||||
* This searches aDest for a given substring
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @update gess 2/04/00: added aCount argument to restrict search
|
||||
* @param aDest string to search
|
||||
* @param aTarget is the substring you're trying to find.
|
||||
* @param aIgnorecase indicates case sensitivity of search
|
||||
* @param anOffset tells us where to start the search
|
||||
* @param aCount tells us how many iterations to make from offset; -1 means the full length of the string
|
||||
* @return index in aDest where member of aSet occurs, or -1 if not found
|
||||
*/
|
||||
PRInt32 nsStr::FindSubstr(const nsStr& aDest,const nsStr& aTarget, PRBool aIgnoreCase,PRInt32 anOffset) {
|
||||
// NS_PRECONDITION(aTarget.mLength!=1,kCallFindChar);
|
||||
PRInt32 nsStr::FindSubstr(const nsStr& aDest,const nsStr& aTarget, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) {
|
||||
PRInt32 theMaxPos = aDest.mLength-aTarget.mLength; //this is the last pos that is feasible for starting the search, with given lengths...
|
||||
|
||||
PRInt32 result=kNotFound;
|
||||
|
||||
if((0<aDest.mLength) && (anOffset<(PRInt32)aDest.mLength)) {
|
||||
PRInt32 theMax=aDest.mLength-aTarget.mLength;
|
||||
PRInt32 index=(0<=anOffset) ? anOffset : 0;
|
||||
|
||||
if((aDest.mLength>=aTarget.mLength) && (aTarget.mLength>0) && (index>=0)){
|
||||
PRInt32 theTargetMax=aTarget.mLength;
|
||||
while(index<=theMax) {
|
||||
PRInt32 theSubIndex=-1;
|
||||
PRBool matches=PR_TRUE;
|
||||
while((++theSubIndex<theTargetMax) && (matches)){
|
||||
PRUnichar theChar=(aIgnoreCase) ? nsCRT::ToLower(GetCharAt(aDest,index+theSubIndex)) : GetCharAt(aDest,index+theSubIndex);
|
||||
PRUnichar theTargetChar=(aIgnoreCase) ? nsCRT::ToLower(GetCharAt(aTarget,theSubIndex)) : GetCharAt(aTarget,theSubIndex);
|
||||
matches=PRBool(theChar==theTargetChar);
|
||||
}
|
||||
if(matches) {
|
||||
result=index;
|
||||
break;
|
||||
}
|
||||
index++;
|
||||
} //while
|
||||
}//if
|
||||
}//if
|
||||
return result;
|
||||
if(0<=theMaxPos) {
|
||||
|
||||
if(anOffset<0)
|
||||
anOffset=0;
|
||||
|
||||
if((0<aDest.mLength) && (anOffset<=theMaxPos) && (aTarget.mLength)) {
|
||||
|
||||
if(aCount<0)
|
||||
aCount = MaxInt(theMaxPos,1);
|
||||
|
||||
if(0<aCount) {
|
||||
|
||||
PRInt32 aDelta= (aDest.mCharSize == eOneByte) ? 1 : 2;
|
||||
const char* root = aDest.mStr;
|
||||
const char* left = root+(anOffset*aDelta);
|
||||
const char* last = left+((aCount-1)*aDelta);
|
||||
const char* max = root+(theMaxPos*aDelta);
|
||||
const char* right = (last<max) ? last : max;
|
||||
|
||||
while(left<=right){
|
||||
PRInt32 cmp=(*gCompare[aDest.mCharSize][aTarget.mCharSize])(left,aTarget.mStr,aTarget.mLength,aIgnoreCase);
|
||||
if(0==cmp) {
|
||||
return (left-root)/aDelta;
|
||||
}
|
||||
left+=aDelta;
|
||||
} //while
|
||||
|
||||
} //if
|
||||
}
|
||||
} //if
|
||||
|
||||
return kNotFound;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This searches aDest for a given character
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @update gess 2/04/00: added aCount argument to restrict search
|
||||
* @param aDest string to search
|
||||
* @param char is the character you're trying to find.
|
||||
* @param aIgnorecase indicates case sensitivity of search
|
||||
* @param anOffset tells us where to start the search
|
||||
* @param aCount tell us how many chars to search from offset
|
||||
* @return index in aDest where member of aSet occurs, or -1 if not found
|
||||
*/
|
||||
PRInt32 nsStr::FindChar(const nsStr& aDest,PRUnichar aChar, PRBool aIgnoreCase,PRInt32 anOffset) {
|
||||
PRInt32 result=kNotFound;
|
||||
if((0<aDest.mLength) && (anOffset<(PRInt32)aDest.mLength)) {
|
||||
PRUint32 index=(0<=anOffset) ? (PRUint32)anOffset : 0;
|
||||
result=gFindChars[aDest.mCharSize](aDest.mStr,aDest.mLength,index,aChar,aIgnoreCase);
|
||||
}
|
||||
return result;
|
||||
PRInt32 nsStr::FindChar(const nsStr& aDest,PRUnichar aChar, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) {
|
||||
return gFindChars[aDest.mCharSize](aDest.mStr,aDest.mLength,anOffset,aChar,aIgnoreCase,aCount);
|
||||
}
|
||||
|
||||
|
||||
@@ -473,7 +476,7 @@ PRInt32 nsStr::FindCharInSet(const nsStr& aDest,const nsStr& aSet,PRBool aIgnore
|
||||
if((0<aDest.mLength) && (0<aSet.mLength)){
|
||||
while(++index<(PRInt32)aDest.mLength) {
|
||||
PRUnichar theChar=GetCharAt(aDest,index);
|
||||
thePos=gFindChars[aSet.mCharSize](aSet.mStr,aSet.mLength,0,theChar,aIgnoreCase);
|
||||
thePos=gFindChars[aSet.mCharSize](aSet.mStr,aSet.mLength,0,theChar,aIgnoreCase,aSet.mLength);
|
||||
if(kNotFound!=thePos)
|
||||
return index;
|
||||
} //while
|
||||
@@ -489,74 +492,66 @@ PRInt32 nsStr::FindCharInSet(const nsStr& aDest,const nsStr& aSet,PRBool aIgnore
|
||||
/**
|
||||
* This searches aDest (in reverse) for a given substring
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @update gess 2/04/00
|
||||
* @param aDest string to search
|
||||
* @param aTarget is the substring you're trying to find.
|
||||
* @param aIgnorecase indicates case sensitivity of search
|
||||
* @param anOffset tells us where to start the search (counting from left)
|
||||
* @param aCount tell us how many iterations to perform from offset
|
||||
* @return index in aDest where member of aSet occurs, or -1 if not found
|
||||
*/
|
||||
PRInt32 nsStr::RFindSubstr(const nsStr& aDest,const nsStr& aTarget, PRBool aIgnoreCase,PRInt32 anOffset) {
|
||||
//NS_PRECONDITION(aTarget.mLength!=1,kCallRFindChar);
|
||||
PRInt32 nsStr::RFindSubstr(const nsStr& aDest,const nsStr& aTarget, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) {
|
||||
if(anOffset<0)
|
||||
anOffset=(PRInt32)aDest.mLength-1;
|
||||
|
||||
PRInt32 result=kNotFound;
|
||||
if(aCount<0)
|
||||
aCount = aDest.mLength;
|
||||
|
||||
if((0<aDest.mLength) && (anOffset<(PRInt32)aDest.mLength)) {
|
||||
PRInt32 index=(0<=anOffset) ? anOffset : aDest.mLength-1;
|
||||
if((0<aDest.mLength) && ((PRUint32)anOffset<aDest.mLength) && (aTarget.mLength)) {
|
||||
|
||||
if(0<aCount) {
|
||||
|
||||
PRInt32 aDelta = (aDest.mCharSize == eOneByte) ? 1 : 2;
|
||||
const char* root = aDest.mStr;
|
||||
const char* destLast = root+((aDest.mLength-1)*aDelta); //pts to last char in aDest (likely null)
|
||||
|
||||
if((aDest.mLength>=aTarget.mLength) && (aTarget.mLength>0) && (index>=0)){
|
||||
const char* rightmost = root+(anOffset*aDelta);
|
||||
const char* min = rightmost-((aCount-1)*aDelta);
|
||||
|
||||
nsStr theCopy;
|
||||
nsStr::Initialize(theCopy,eOneByte);
|
||||
nsStr::Assign(theCopy,aTarget,0,aTarget.mLength);
|
||||
if(aIgnoreCase){
|
||||
nsStr::ChangeCase(theCopy,PR_FALSE); //force to lowercase
|
||||
}
|
||||
|
||||
PRInt32 theTargetMax=theCopy.mLength;
|
||||
while(index>=0) {
|
||||
PRInt32 theSubIndex=-1;
|
||||
PRBool matches=PR_FALSE;
|
||||
if(index+theCopy.mLength<=aDest.mLength) {
|
||||
matches=PR_TRUE;
|
||||
while((++theSubIndex<theTargetMax) && (matches)){
|
||||
PRUnichar theDestChar=(aIgnoreCase) ? nsCRT::ToLower(GetCharAt(aDest,index+theSubIndex)) : GetCharAt(aDest,index+theSubIndex);
|
||||
PRUnichar theTargetChar=GetCharAt(theCopy,theSubIndex);
|
||||
matches=PRBool(theDestChar==theTargetChar);
|
||||
} //while
|
||||
const char* leftmost = (min<root) ? root: min;
|
||||
|
||||
while(leftmost<=rightmost) {
|
||||
if(aTarget.mLength<=PRUint32(destLast-rightmost)) {
|
||||
PRInt32 result=(*gCompare[aDest.mCharSize][aTarget.mCharSize])(rightmost,aTarget.mStr,aTarget.mLength,aIgnoreCase);
|
||||
if(0==result) {
|
||||
return (rightmost-root)/aDelta;
|
||||
}
|
||||
} //if
|
||||
if(matches) {
|
||||
result=index;
|
||||
break;
|
||||
}
|
||||
index--;
|
||||
rightmost-=aDelta;
|
||||
} //while
|
||||
nsStr::Destroy(theCopy);
|
||||
}//if
|
||||
}//if
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return kNotFound;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This searches aDest (in reverse) for a given character
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @update gess 2/04/00
|
||||
* @param aDest string to search
|
||||
* @param char is the character you're trying to find.
|
||||
* @param aIgnorecase indicates case sensitivity of search
|
||||
* @param anOffset tells us where to start the search
|
||||
* @param anOffset tells us where to start the search; -1 means start at very end (mLength)
|
||||
* @param aCount tell us how many iterations to perform from offset; -1 means use full length.
|
||||
* @return index in aDest where member of aSet occurs, or -1 if not found
|
||||
*/
|
||||
PRInt32 nsStr::RFindChar(const nsStr& aDest,PRUnichar aChar, PRBool aIgnoreCase,PRInt32 anOffset) {
|
||||
PRInt32 result=kNotFound;
|
||||
if((0<aDest.mLength) && (anOffset<(PRInt32)aDest.mLength)) {
|
||||
PRUint32 index=(0<=anOffset) ? anOffset : aDest.mLength-1;
|
||||
result=gRFindChars[aDest.mCharSize](aDest.mStr,aDest.mLength,index,aChar,aIgnoreCase);
|
||||
}
|
||||
return result;
|
||||
PRInt32 nsStr::RFindChar(const nsStr& aDest,PRUnichar aChar, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) {
|
||||
return gRFindChars[aDest.mCharSize](aDest.mStr,aDest.mLength,anOffset,aChar,aIgnoreCase,aCount);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This searches aDest (in reverese) for a character found in aSet.
|
||||
*
|
||||
@@ -578,7 +573,7 @@ PRInt32 nsStr::RFindCharInSet(const nsStr& aDest,const nsStr& aSet,PRBool aIgnor
|
||||
if(0<aDest.mLength) {
|
||||
while(--index>=0) {
|
||||
PRUnichar theChar=GetCharAt(aDest,index);
|
||||
thePos=gFindChars[aSet.mCharSize](aSet.mStr,aSet.mLength,0,theChar,aIgnoreCase);
|
||||
thePos=gFindChars[aSet.mCharSize](aSet.mStr,aSet.mLength,0,theChar,aIgnoreCase,aSet.mLength);
|
||||
if(kNotFound!=thePos)
|
||||
return index;
|
||||
} //while
|
||||
|
||||
@@ -223,8 +223,6 @@ public:
|
||||
|
||||
struct NS_COM nsStr {
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
nsStr() {
|
||||
MOZ_COUNT_CTOR(nsStr);
|
||||
}
|
||||
@@ -402,12 +400,12 @@ struct NS_COM nsStr {
|
||||
* @param anOffset tells us where in the dest string to start searching
|
||||
* @return the index of the source (substr) in dest, or -1 (kNotFound) if not found.
|
||||
*/
|
||||
static PRInt32 FindSubstr(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset);
|
||||
static PRInt32 FindChar(const nsStr& aDest,PRUnichar aChar, PRBool aIgnoreCase,PRInt32 anOffset);
|
||||
static PRInt32 FindSubstr(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount);
|
||||
static PRInt32 FindChar(const nsStr& aDest,PRUnichar aChar, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount);
|
||||
static PRInt32 FindCharInSet(const nsStr& aDest,const nsStr& aSet,PRBool aIgnoreCase,PRInt32 anOffset);
|
||||
|
||||
static PRInt32 RFindSubstr(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset);
|
||||
static PRInt32 RFindChar(const nsStr& aDest,PRUnichar aChar, PRBool aIgnoreCase,PRInt32 anOffset);
|
||||
static PRInt32 RFindSubstr(const nsStr& aDest,const nsStr& aSource, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount);
|
||||
static PRInt32 RFindChar(const nsStr& aDest,PRUnichar aChar, PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount);
|
||||
static PRInt32 RFindCharInSet(const nsStr& aDest,const nsStr& aSet,PRBool aIgnoreCase,PRInt32 anOffset);
|
||||
|
||||
static void Overwrite(nsStr& aDest,const nsStr& aSource,PRInt32 anOffset);
|
||||
@@ -445,6 +443,9 @@ private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/**************************************************************
|
||||
A couple of tiny helper methods used in the string classes.
|
||||
**************************************************************/
|
||||
@@ -485,6 +486,7 @@ inline PRUnichar GetCharAt(const nsStr& aDest,PRUint32 anIndex){
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#ifdef NS_STR_STATS
|
||||
|
||||
class nsStringInfo {
|
||||
|
||||
@@ -342,10 +342,10 @@ void nsCString::ToUpperCase(nsCString& aString) const {
|
||||
*/
|
||||
nsCString& nsCString::StripChar(PRUnichar aChar,PRInt32 anOffset){
|
||||
|
||||
anOffset=nsStr::FindChar(*this,aChar,PR_FALSE,anOffset);
|
||||
anOffset=nsStr::FindChar(*this,aChar,PR_FALSE,anOffset,mLength);
|
||||
while(kNotFound<anOffset) {
|
||||
nsStr::Delete(*this,anOffset,1);
|
||||
anOffset=nsStr::FindChar(*this,aChar,PR_FALSE,anOffset);
|
||||
anOffset=nsStr::FindChar(*this,aChar,PR_FALSE,anOffset,mLength);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@@ -457,7 +457,7 @@ nsCString& nsCString::ReplaceSubstring(const nsCString& aTarget,const nsCString&
|
||||
}
|
||||
else {
|
||||
PRInt32 theIndex=0;
|
||||
while(kNotFound!=(theIndex=nsStr::FindSubstr(*this,aTarget,PR_FALSE,theIndex))) {
|
||||
while(kNotFound!=(theIndex=nsStr::FindSubstr(*this,aTarget,PR_FALSE,theIndex,mLength))) {
|
||||
if(aNewValue.mLength<aTarget.mLength) {
|
||||
//Since target is longer than newValue, we should delete a few chars first, then overwrite.
|
||||
PRInt32 theDelLen=aTarget.mLength-aNewValue.mLength;
|
||||
@@ -504,9 +504,34 @@ PRInt32 nsCString::CountChar(PRUnichar aChar) {
|
||||
* both ends
|
||||
* @return this
|
||||
*/
|
||||
nsCString& nsCString::Trim(const char* aTrimSet, PRBool aEliminateLeading,PRBool aEliminateTrailing){
|
||||
nsCString& nsCString::Trim(const char* aTrimSet, PRBool aEliminateLeading,PRBool aEliminateTrailing,PRBool aIgnoreQuotes){
|
||||
|
||||
if(aTrimSet){
|
||||
|
||||
PRUnichar theFirstChar=0;
|
||||
PRUnichar theLastChar=0;
|
||||
PRBool theQuotesAreNeeded=PR_FALSE;
|
||||
|
||||
if(aIgnoreQuotes && (mLength>2)) {
|
||||
theFirstChar=First();
|
||||
theLastChar=Last();
|
||||
if(theFirstChar==theLastChar) {
|
||||
if(('\''==theFirstChar) || ('"'==theFirstChar)) {
|
||||
Cut(0,1);
|
||||
Truncate(mLength-1);
|
||||
theQuotesAreNeeded=PR_TRUE;
|
||||
}
|
||||
else theFirstChar=0;
|
||||
}
|
||||
}
|
||||
|
||||
nsStr::Trim(*this,aTrimSet,aEliminateLeading,aEliminateTrailing);
|
||||
|
||||
if(aIgnoreQuotes && theQuotesAreNeeded) {
|
||||
Insert(theFirstChar,0);
|
||||
Append(theLastChar);
|
||||
}
|
||||
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@@ -644,7 +669,7 @@ float nsCString::ToFloat(PRInt32* aErrorCode) const {
|
||||
* @return int rep of string value
|
||||
*/
|
||||
PRInt32 _ToInteger(nsCString& aString,PRInt32* anErrorCode,PRUint32 aRadix) {
|
||||
|
||||
|
||||
//copy chars to local buffer -- step down from 2 bytes to 1 if necessary...
|
||||
PRInt32 result=0;
|
||||
|
||||
@@ -712,10 +737,11 @@ PRInt32 _ToInteger(nsCString& aString,PRInt32* anErrorCode,PRUint32 aRadix) {
|
||||
*/
|
||||
static PRInt32 GetNumericSubstring(nsCString& aString,PRUint32& aRadix) {
|
||||
|
||||
const char* cp=aString.GetBuffer();
|
||||
const char* cp=aString.mStr;
|
||||
PRInt32 result=NS_ERROR_ILLEGAL_VALUE;
|
||||
if(cp) {
|
||||
|
||||
aRadix = (kAutoDetect==aRadix) ? 10 : aRadix;
|
||||
|
||||
//begin by skipping over leading chars that shouldn't be part of the number...
|
||||
|
||||
@@ -725,16 +751,19 @@ static PRInt32 GetNumericSubstring(nsCString& aString,PRUint32& aRadix) {
|
||||
|
||||
while(!done){
|
||||
switch(*cp) {
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
|
||||
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
|
||||
aRadix=16;
|
||||
done=PR_TRUE;
|
||||
break;
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
case '-': case '+': case '#':
|
||||
done=PR_TRUE;
|
||||
break;
|
||||
default:
|
||||
cp++;
|
||||
done=cp<endcp;
|
||||
done=(cp==endcp);
|
||||
break;
|
||||
} //switch
|
||||
}
|
||||
@@ -794,7 +823,8 @@ static PRInt32 GetNumericSubstring(nsCString& aString,PRUint32& aRadix) {
|
||||
PRUint32 nsCString::DetermineRadix(void) {
|
||||
PRUint32 result=kRadixUnknown;
|
||||
if(0<mLength) {
|
||||
nsCAutoString theString(*this);
|
||||
//nsCAutoString theString(*this);
|
||||
nsSubsumeCStr theString(mStr,mLength);
|
||||
if(NS_OK!=GetNumericSubstring(theString,result))
|
||||
result=kRadixUnknown;
|
||||
}
|
||||
@@ -811,23 +841,127 @@ PRUint32 nsCString::DetermineRadix(void) {
|
||||
* @return int rep of string value
|
||||
*/
|
||||
PRInt32 nsCString::ToInteger(PRInt32* anErrorCode,PRUint32 aRadix) const {
|
||||
|
||||
#if 1
|
||||
//copy chars to local buffer -- step down from 2 bytes to 1 if necessary...
|
||||
PRInt32 result=0;
|
||||
nsCAutoString theString(*this);
|
||||
PRUint32 theRadix=aRadix;
|
||||
|
||||
*anErrorCode=GetNumericSubstring(theString,theRadix); //we actually don't use this radix; use given radix instead
|
||||
if(0<mLength) {
|
||||
|
||||
if(NS_OK==*anErrorCode){
|
||||
if(kAutoDetect==aRadix)
|
||||
aRadix=theRadix;
|
||||
if((kRadix10==aRadix) || (kRadix16==aRadix))
|
||||
result=_ToInteger(theString,anErrorCode,aRadix); //note we use the given radix, not the computed one.
|
||||
else *anErrorCode=NS_ERROR_ILLEGAL_VALUE;
|
||||
nsCAutoString theString(mStr,mLength);
|
||||
PRUint32 theRadix=aRadix;
|
||||
|
||||
*anErrorCode=GetNumericSubstring(theString,theRadix); //we actually don't use this radix; use given radix instead
|
||||
|
||||
if(NS_OK==*anErrorCode){
|
||||
if(kAutoDetect==aRadix)
|
||||
aRadix=theRadix;
|
||||
if((kRadix10==aRadix) || (kRadix16==aRadix))
|
||||
result=_ToInteger(theString,anErrorCode,aRadix); //note we use the given radix, not the computed one.
|
||||
else *anErrorCode=NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
#else
|
||||
char* cp=aString.mStr;
|
||||
PRInt32 theRadix = (kAutoDetect==aRadix) ? 10 : aRadix;
|
||||
PRInt32 result=0;
|
||||
PRBool negate=PR_FALSE;
|
||||
char theChar=0;
|
||||
|
||||
*anErrorCode=NS_ERROR_ILLEGAL_VALUE;
|
||||
|
||||
if(cp) {
|
||||
|
||||
//begin by skipping over leading chars that shouldn't be part of the number...
|
||||
|
||||
char* endcp=cp+aString.mLength;
|
||||
PRBool done=PR_FALSE;
|
||||
|
||||
while((cp<endcp) && (!done)){
|
||||
theChar=*cp;
|
||||
switch(*cp++) {
|
||||
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
|
||||
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
|
||||
theRadix=16;
|
||||
done=PR_TRUE;
|
||||
break;
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
done=PR_TRUE;
|
||||
break;
|
||||
case '-':
|
||||
negate=PR_TRUE; //fall through...
|
||||
break;
|
||||
case 'X': case 'x':
|
||||
theRadix=16;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
} //switch
|
||||
}
|
||||
|
||||
//if you don't have any valid chars, return 0, but set the error;
|
||||
if(cp<=endcp) {
|
||||
|
||||
*anErrorCode = NS_OK;
|
||||
|
||||
//now iterate the numeric chars and build our result
|
||||
char* first=--cp; //in case we have to back up.
|
||||
|
||||
while(cp<=endcp){
|
||||
theChar=*cp++;
|
||||
if(('0'<=theChar) && (theChar<='9')){
|
||||
result = (theRadix * result) + (theChar-'0');
|
||||
}
|
||||
else if((theChar>='A') && (theChar<='F')) {
|
||||
if(10==theRadix) {
|
||||
if(kAutoDetect==aRadix){
|
||||
theRadix=16;
|
||||
cp=first; //backup
|
||||
result=0;
|
||||
}
|
||||
else {
|
||||
*anErrorCode=NS_ERROR_ILLEGAL_VALUE;
|
||||
result=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = (theRadix * result) + ((theChar-'A')+10);
|
||||
}
|
||||
}
|
||||
else if((theChar>='a') && (theChar<='f')) {
|
||||
if(10==theRadix) {
|
||||
if(kAutoDetect==aRadix){
|
||||
theRadix=16;
|
||||
cp=first; //backup
|
||||
result=0;
|
||||
}
|
||||
else {
|
||||
*anErrorCode=NS_ERROR_ILLEGAL_VALUE;
|
||||
result=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = (theRadix * result) + ((theChar-'a')+10);
|
||||
}
|
||||
}
|
||||
else if(('X'==theChar) || ('x'==theChar) || ('#'==theChar) || ('+'==theChar)) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
//we've encountered a char that's not a legal number or sign
|
||||
break;
|
||||
}
|
||||
} //while
|
||||
if(negate)
|
||||
result=-result;
|
||||
} //if
|
||||
}
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
@@ -894,7 +1028,7 @@ nsCString& nsCString::Assign(const PRUnichar* aString,PRInt32 aCount) {
|
||||
// If this assertion fires, the caller is probably lying about the length of
|
||||
// the passed-in string. File a bug on the caller.
|
||||
#ifdef NS_DEBUG
|
||||
PRInt32 len=nsStr::FindChar(temp,0,PR_FALSE,0);
|
||||
PRInt32 len=nsStr::FindChar(temp,0,PR_FALSE,0,temp.mLength);
|
||||
NS_WARN_IF_FALSE(kNotFound==len,"possible embedded null in Assign(PRUnichar*)");
|
||||
#endif
|
||||
|
||||
@@ -1183,7 +1317,7 @@ nsCString& nsCString::Insert(const char* aCString,PRUint32 anOffset,PRInt32 aCou
|
||||
// If this assertion fires, the caller is probably lying about the length of
|
||||
// the passed-in string. File a bug on the caller.
|
||||
#ifdef NS_DEBUG
|
||||
PRInt32 len=nsStr::FindChar(temp,0,PR_FALSE,0);
|
||||
PRInt32 len=nsStr::FindChar(temp,0,PR_FALSE,0,temp.mLength);
|
||||
NS_WARN_IF_FALSE(kNotFound==len,"possible embedded null in Insert(char*)");
|
||||
#endif
|
||||
|
||||
@@ -1287,18 +1421,19 @@ PRInt32 nsCString::BinarySearch(PRUnichar aChar) const{
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aCString - substr to be found
|
||||
* @param aIgnoreCase
|
||||
* @param anOffset
|
||||
* @param aIgnoreCase tells us whether or not to do caseless compare
|
||||
* @param anOffset tells us where in this string to start searching
|
||||
* @param aCount tells us how many iterations to make starting at the given offset
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 nsCString::Find(const char* aCString,PRBool aIgnoreCase,PRInt32 anOffset) const{
|
||||
PRInt32 nsCString::Find(const char* aCString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{
|
||||
PRInt32 result=kNotFound;
|
||||
if(aCString) {
|
||||
nsStr temp;
|
||||
nsStr::Initialize(temp,eOneByte);
|
||||
temp.mLength=nsCRT::strlen(aCString);
|
||||
temp.mLength = nsCRT::strlen(aCString);
|
||||
temp.mStr=(char*)aCString;
|
||||
result=nsStr::FindSubstr(*this,temp,aIgnoreCase,anOffset);
|
||||
result=nsStr::FindSubstr(*this,temp,aIgnoreCase,anOffset,aCount);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -1307,21 +1442,22 @@ PRInt32 nsCString::Find(const char* aCString,PRBool aIgnoreCase,PRInt32 anOffset
|
||||
* Search for given buffer within this string
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aString unichar* to be found
|
||||
* @param aIgnoreCase
|
||||
* @param anOffset
|
||||
* @param aString - substr to be found
|
||||
* @param aIgnoreCase tells us whether or not to do caseless compare
|
||||
* @param anOffset tells us where in this string to start searching
|
||||
* @param aCount tells us how many iterations to make starting at the given offset
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 nsCString::Find(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 anOffset) const{
|
||||
PRInt32 nsCString::Find(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{
|
||||
NS_ASSERTION(0!=aString,kNullPointerError);
|
||||
|
||||
PRInt32 result=kNotFound;
|
||||
if(aString) {
|
||||
nsStr temp;
|
||||
nsStr::Initialize(temp,eTwoByte);
|
||||
temp.mLength=nsCRT::strlen(aString);
|
||||
temp.mLength = nsCRT::strlen(aString);
|
||||
temp.mUStr=(PRUnichar*)aString;
|
||||
result=nsStr::FindSubstr(*this,temp,aIgnoreCase,anOffset);
|
||||
result=nsStr::FindSubstr(*this,temp,aIgnoreCase,anOffset,aCount);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -1330,28 +1466,30 @@ PRInt32 nsCString::Find(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 anOf
|
||||
* Search for given string within this string
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aSTring -- buffer to be found
|
||||
* @param aIgnoreCase
|
||||
* @param anOffset
|
||||
* @param aString - substr to be found
|
||||
* @param aIgnoreCase tells us whether or not to do caseless compare
|
||||
* @param anOffset tells us where in this string to start searching
|
||||
* @param aCount tells us how many iterations to make starting at the given offset
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 nsCString::Find(const nsStr& aString,PRBool aIgnoreCase,PRInt32 anOffset) const{
|
||||
PRInt32 result=nsStr::FindSubstr(*this,aString,aIgnoreCase,anOffset);
|
||||
PRInt32 nsCString::Find(const nsStr& aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{
|
||||
PRInt32 result=nsStr::FindSubstr(*this,aString,aIgnoreCase,anOffset,aCount);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Search for a given char, starting at given offset
|
||||
* This searches this string for a given character
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aChar the unichar to be sought
|
||||
* @param aIgnoreCase
|
||||
* @param anOffset
|
||||
* @return offset of found char, or -1 (kNotFound)
|
||||
* @update gess 2/04/00
|
||||
* @param char is the character you're trying to find.
|
||||
* @param aIgnorecase indicates case sensitivity of search
|
||||
* @param anOffset tells us where to start the search; -1 means start at 0.
|
||||
* @param aCount tell us how many chars to search from offset; -1 means use full length.
|
||||
* @return index in aDest where member of aSet occurs, or -1 if not found
|
||||
*/
|
||||
PRInt32 nsCString::FindChar(PRUnichar aChar,PRBool aIgnoreCase,PRInt32 anOffset) const{
|
||||
PRInt32 result=nsStr::FindChar(*this,aChar,aIgnoreCase,anOffset);
|
||||
PRInt32 nsCString::FindChar(PRUnichar aChar,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{
|
||||
PRInt32 result=nsStr::FindChar(*this,aChar,aIgnoreCase,anOffset,aCount);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1416,30 +1554,32 @@ PRInt32 nsCString::FindCharInSet(const nsStr& aSet,PRInt32 anOffset) const{
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse search for substring
|
||||
* Reverse search for given string within this string
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aString
|
||||
* @param aIgnoreCase
|
||||
* @param anOffset - tells us where to begin the search
|
||||
* @return offset of substring or -1
|
||||
* @param aString - substr to be found
|
||||
* @param aIgnoreCase tells us whether or not to do caseless compare
|
||||
* @param anOffset tells us where in this string to start searching
|
||||
* @param aCount tells us how many iterations to make starting at the given offset
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 nsCString::RFind(const nsStr& aString,PRBool aIgnoreCase,PRInt32 anOffset) const{
|
||||
PRInt32 result=nsStr::RFindSubstr(*this,aString,aIgnoreCase,anOffset);
|
||||
PRInt32 nsCString::RFind(const nsStr& aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{
|
||||
PRInt32 result=nsStr::RFindSubstr(*this,aString,aIgnoreCase,anOffset,aCount);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse search for substring
|
||||
* Reverse search for given string within this string
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aString
|
||||
* @param aIgnoreCase
|
||||
* @param anOffset - tells us where to begin the search
|
||||
* @return offset of substring or -1
|
||||
* @param aString - substr to be found
|
||||
* @param aIgnoreCase tells us whether or not to do caseless compare
|
||||
* @param anOffset tells us where in this string to start searching
|
||||
* @param aCount tells us how many iterations to make starting at the given offset
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 nsCString::RFind(const char* aString,PRBool aIgnoreCase,PRInt32 anOffset) const{
|
||||
PRInt32 nsCString::RFind(const char* aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{
|
||||
NS_ASSERTION(0!=aString,kNullPointerError);
|
||||
|
||||
PRInt32 result=kNotFound;
|
||||
@@ -1448,22 +1588,23 @@ PRInt32 nsCString::RFind(const char* aString,PRBool aIgnoreCase,PRInt32 anOffset
|
||||
nsStr::Initialize(temp,eOneByte);
|
||||
temp.mLength=nsCRT::strlen(aString);
|
||||
temp.mStr=(char*)aString;
|
||||
result=nsStr::RFindSubstr(*this,temp,aIgnoreCase,anOffset);
|
||||
result=nsStr::RFindSubstr(*this,temp,aIgnoreCase,anOffset,aCount);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse search for char
|
||||
* This reverse searches this string for a given character
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aChar
|
||||
* @param aIgnoreCase
|
||||
* @param anOffset - tells us where to begin the search
|
||||
* @return offset of substring or -1
|
||||
* @update gess 2/04/00
|
||||
* @param char is the character you're trying to find.
|
||||
* @param aIgnorecase indicates case sensitivity of search
|
||||
* @param anOffset tells us where to start the search; -1 means start at 0.
|
||||
* @param aCount tell us how many chars to search from offset; -1 means use full length.
|
||||
* @return index in aDest where member of aSet occurs, or -1 if not found
|
||||
*/
|
||||
PRInt32 nsCString::RFindChar(PRUnichar aChar,PRBool aIgnoreCase,PRInt32 anOffset) const{
|
||||
PRInt32 result=nsStr::RFindChar(*this,aChar,aIgnoreCase,anOffset);
|
||||
PRInt32 nsCString::RFindChar(PRUnichar aChar,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{
|
||||
PRInt32 result=nsStr::RFindChar(*this,aChar,aIgnoreCase,anOffset,aCount);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -270,9 +270,12 @@ public:
|
||||
*
|
||||
* @param aTrimSet -- contains chars to be trimmed from
|
||||
* both ends
|
||||
* @param aEliminateLeading
|
||||
* @param aEliminateTrailing
|
||||
* @param aIgnoreQuotes
|
||||
* @return this
|
||||
*/
|
||||
nsCString& Trim(const char* aSet,PRBool aEliminateLeading=PR_TRUE,PRBool aEliminateTrailing=PR_TRUE);
|
||||
nsCString& Trim(const char* aSet,PRBool aEliminateLeading=PR_TRUE,PRBool aEliminateTrailing=PR_TRUE,PRBool aIgnoreQuotes=PR_FALSE);
|
||||
|
||||
/**
|
||||
* This method strips whitespace from string.
|
||||
@@ -533,11 +536,12 @@ public:
|
||||
* @param aString is substring to be sought in this
|
||||
* @param aIgnoreCase selects case sensitivity
|
||||
* @param anOffset tells us where in this strig to start searching
|
||||
* @param aCount tells us how many iterations to make starting at the given offset
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 Find(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 Find(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 Find(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 Find(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1,PRInt32 aCount=-1) const;
|
||||
PRInt32 Find(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1,PRInt32 aCount=-1) const;
|
||||
PRInt32 Find(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1,PRInt32 aCount=-1) const;
|
||||
|
||||
/**
|
||||
* Search for given char within this string
|
||||
@@ -545,9 +549,10 @@ public:
|
||||
* @param aString is substring to be sought in this
|
||||
* @param anOffset tells us where in this strig to start searching
|
||||
* @param aIgnoreCase selects case sensitivity
|
||||
* @param aCount tells us how many iterations to make starting at the given offset
|
||||
* @return find pos in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 FindChar(PRUnichar aChar,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 FindChar(PRUnichar aChar,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1,PRInt32 aCount=-1) const;
|
||||
|
||||
/**
|
||||
* This method searches this string for the first character
|
||||
@@ -565,11 +570,12 @@ public:
|
||||
* This methods scans the string backwards, looking for the given string
|
||||
* @param aString is substring to be sought in this
|
||||
* @param aIgnoreCase tells us whether or not to do caseless compare
|
||||
* @param aCount tells us how many iterations to make starting at the given offset
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 RFind(const char* aCString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 RFind(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 RFind(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 RFind(const char* aCString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1,PRInt32 aCount=-1) const;
|
||||
PRInt32 RFind(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1,PRInt32 aCount=-1) const;
|
||||
PRInt32 RFind(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1,PRInt32 aCount=-1) const;
|
||||
|
||||
|
||||
/**
|
||||
@@ -580,7 +586,7 @@ public:
|
||||
* @param aIgnoreCase selects case sensitivity
|
||||
* @return find pos in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 RFindChar(PRUnichar aChar,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 RFindChar(PRUnichar aChar,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1,PRInt32 aCount=-1) const;
|
||||
|
||||
/**
|
||||
* This method searches this string for the last character
|
||||
|
||||
@@ -403,10 +403,10 @@ void nsString::ToUpperCase(nsString& aString) const {
|
||||
*/
|
||||
nsString& nsString::StripChar(PRUnichar aChar,PRInt32 anOffset){
|
||||
|
||||
anOffset=nsStr::FindChar(*this,aChar,PR_FALSE,anOffset);
|
||||
anOffset=nsStr::FindChar(*this,aChar,PR_FALSE,anOffset,mLength);
|
||||
while(kNotFound<anOffset) {
|
||||
nsStr::Delete(*this,anOffset,1);
|
||||
anOffset=nsStr::FindChar(*this,aChar,PR_FALSE,anOffset);
|
||||
anOffset=nsStr::FindChar(*this,aChar,PR_FALSE,anOffset,mLength);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@@ -528,7 +528,7 @@ nsString& nsString::ReplaceSubstring(const nsString& aTarget,const nsString& aNe
|
||||
}
|
||||
else {
|
||||
PRInt32 theIndex=0;
|
||||
while(kNotFound!=(theIndex=nsStr::FindSubstr(*this,aTarget,PR_FALSE,theIndex))) {
|
||||
while(kNotFound!=(theIndex=nsStr::FindSubstr(*this,aTarget,PR_FALSE,theIndex,mLength))) {
|
||||
if(aNewValue.mLength<aTarget.mLength) {
|
||||
//Since target is longer than newValue, we should delete a few chars first, then overwrite.
|
||||
PRInt32 theDelLen=aTarget.mLength-aNewValue.mLength;
|
||||
@@ -575,11 +575,35 @@ PRInt32 nsString::CountChar(PRUnichar aChar) {
|
||||
* both ends
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Trim(const char* aTrimSet, PRBool aEliminateLeading,PRBool aEliminateTrailing){
|
||||
if(aTrimSet){
|
||||
nsStr::Trim(*this,aTrimSet,aEliminateLeading,aEliminateTrailing);
|
||||
}
|
||||
nsString& nsString::Trim(const char* aTrimSet, PRBool aEliminateLeading,PRBool aEliminateTrailing,PRBool aIgnoreQuotes){
|
||||
|
||||
if(aTrimSet){
|
||||
|
||||
PRUnichar theFirstChar=0;
|
||||
PRUnichar theLastChar=0;
|
||||
PRBool theQuotesAreNeeded=PR_FALSE;
|
||||
|
||||
if(aIgnoreQuotes && (mLength>2)) {
|
||||
theFirstChar=First();
|
||||
theLastChar=Last();
|
||||
if(theFirstChar==theLastChar) {
|
||||
if(('\''==theFirstChar) || ('"'==theFirstChar)) {
|
||||
Cut(0,1);
|
||||
Truncate(mLength-1);
|
||||
theQuotesAreNeeded=PR_TRUE;
|
||||
}
|
||||
else theFirstChar=0;
|
||||
}
|
||||
}
|
||||
|
||||
nsStr::Trim(*this,aTrimSet,aEliminateLeading,aEliminateTrailing);
|
||||
|
||||
if(aIgnoreQuotes && theQuotesAreNeeded) {
|
||||
Insert(theFirstChar,0);
|
||||
Append(theLastChar);
|
||||
}
|
||||
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -872,10 +896,11 @@ static PRInt32 _ToInteger(nsCString& aString,PRInt32* anErrorCode,PRUint32 aRadi
|
||||
*/
|
||||
static PRInt32 GetNumericSubstring(nsCString& aString,PRUint32& aRadix) {
|
||||
|
||||
const char* cp=aString.GetBuffer();
|
||||
const char* cp=aString.mStr;
|
||||
PRInt32 result=NS_ERROR_ILLEGAL_VALUE;
|
||||
if(cp) {
|
||||
|
||||
aRadix = (kAutoDetect==aRadix) ? 10 : aRadix;
|
||||
|
||||
//begin by skipping over leading chars that shouldn't be part of the number...
|
||||
|
||||
@@ -885,16 +910,19 @@ static PRInt32 GetNumericSubstring(nsCString& aString,PRUint32& aRadix) {
|
||||
|
||||
while(!done){
|
||||
switch(*cp) {
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
|
||||
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
|
||||
aRadix=16;
|
||||
done=PR_TRUE;
|
||||
break;
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
case '-': case '+': case '#':
|
||||
done=PR_TRUE;
|
||||
break;
|
||||
default:
|
||||
cp++;
|
||||
done=cp<endcp;
|
||||
done=(cp==endcp);
|
||||
break;
|
||||
} //switch
|
||||
}
|
||||
@@ -971,22 +999,127 @@ PRUint32 nsString::DetermineRadix(void) {
|
||||
* @return int rep of string value
|
||||
*/
|
||||
PRInt32 nsString::ToInteger(PRInt32* anErrorCode,PRUint32 aRadix) const {
|
||||
|
||||
#if 1
|
||||
//copy chars to local buffer -- step down from 2 bytes to 1 if necessary...
|
||||
PRInt32 result=0;
|
||||
nsCAutoString theString(*this);
|
||||
PRUint32 theRadix=aRadix;
|
||||
|
||||
*anErrorCode=GetNumericSubstring(theString,theRadix); //we actually don't use this radix; use given radix instead
|
||||
if(0<mLength) {
|
||||
|
||||
if(NS_OK==*anErrorCode){
|
||||
if(kAutoDetect==aRadix)
|
||||
aRadix=theRadix;
|
||||
if((kRadix10==aRadix) || (kRadix16==aRadix))
|
||||
result=_ToInteger(theString,anErrorCode,aRadix); //note we use the given radix, not the computed one.
|
||||
else *anErrorCode=NS_ERROR_ILLEGAL_VALUE;
|
||||
nsCAutoString theString(mUStr,mLength);
|
||||
PRUint32 theRadix=aRadix;
|
||||
|
||||
*anErrorCode=GetNumericSubstring(theString,theRadix); //we actually don't use this radix; use given radix instead
|
||||
|
||||
if(NS_OK==*anErrorCode){
|
||||
if(kAutoDetect==aRadix)
|
||||
aRadix=theRadix;
|
||||
if((kRadix10==aRadix) || (kRadix16==aRadix))
|
||||
result=_ToInteger(theString,anErrorCode,aRadix); //note we use the given radix, not the computed one.
|
||||
else *anErrorCode=NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
#else
|
||||
PRUnichar* cp=aString.mUStr;
|
||||
PRInt32 theRadix = (kAutoDetect==aRadix) ? 10 : aRadix;
|
||||
PRInt32 result=0;
|
||||
PRBool negate=PR_FALSE;
|
||||
PRUnichar theChar=0;
|
||||
|
||||
*anErrorCode=NS_ERROR_ILLEGAL_VALUE;
|
||||
|
||||
if(cp) {
|
||||
|
||||
//begin by skipping over leading chars that shouldn't be part of the number...
|
||||
|
||||
PRUnichar* endcp=cp+aString.mLength;
|
||||
PRBool done=PR_FALSE;
|
||||
|
||||
while((cp<endcp) && (!done)){
|
||||
theChar=*cp;
|
||||
switch(*cp++) {
|
||||
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
|
||||
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
|
||||
theRadix=16;
|
||||
done=PR_TRUE;
|
||||
break;
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
done=PR_TRUE;
|
||||
break;
|
||||
case '-':
|
||||
negate=PR_TRUE; //fall through...
|
||||
break;
|
||||
case 'X': case 'x':
|
||||
theRadix=16;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
} //switch
|
||||
}
|
||||
|
||||
//if you don't have any valid chars, return 0, but set the error;
|
||||
if(cp<=endcp) {
|
||||
|
||||
*anErrorCode = NS_OK;
|
||||
|
||||
//now iterate the numeric chars and build our result
|
||||
PRUnichar* first=--cp; //in case we have to back up.
|
||||
|
||||
while(cp<=endcp){
|
||||
theChar=*cp++;
|
||||
if(('0'<=theChar) && (theChar<='9')){
|
||||
result = (theRadix * result) + (theChar-'0');
|
||||
}
|
||||
else if((theChar>='A') && (theChar<='F')) {
|
||||
if(10==theRadix) {
|
||||
if(kAutoDetect==aRadix){
|
||||
theRadix=16;
|
||||
cp=first; //backup
|
||||
result=0;
|
||||
}
|
||||
else {
|
||||
*anErrorCode=NS_ERROR_ILLEGAL_VALUE;
|
||||
result=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = (theRadix * result) + ((theChar-'A')+10);
|
||||
}
|
||||
}
|
||||
else if((theChar>='a') && (theChar<='f')) {
|
||||
if(10==theRadix) {
|
||||
if(kAutoDetect==aRadix){
|
||||
theRadix=16;
|
||||
cp=first; //backup
|
||||
result=0;
|
||||
}
|
||||
else {
|
||||
*anErrorCode=NS_ERROR_ILLEGAL_VALUE;
|
||||
result=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = (theRadix * result) + ((theChar-'a')+10);
|
||||
}
|
||||
}
|
||||
else if(('X'==theChar) || ('x'==theChar) || ('#'==theChar) || ('+'==theChar)) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
//we've encountered a char that's not a legal number or sign
|
||||
break;
|
||||
}
|
||||
} //while
|
||||
if(negate)
|
||||
result=-result;
|
||||
} //if
|
||||
}
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
@@ -1146,7 +1279,7 @@ nsString& nsString::Append(const char* aCString,PRInt32 aCount) {
|
||||
// the passed-in string. File a bug on the caller.
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
PRInt32 len=nsStr::FindChar(temp,0,PR_FALSE,0);
|
||||
PRInt32 len=nsStr::FindChar(temp,0,PR_FALSE,0,temp.mLength);
|
||||
NS_WARN_IF_FALSE(kNotFound==len,"possible embedded null in append(char*)");
|
||||
#endif
|
||||
|
||||
@@ -1180,7 +1313,7 @@ nsString& nsString::Append(const PRUnichar* aString,PRInt32 aCount) {
|
||||
// If this assertion fires, the caller is probably lying about the length of
|
||||
// the passed-in string. File a bug on the caller.
|
||||
#ifdef NS_DEBUG
|
||||
PRInt32 len=nsStr::FindChar(temp,0,PR_FALSE,0);
|
||||
PRInt32 len=nsStr::FindChar(temp,0,PR_FALSE,0,temp.mLength);
|
||||
NS_WARN_IF_FALSE(kNotFound==len,"possible embedded null in append(PRUnichar*)");
|
||||
#endif
|
||||
|
||||
@@ -1372,7 +1505,7 @@ nsString& nsString::Insert(const char* aCString,PRUint32 anOffset,PRInt32 aCount
|
||||
// If this assertion fires, the caller is probably lying about the length of
|
||||
// the passed-in string. File a bug on the caller.
|
||||
#ifdef NS_DEBUG
|
||||
PRInt32 len=nsStr::FindChar(temp,0,PR_FALSE,0);
|
||||
PRInt32 len=nsStr::FindChar(temp,0,PR_FALSE,0,temp.mLength);
|
||||
NS_WARN_IF_FALSE(kNotFound==len,"possible embedded null in Insert(char*)");
|
||||
#endif
|
||||
|
||||
@@ -1410,7 +1543,7 @@ nsString& nsString::Insert(const PRUnichar* aString,PRUint32 anOffset,PRInt32 aC
|
||||
// If this assertion fires, the caller is probably lying about the length of
|
||||
// the passed-in string. File a bug on the caller.
|
||||
#ifdef NS_DEBUG
|
||||
PRInt32 len=nsStr::FindChar(temp,0,PR_FALSE,0);
|
||||
PRInt32 len=nsStr::FindChar(temp,0,PR_FALSE,0,temp.mLength);
|
||||
NS_WARN_IF_FALSE(kNotFound==len,"possible embedded null in Insert(PRUnichar*)");
|
||||
#endif
|
||||
|
||||
@@ -1491,13 +1624,16 @@ PRInt32 nsString::BinarySearch(PRUnichar aChar) const{
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for given cstr within this string
|
||||
* search for given string within this string
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aCString - substr to be found
|
||||
* @param aString - substr to be found
|
||||
* @param aIgnoreCase tells us whether or not to do caseless compare
|
||||
* @param anOffset tells us where in this string to start searching
|
||||
* @param aCount tells us how many iterations to make starting at the given offset
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 nsString::Find(const char* aCString,PRBool aIgnoreCase,PRInt32 anOffset) const{
|
||||
PRInt32 nsString::Find(const char* aCString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{
|
||||
NS_ASSERTION(0!=aCString,kNullPointerError);
|
||||
|
||||
PRInt32 result=kNotFound;
|
||||
@@ -1506,19 +1642,22 @@ PRInt32 nsString::Find(const char* aCString,PRBool aIgnoreCase,PRInt32 anOffset)
|
||||
nsStr::Initialize(temp,eOneByte);
|
||||
temp.mLength=nsCRT::strlen(aCString);
|
||||
temp.mStr=(char*)aCString;
|
||||
result=nsStr::FindSubstr(*this,temp,aIgnoreCase,anOffset);
|
||||
result=nsStr::FindSubstr(*this,temp,aIgnoreCase,anOffset,aCount);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for given unichar* within this string
|
||||
* search for given string within this string
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aString - substr to be found
|
||||
* @param aIgnoreCase tells us whether or not to do caseless compare
|
||||
* @param anOffset tells us where in this string to start searching
|
||||
* @param aCount tells us how many iterations to make starting at the given offset
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 nsString::Find(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 anOffset) const{
|
||||
PRInt32 nsString::Find(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{
|
||||
NS_ASSERTION(0!=aString,kNullPointerError);
|
||||
|
||||
PRInt32 result=kNotFound;
|
||||
@@ -1527,32 +1666,38 @@ PRInt32 nsString::Find(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 anOff
|
||||
nsStr::Initialize(temp,eTwoByte);
|
||||
temp.mLength=nsCRT::strlen(aString);
|
||||
temp.mUStr=(PRUnichar*)aString;
|
||||
result=nsStr::FindSubstr(*this,temp,aIgnoreCase,anOffset);
|
||||
result=nsStr::FindSubstr(*this,temp,aIgnoreCase,anOffset,aCount);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for given nsSTr within this string
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aString - substr to be found
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 nsString::Find(const nsStr& aString,PRBool aIgnoreCase,PRInt32 anOffset) const{
|
||||
PRInt32 result=nsStr::FindSubstr(*this,aString,aIgnoreCase,anOffset);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for given string within this string
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aString - substr to be found
|
||||
* @param aIgnoreCase tells us whether or not to do caseless compare
|
||||
* @param anOffset tells us where in this string to start searching
|
||||
* @param aCount tells us how many iterations to make starting at the given offset
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 nsString::Find(const nsString& aString,PRBool aIgnoreCase,PRInt32 anOffset) const{
|
||||
PRInt32 result=nsStr::FindSubstr(*this,aString,aIgnoreCase,anOffset);
|
||||
PRInt32 nsString::Find(const nsStr& aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{
|
||||
PRInt32 result=nsStr::FindSubstr(*this,aString,aIgnoreCase,anOffset,aCount);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* search for given string within this string
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aString - substr to be found
|
||||
* @param aIgnoreCase tells us whether or not to do caseless compare
|
||||
* @param anOffset tells us where in this string to start searching
|
||||
* @param aCount tells us how many iterations to make starting at the given offset
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 nsString::Find(const nsString& aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{
|
||||
PRInt32 result=nsStr::FindSubstr(*this,aString,aIgnoreCase,anOffset,aCount);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1575,12 +1720,13 @@ PRInt32 nsString::Find(PRUnichar aChar,PRInt32 anOffset,PRBool aIgnoreCase) cons
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aChar is the unichar to be sought
|
||||
* @param anOffset
|
||||
* @param aIgnoreCase
|
||||
* @return offset of found char, or -1 (kNotFound)
|
||||
* @param aIgnoreCase tells us whether or not to do caseless compare
|
||||
* @param anOffset tells us where in this string to start searching
|
||||
* @param aCount tells us how many iterations to make starting at the given offset
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 nsString::FindChar(PRUnichar aChar,PRBool aIgnoreCase,PRInt32 anOffset) const{
|
||||
PRInt32 result=nsStr::FindChar(*this,aChar,aIgnoreCase,anOffset);
|
||||
PRInt32 nsString::FindChar(PRUnichar aChar,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{
|
||||
PRInt32 result=nsStr::FindChar(*this,aChar,aIgnoreCase,anOffset,aCount);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1646,50 +1792,55 @@ PRInt32 nsString::FindCharInSet(const nsStr& aSet,PRInt32 anOffset) const{
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Reverse search for given string within this string
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
* @param aString - substr to be found
|
||||
* @param aIgnoreCase tells us whether or not to do caseless compare
|
||||
* @param anOffset tells us where in this string to start searching
|
||||
* @param aCount tells us how many iterations to make starting at the given offset
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 nsString::RFind(const nsStr& aString,PRBool aIgnoreCase,PRInt32 anOffset) const{
|
||||
PRInt32 result=nsStr::RFindSubstr(*this,aString,aIgnoreCase,anOffset);
|
||||
PRInt32 nsString::RFind(const nsStr& aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{
|
||||
PRInt32 result=nsStr::RFindSubstr(*this,aString,aIgnoreCase,anOffset,aCount);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse search for substring
|
||||
* Reverse search for given string within this string
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aString
|
||||
* @param aIgnoreCase
|
||||
* @param anOffset - tells us where to begin the search
|
||||
* @return offset of substring or -1
|
||||
* @param aString - substr to be found
|
||||
* @param aIgnoreCase tells us whether or not to do caseless compare
|
||||
* @param anOffset tells us where in this string to start searching
|
||||
* @param aCount tells us how many iterations to make starting at the given offset
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 nsString::RFind(const nsString& aString,PRBool aIgnoreCase,PRInt32 anOffset) const{
|
||||
PRInt32 result=nsStr::RFindSubstr(*this,aString,aIgnoreCase,anOffset);
|
||||
PRInt32 nsString::RFind(const nsString& aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{
|
||||
PRInt32 result=nsStr::RFindSubstr(*this,aString,aIgnoreCase,anOffset,aCount);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse search for substring
|
||||
* Reverse search for given string within this string
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aString
|
||||
* @param aIgnoreCase
|
||||
* @param anOffset - tells us where to begin the search
|
||||
* @return offset of substring or -1
|
||||
* @param aString - substr to be found
|
||||
* @param aIgnoreCase tells us whether or not to do caseless compare
|
||||
* @param anOffset tells us where in this string to start searching
|
||||
* @param aCount tells us how many iterations to make starting at the given offset
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 nsString::RFind(const char* aString,PRBool aIgnoreCase,PRInt32 anOffset) const{
|
||||
PRInt32 nsString::RFind(const char* aString,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{
|
||||
NS_ASSERTION(0!=aString,kNullPointerError);
|
||||
|
||||
|
||||
PRInt32 result=kNotFound;
|
||||
if(aString) {
|
||||
nsStr temp;
|
||||
nsStr::Initialize(temp,eOneByte);
|
||||
temp.mLength=nsCRT::strlen(aString);
|
||||
temp.mStr=(char*)aString;
|
||||
result=nsStr::RFindSubstr(*this,temp,aIgnoreCase,anOffset);
|
||||
result=nsStr::RFindSubstr(*this,temp,aIgnoreCase,anOffset,aCount);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -1720,8 +1871,8 @@ PRInt32 nsString::RFind(PRUnichar aChar,PRInt32 anOffset,PRBool aIgnoreCase) con
|
||||
* @param anOffset
|
||||
* @return offset of found char, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 nsString::RFindChar(PRUnichar aChar,PRBool aIgnoreCase,PRInt32 anOffset) const{
|
||||
PRInt32 result=nsStr::RFindChar(*this,aChar,aIgnoreCase,anOffset);
|
||||
PRInt32 nsString::RFindChar(PRUnichar aChar,PRBool aIgnoreCase,PRInt32 anOffset,PRInt32 aCount) const{
|
||||
PRInt32 result=nsStr::RFindChar(*this,aChar,aIgnoreCase,anOffset,aCount);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -2358,12 +2509,16 @@ void nsAutoString::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const {
|
||||
}
|
||||
}
|
||||
|
||||
nsSubsumeStr::nsSubsumeStr() : nsString() {
|
||||
}
|
||||
|
||||
nsSubsumeStr::nsSubsumeStr(nsStr& aString) : nsString() {
|
||||
Subsume(*this,aString);
|
||||
::Subsume(*this,aString);
|
||||
}
|
||||
|
||||
nsSubsumeStr::nsSubsumeStr(PRUnichar* aString,PRBool assumeOwnership,PRInt32 aLength) : nsString() {
|
||||
mUStr=aString;
|
||||
mCharSize=eTwoByte;
|
||||
mCapacity=mLength=(-1==aLength) ? nsCRT::strlen(aString) : aLength;
|
||||
mOwnsBuffer=assumeOwnership;
|
||||
}
|
||||
@@ -2375,3 +2530,9 @@ nsSubsumeStr::nsSubsumeStr(char* aString,PRBool assumeOwnership,PRInt32 aLength)
|
||||
mOwnsBuffer=assumeOwnership;
|
||||
}
|
||||
|
||||
nsSubsumeStr::Subsume(PRUnichar* aString,PRBool assumeOwnership,PRInt32 aLength) {
|
||||
mUStr=aString;
|
||||
mCharSize=eTwoByte;
|
||||
mCapacity=mLength=(-1==aLength) ? nsCRT::strlen(aString) : aLength;
|
||||
mOwnsBuffer=assumeOwnership;
|
||||
}
|
||||
|
||||
@@ -310,9 +310,12 @@ public:
|
||||
*
|
||||
* @param aTrimSet -- contains chars to be trimmed from
|
||||
* both ends
|
||||
* @param aEliminateLeading
|
||||
* @param aEliminateTrailing
|
||||
* @param aIgnoreQuotes
|
||||
* @return this
|
||||
*/
|
||||
nsString& Trim(const char* aSet,PRBool aEliminateLeading=PR_TRUE,PRBool aEliminateTrailing=PR_TRUE);
|
||||
nsString& Trim(const char* aSet,PRBool aEliminateLeading=PR_TRUE,PRBool aEliminateTrailing=PR_TRUE,PRBool aIgnoreQuotes=PR_FALSE);
|
||||
|
||||
/**
|
||||
* This method strips whitespace from string.
|
||||
@@ -584,12 +587,13 @@ public:
|
||||
* @param aString is substring to be sought in this
|
||||
* @param aIgnoreCase selects case sensitivity
|
||||
* @param anOffset tells us where in this strig to start searching
|
||||
* @param aCount tells us how many iterations to make starting at the given offset
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 Find(const nsString& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 Find(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 Find(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 Find(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 Find(const nsString& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1,PRInt32 aCount=-1) const;
|
||||
PRInt32 Find(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1,PRInt32 aCount=-1) const;
|
||||
PRInt32 Find(const char* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1,PRInt32 aCount=-1) const;
|
||||
PRInt32 Find(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1,PRInt32 aCount=-1) const;
|
||||
|
||||
|
||||
/**
|
||||
@@ -598,10 +602,11 @@ public:
|
||||
* @param aString is substring to be sought in this
|
||||
* @param anOffset tells us where in this strig to start searching
|
||||
* @param aIgnoreCase selects case sensitivity
|
||||
* @param aCount tells us how many iterations to make starting at the given offset
|
||||
* @return find pos in string, or -1 (kNotFound)
|
||||
*/
|
||||
//PRInt32 Find(PRUnichar aChar,PRInt32 offset=-1,PRBool aIgnoreCase=PR_FALSE) const;
|
||||
PRInt32 FindChar(PRUnichar aChar,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 FindChar(PRUnichar aChar,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1,PRInt32 aCount=-1) const;
|
||||
|
||||
/**
|
||||
* This method searches this string for the first character
|
||||
@@ -619,12 +624,14 @@ public:
|
||||
* This methods scans the string backwards, looking for the given string
|
||||
* @param aString is substring to be sought in this
|
||||
* @param aIgnoreCase tells us whether or not to do caseless compare
|
||||
* @param anOffset tells us where in this strig to start searching (counting from left)
|
||||
* @param anOffset tells us where in this strig to start searching (counting from left)
|
||||
* @param aCount tells us how many iterations to make starting at the given offset
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 RFind(const char* aCString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 RFind(const nsString& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 RFind(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 RFind(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 RFind(const char* aCString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1,PRInt32 aCount=-1) const;
|
||||
PRInt32 RFind(const nsString& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1,PRInt32 aCount=-1) const;
|
||||
PRInt32 RFind(const nsStr& aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1,PRInt32 aCount=-1) const;
|
||||
PRInt32 RFind(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1,PRInt32 aCount=-1) const;
|
||||
|
||||
|
||||
/**
|
||||
@@ -633,10 +640,11 @@ public:
|
||||
* @param aString is substring to be sought in this
|
||||
* @param anOffset tells us where in this strig to start searching (counting from left)
|
||||
* @param aIgnoreCase selects case sensitivity
|
||||
* @param aCount tells us how many iterations to make starting at the given offset
|
||||
* @return find pos in string, or -1 (kNotFound)
|
||||
*/
|
||||
//PRInt32 RFind(PRUnichar aChar,PRInt32 offset=-1,PRBool aIgnoreCase=PR_FALSE) const;
|
||||
PRInt32 RFindChar(PRUnichar aChar,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1) const;
|
||||
PRInt32 RFindChar(PRUnichar aChar,PRBool aIgnoreCase=PR_FALSE,PRInt32 anOffset=-1,PRInt32 aCount=-1) const;
|
||||
|
||||
/**
|
||||
* This method searches this string for the last character
|
||||
@@ -849,9 +857,11 @@ public:
|
||||
***************************************************************/
|
||||
class NS_COM nsSubsumeStr : public nsString {
|
||||
public:
|
||||
nsSubsumeStr();
|
||||
nsSubsumeStr(nsStr& aString);
|
||||
nsSubsumeStr(PRUnichar* aString,PRBool assumeOwnership,PRInt32 aLength=-1);
|
||||
nsSubsumeStr(char* aString,PRBool assumeOwnership,PRInt32 aLength=-1);
|
||||
Subsume(PRUnichar* aString,PRBool assumeOwnership,PRInt32 aLength=-1);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user