adjustments to the string interfaces that should have no effect in the non-|NEW_STRING_APIS| case (yes, I built all changes to verify)
git-svn-id: svn://10.0.0.236/trunk@64635 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -120,7 +120,7 @@ PRBool nsStr::GrowCapacity(nsStr& aDest,PRUint32 aNewLength) {
|
||||
result=EnsureCapacity(theTempStr,aNewLength);
|
||||
if(result) {
|
||||
if(aDest.mLength) {
|
||||
Append(theTempStr,aDest,0,aDest.mLength);
|
||||
StrAppend(theTempStr,aDest,0,aDest.mLength);
|
||||
}
|
||||
Free(aDest);
|
||||
aDest.mStr = theTempStr.mStr;
|
||||
@@ -140,10 +140,10 @@ PRBool nsStr::GrowCapacity(nsStr& aDest,PRUint32 aNewLength) {
|
||||
* @param aSource is where chars are copied from
|
||||
* @param aCount is the number of chars copied from aSource
|
||||
*/
|
||||
void nsStr::Assign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount){
|
||||
void nsStr::StrAssign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount){
|
||||
if(&aDest!=&aSource){
|
||||
Truncate(aDest,0);
|
||||
Append(aDest,aSource,anOffset,aCount);
|
||||
StrAppend(aDest,aSource,anOffset,aCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ void nsStr::Assign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 a
|
||||
* @param aSource is where char are copied from
|
||||
* @aCount is the number of bytes to be copied
|
||||
*/
|
||||
void nsStr::Append(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount){
|
||||
void nsStr::StrAppend(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount){
|
||||
if(anOffset<aSource.mLength){
|
||||
PRUint32 theRealLen=(aCount<0) ? aSource.mLength : MinInt(aCount,aSource.mLength);
|
||||
PRUint32 theLength=(anOffset+theRealLen<aSource.mLength) ? theRealLen : (aSource.mLength-anOffset);
|
||||
@@ -188,7 +188,7 @@ void nsStr::Append(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 a
|
||||
* @param aSrcOffset is where in aSource chars are copied from
|
||||
* @param aCount is the number of chars from aSource to be inserted into aDest
|
||||
*/
|
||||
void nsStr::Insert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount){
|
||||
void nsStr::StrInsert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount){
|
||||
//there are a few cases for insert:
|
||||
// 1. You're inserting chars into an empty string (assign)
|
||||
// 2. You're inserting onto the end of a string (append)
|
||||
@@ -211,14 +211,14 @@ void nsStr::Insert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUin
|
||||
|
||||
if(isBigEnough) {
|
||||
if(aDestOffset) {
|
||||
Append(theTempStr,aDest,0,aDestOffset); //first copy leftmost data...
|
||||
StrAppend(theTempStr,aDest,0,aDestOffset); //first copy leftmost data...
|
||||
}
|
||||
|
||||
Append(theTempStr,aSource,0,aSource.mLength); //next copy inserted (new) data
|
||||
StrAppend(theTempStr,aSource,0,aSource.mLength); //next copy inserted (new) data
|
||||
|
||||
PRUint32 theRemains=aDest.mLength-aDestOffset;
|
||||
if(theRemains) {
|
||||
Append(theTempStr,aDest,aDestOffset,theRemains); //next copy rightmost data
|
||||
StrAppend(theTempStr,aDest,aDestOffset,theRemains); //next copy rightmost data
|
||||
}
|
||||
|
||||
Free(aDest);
|
||||
@@ -245,9 +245,9 @@ void nsStr::Insert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUin
|
||||
}//if
|
||||
//else nothing to do!
|
||||
}
|
||||
else Append(aDest,aSource,0,aCount);
|
||||
else StrAppend(aDest,aSource,0,aCount);
|
||||
}
|
||||
else Append(aDest,aSource,0,aCount);
|
||||
else StrAppend(aDest,aSource,0,aCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -833,7 +833,7 @@ nsStringInfo::nsStringInfo(nsStr& str)
|
||||
: mCount(0)
|
||||
{
|
||||
nsStr::Initialize(mStr, str.mCharSize);
|
||||
nsStr::Assign(mStr, str, 0, -1);
|
||||
nsStr::StrAssign(mStr, str, 0, -1);
|
||||
// nsStr::Print(mStr, stdout);
|
||||
// fputc('\n', stdout);
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ struct NS_COM nsStr {
|
||||
* @param aCount tells us the (max) # of chars to copy
|
||||
* @param anAgent is the allocator to be used for alloc/free operations
|
||||
*/
|
||||
static void Append(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount);
|
||||
static void StrAppend(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount);
|
||||
|
||||
/**
|
||||
* These methods are used to assign contents of a source string to dest string
|
||||
@@ -295,7 +295,7 @@ struct NS_COM nsStr {
|
||||
* @param aCount tells us the (max) # of chars to copy
|
||||
* @param anAgent is the allocator to be used for alloc/free operations
|
||||
*/
|
||||
static void Assign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount);
|
||||
static void StrAssign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount);
|
||||
|
||||
/**
|
||||
* These methods are used to insert content from source string to the dest nsStr
|
||||
@@ -308,7 +308,19 @@ struct NS_COM nsStr {
|
||||
* @param aCount tells us the (max) # of chars to insert
|
||||
* @param anAgent is the allocator to be used for alloc/free operations
|
||||
*/
|
||||
static void Insert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount);
|
||||
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.
|
||||
|
||||
@@ -53,7 +53,7 @@ static void CSubsume(nsStr& aDest,nsStr& aSource){
|
||||
aSource.mStr=0;
|
||||
}
|
||||
else{
|
||||
nsStr::Assign(aDest,aSource,0,aSource.mLength);
|
||||
nsStr::StrAssign(aDest,aSource,0,aSource.mLength);
|
||||
}
|
||||
}
|
||||
else nsStr::Truncate(aDest,0);
|
||||
@@ -64,9 +64,16 @@ static void CSubsume(nsStr& aDest,nsStr& aSource){
|
||||
* Default constructor.
|
||||
*/
|
||||
nsCString::nsCString() {
|
||||
nsStr::Initialize(*this,eOneByte);
|
||||
Initialize(*this,eOneByte);
|
||||
}
|
||||
|
||||
#ifdef NEW_STRING_APIS
|
||||
nsCString::nsCString(const char* aCString) {
|
||||
Initialize(*this,eOneByte);
|
||||
Assign(aCString);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This constructor accepts an ascii string
|
||||
* @update gess 1/4/99
|
||||
@@ -74,10 +81,11 @@ nsCString::nsCString() {
|
||||
* @param aLength tells us how many chars to copy from given CString
|
||||
*/
|
||||
nsCString::nsCString(const char* aCString,PRInt32 aLength) {
|
||||
nsStr::Initialize(*this,eOneByte);
|
||||
Initialize(*this,eOneByte);
|
||||
Assign(aCString,aLength);
|
||||
}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* This constructor accepts a unicode string
|
||||
* @update gess 1/4/99
|
||||
@@ -85,7 +93,7 @@ nsCString::nsCString(const char* aCString,PRInt32 aLength) {
|
||||
* @param aLength tells us how many chars to copy from given aString
|
||||
*/
|
||||
nsCString::nsCString(const PRUnichar* aString,PRInt32 aLength) {
|
||||
nsStr::Initialize(*this,eOneByte);
|
||||
Initialize(*this,eOneByte);
|
||||
AssignWithConversion(aString,aLength);
|
||||
}
|
||||
|
||||
@@ -95,9 +103,10 @@ nsCString::nsCString(const PRUnichar* aString,PRInt32 aLength) {
|
||||
* @param reference to another nsCString
|
||||
*/
|
||||
nsCString::nsCString(const nsStr &aString) {
|
||||
nsStr::Initialize(*this,eOneByte);
|
||||
nsStr::Assign(*this,aString,0,aString.mLength);
|
||||
Initialize(*this,eOneByte);
|
||||
StrAssign(*this,aString,0,aString.mLength);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This is our copy constructor
|
||||
@@ -105,8 +114,8 @@ nsCString::nsCString(const nsStr &aString) {
|
||||
* @param reference to another nsCString
|
||||
*/
|
||||
nsCString::nsCString(const nsCString& aString) {
|
||||
nsStr::Initialize(*this,aString.mCharSize);
|
||||
nsStr::Assign(*this,aString,0,aString.mLength);
|
||||
Initialize(*this,aString.mCharSize);
|
||||
StrAssign(*this,aString,0,aString.mLength);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,7 +131,7 @@ nsCString::nsCString(nsSubsumeCStr& aSubsumeStr) {
|
||||
* Destructor
|
||||
*/
|
||||
nsCString::~nsCString() {
|
||||
nsStr::Destroy(*this);
|
||||
Destroy(*this);
|
||||
}
|
||||
|
||||
#ifdef NEW_STRING_APIS
|
||||
@@ -157,15 +166,11 @@ char* nsCString::GetWritableFragment( nsWritableFragment<char>& aFragment, nsFra
|
||||
}
|
||||
|
||||
nsCString::nsCString( const nsAReadableCString& aReadable ) {
|
||||
nsStr::Initialize(*this,eOneByte);
|
||||
Initialize(*this,eOneByte);
|
||||
Assign(aReadable);
|
||||
}
|
||||
#endif
|
||||
|
||||
void nsCString::AppendChar( char aChar ) {
|
||||
Append(aChar);
|
||||
}
|
||||
|
||||
void nsCString::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const {
|
||||
if (aResult) {
|
||||
*aResult = sizeof(*this) + mCapacity * mCharSize;
|
||||
@@ -271,7 +276,7 @@ PRBool nsCString::SetCharAt(PRUnichar aChar,PRUint32 anIndex){
|
||||
*/
|
||||
nsSubsumeCStr nsCString::operator+(const nsCString& aString){
|
||||
nsCString temp(*this); //make a temp string the same size as this...
|
||||
nsStr::Append(temp,aString,0,aString.mLength);
|
||||
nsStr::StrAppend(temp,aString,0,aString.mLength);
|
||||
return nsSubsumeCStr(temp);
|
||||
}
|
||||
|
||||
@@ -521,7 +526,7 @@ nsCString& nsCString::ReplaceSubstring(const nsCString& aTarget,const nsCString&
|
||||
//this is the worst case: the newvalue is larger than the substr it's replacing
|
||||
//so we have to insert some characters...
|
||||
PRInt32 theInsLen=aNewValue.mLength-aTarget.mLength;
|
||||
nsStr::Insert(*this,theIndex,aNewValue,0,theInsLen);
|
||||
StrInsert(*this,theIndex,aNewValue,0,theInsLen);
|
||||
}
|
||||
nsStr::Overwrite(*this,aNewValue,theIndex);
|
||||
}
|
||||
@@ -841,11 +846,10 @@ nsCString& nsCString::Assign(const nsStr& aString,PRInt32 aCount) {
|
||||
aCount=aString.mLength;
|
||||
else aCount=MinInt(aCount,aString.mLength);
|
||||
|
||||
nsStr::Assign(*this,aString,0,aCount);
|
||||
StrAssign(*this,aString,0,aCount);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* assign given char* to this string
|
||||
@@ -864,55 +868,6 @@ nsCString& nsCString::Assign(const char* aCString,PRInt32 aCount) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* assign given unichar* to this string
|
||||
* @update gess 01/04/99
|
||||
* @param aCString: buffer to be assigned to this
|
||||
* @param aCount -- length of given buffer or -1 if you want me to compute length.
|
||||
* NOTE: IFF you pass -1 as aCount, then your buffer must be null terminated.
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
void nsCString::AssignWithConversion(const PRUnichar* aString,PRInt32 aCount) {
|
||||
nsStr::Truncate(*this,0);
|
||||
|
||||
if(aString && aCount){
|
||||
nsStr temp;
|
||||
Initialize(temp,eTwoByte);
|
||||
temp.mUStr=(PRUnichar*)aString;
|
||||
|
||||
if(0<aCount) {
|
||||
temp.mLength=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,temp.mLength);
|
||||
if(kNotFound<len) {
|
||||
NS_WARNING(kPossibleNull);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
else aCount=temp.mLength=nsCRT::strlen(aString);
|
||||
|
||||
if(0<aCount)
|
||||
nsStr::Append(*this,temp,0,aCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* assign given unichar to this string
|
||||
* @update gess 01/04/99
|
||||
* @param aChar: char to be assignd to this
|
||||
* @return this
|
||||
*/
|
||||
void nsCString::AssignWithConversion(PRUnichar aChar) {
|
||||
nsStr::Truncate(*this,0);
|
||||
Append(aChar);
|
||||
}
|
||||
|
||||
/**
|
||||
* assign given char to this string
|
||||
* @update gess 01/04/99
|
||||
@@ -942,7 +897,58 @@ nsCString& nsCString::operator=(nsSubsumeCStr& aSubsumeString) {
|
||||
#endif // AIX
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* assign given unichar* to this string
|
||||
* @update gess 01/04/99
|
||||
* @param aCString: buffer to be assigned to this
|
||||
* @param aCount -- length of given buffer or -1 if you want me to compute length.
|
||||
* NOTE: IFF you pass -1 as aCount, then your buffer must be null terminated.
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
void nsCString::AssignWithConversion(const PRUnichar* aString,PRInt32 aCount) {
|
||||
nsStr::Truncate(*this,0);
|
||||
|
||||
if(aString && aCount){
|
||||
nsStr temp;
|
||||
nsStr::Initialize(temp,eTwoByte);
|
||||
temp.mUStr=(PRUnichar*)aString;
|
||||
|
||||
if(0<aCount) {
|
||||
temp.mLength=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,temp.mLength);
|
||||
if(kNotFound<len) {
|
||||
NS_WARNING(kPossibleNull);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
else aCount=temp.mLength=nsCRT::strlen(aString);
|
||||
|
||||
if(0<aCount)
|
||||
StrAppend(*this,temp,0,aCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* assign given unichar to this string
|
||||
* @update gess 01/04/99
|
||||
* @param aChar: char to be assignd to this
|
||||
* @return this
|
||||
*/
|
||||
void nsCString::AssignWithConversion(PRUnichar aChar) {
|
||||
nsStr::Truncate(*this,0);
|
||||
Append(aChar);
|
||||
}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* append given string to this string
|
||||
* @update gess 01/04/99
|
||||
@@ -954,7 +960,7 @@ nsCString& nsCString::Append(const nsCString& aString,PRInt32 aCount) {
|
||||
aCount=aString.mLength;
|
||||
else aCount=MinInt(aCount,aString.mLength);
|
||||
if(0<aCount)
|
||||
nsStr::Append(*this,aString,0,aCount);
|
||||
StrAppend(*this,aString,0,aCount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -971,7 +977,7 @@ nsCString& nsCString::Append(const nsStr& aString,PRInt32 aCount) {
|
||||
else aCount=MinInt(aCount,aString.mLength);
|
||||
|
||||
if(0<aCount)
|
||||
nsStr::Append(*this,aString,0,aCount);
|
||||
StrAppend(*this,aString,0,aCount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -987,7 +993,7 @@ nsCString& nsCString::Append(const nsStr& aString,PRInt32 aCount) {
|
||||
nsCString& nsCString::Append(const char* aCString,PRInt32 aCount) {
|
||||
if(aCString){
|
||||
nsStr temp;
|
||||
Initialize(temp,eOneByte);
|
||||
nsStr::Initialize(temp,eOneByte);
|
||||
temp.mStr=(char*)aCString;
|
||||
|
||||
if(0<aCount) {
|
||||
@@ -996,30 +1002,11 @@ nsCString& nsCString::Append(const char* aCString,PRInt32 aCount) {
|
||||
else aCount=temp.mLength=nsCRT::strlen(aCString);
|
||||
|
||||
if(0<aCount)
|
||||
nsStr::Append(*this,temp,0,aCount);
|
||||
StrAppend(*this,temp,0,aCount);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* append given char to this string
|
||||
* @update gess 01/04/99
|
||||
* @param aChar: char to be appended to this
|
||||
* @return this
|
||||
*/
|
||||
nsCString& nsCString::Append(PRUnichar aChar) {
|
||||
PRUnichar buf[2]={0,0};
|
||||
buf[0]=aChar;
|
||||
|
||||
nsStr temp;
|
||||
Initialize(temp,eTwoByte);
|
||||
temp.mUStr=buf;
|
||||
temp.mLength=1;
|
||||
nsStr::Append(*this,temp,0,1);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* append given unichar to this string
|
||||
* @update gess 01/04/99
|
||||
@@ -1031,12 +1018,30 @@ nsCString& nsCString::Append(char aChar) {
|
||||
buf[0]=aChar;
|
||||
|
||||
nsStr temp;
|
||||
Initialize(temp,eOneByte);
|
||||
nsStr::Initialize(temp,eOneByte);
|
||||
temp.mStr=buf;
|
||||
temp.mLength=1;
|
||||
nsStr::Append(*this,temp,0,1);
|
||||
StrAppend(*this,temp,0,1);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* append given char to this string
|
||||
* @update gess 01/04/99
|
||||
* @param aChar: char to be appended to this
|
||||
* @return this
|
||||
*/
|
||||
void nsCString::AppendWithConversion(PRUnichar aChar) {
|
||||
PRUnichar buf[2]={0,0};
|
||||
buf[0]=aChar;
|
||||
|
||||
nsStr temp;
|
||||
nsStr::Initialize(temp,eTwoByte);
|
||||
temp.mUStr=buf;
|
||||
temp.mLength=1;
|
||||
StrAppend(*this,temp,0,1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Append the given integer to this string
|
||||
@@ -1045,7 +1050,7 @@ nsCString& nsCString::Append(char aChar) {
|
||||
* @param aRadix:
|
||||
* @return
|
||||
*/
|
||||
nsCString& nsCString::Append(PRInt32 anInteger,PRInt32 aRadix) {
|
||||
void nsCString::AppendWithConversion(PRInt32 anInteger,PRInt32 aRadix) {
|
||||
|
||||
PRUint32 theInt=(PRUint32)anInteger;
|
||||
|
||||
@@ -1073,7 +1078,7 @@ nsCString& nsCString::Append(PRInt32 anInteger,PRInt32 aRadix) {
|
||||
theInt-=theDiv*mask1;
|
||||
mask1/=aRadix;
|
||||
}
|
||||
return Append(buf);
|
||||
Append(buf);
|
||||
}
|
||||
|
||||
|
||||
@@ -1083,12 +1088,12 @@ nsCString& nsCString::Append(PRInt32 anInteger,PRInt32 aRadix) {
|
||||
* @param aFloat:
|
||||
* @return
|
||||
*/
|
||||
nsCString& nsCString::Append(float aFloat){
|
||||
void nsCString::AppendWithConversion(float aFloat){
|
||||
char buf[40];
|
||||
// *** XX UNCOMMENT THIS LINE
|
||||
//PR_snprintf(buf, sizeof(buf), "%g", aFloat);
|
||||
sprintf(buf,"%g",aFloat);
|
||||
return Append(buf);
|
||||
Append(buf);
|
||||
}
|
||||
|
||||
|
||||
@@ -1104,7 +1109,7 @@ PRUint32 nsCString::Left(nsCString& aDest,PRInt32 aCount) const{
|
||||
if(aCount<0)
|
||||
aCount=mLength;
|
||||
else aCount=MinInt(aCount,mLength);
|
||||
nsStr::Assign(aDest,*this,0,aCount);
|
||||
StrAssign(aDest,*this,0,aCount);
|
||||
return aDest.mLength;
|
||||
}
|
||||
|
||||
@@ -1121,7 +1126,7 @@ PRUint32 nsCString::Mid(nsCString& aDest,PRUint32 anOffset,PRInt32 aCount) const
|
||||
if(aCount<0)
|
||||
aCount=mLength;
|
||||
else aCount=MinInt(aCount,mLength);
|
||||
nsStr::Assign(aDest,*this,anOffset,aCount);
|
||||
StrAssign(aDest,*this,anOffset,aCount);
|
||||
return aDest.mLength;
|
||||
}
|
||||
|
||||
@@ -1139,6 +1144,25 @@ PRUint32 nsCString::Right(nsCString& aDest,PRInt32 aCount) const{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert a single unichar into this string at a specified offset.
|
||||
*
|
||||
* @update gess4/22/98
|
||||
* @param aChar unichar to be inserted into this string
|
||||
* @param anOffset is insert pos in str
|
||||
* @return this
|
||||
*/
|
||||
void nsCString::InsertWithConversion(PRUnichar aChar,PRUint32 anOffset){
|
||||
PRUnichar theBuffer[2]={0,0};
|
||||
theBuffer[0]=aChar;
|
||||
nsStr temp;
|
||||
nsStr::Initialize(temp,eTwoByte);
|
||||
temp.mUStr=theBuffer;
|
||||
temp.mLength=1;
|
||||
StrInsert(*this,anOffset,temp,0,1);
|
||||
}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/*
|
||||
* This method inserts n chars from given string into this
|
||||
* string at str[anOffset].
|
||||
@@ -1151,7 +1175,7 @@ PRUint32 nsCString::Right(nsCString& aDest,PRInt32 aCount) const{
|
||||
*/
|
||||
nsCString& nsCString::Insert(const nsCString& aString,PRUint32 anOffset,PRInt32 aCount) {
|
||||
|
||||
nsStr::Insert(*this,anOffset,aString,0,aCount);
|
||||
StrInsert(*this,anOffset,aString,0,aCount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -1186,32 +1210,13 @@ nsCString& nsCString::Insert(const char* aCString,PRUint32 anOffset,PRInt32 aCou
|
||||
else aCount=temp.mLength=nsCRT::strlen(aCString);
|
||||
|
||||
if(temp.mLength && (0<aCount)){
|
||||
nsStr::Insert(*this,anOffset,temp,0,aCount);
|
||||
StrInsert(*this,anOffset,temp,0,aCount);
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert a single unichar into this string at a specified offset.
|
||||
*
|
||||
* @update gess4/22/98
|
||||
* @param aChar unichar to be inserted into this string
|
||||
* @param anOffset is insert pos in str
|
||||
* @return this
|
||||
*/
|
||||
nsCString& nsCString::Insert(PRUnichar aChar,PRUint32 anOffset){
|
||||
PRUnichar theBuffer[2]={0,0};
|
||||
theBuffer[0]=aChar;
|
||||
nsStr temp;
|
||||
nsStr::Initialize(temp,eTwoByte);
|
||||
temp.mUStr=theBuffer;
|
||||
temp.mLength=1;
|
||||
nsStr::Insert(*this,anOffset,temp,0,1);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a single uni-char into this string at
|
||||
* a specified offset.
|
||||
@@ -1228,9 +1233,11 @@ nsCString& nsCString::Insert(char aChar,PRUint32 anOffset){
|
||||
nsStr::Initialize(temp,eOneByte);
|
||||
temp.mStr=theBuffer;
|
||||
temp.mLength=1;
|
||||
nsStr::Insert(*this,anOffset,temp,0,1);
|
||||
StrInsert(*this,anOffset,temp,0,1);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* This method is used to cut characters in this string
|
||||
@@ -1810,7 +1817,7 @@ void nsCString::DebugDump(void) const {
|
||||
*
|
||||
*/
|
||||
nsCAutoString::nsCAutoString() : nsCString(){
|
||||
nsStr::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
|
||||
}
|
||||
@@ -1819,7 +1826,7 @@ nsCAutoString::nsCAutoString() : nsCString(){
|
||||
* Default constructor
|
||||
*/
|
||||
nsCAutoString::nsCAutoString(const nsCAutoString& aString) : nsCString() {
|
||||
nsStr::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aString);
|
||||
}
|
||||
@@ -1830,7 +1837,7 @@ nsCAutoString::nsCAutoString(const nsCAutoString& aString) : nsCString() {
|
||||
* @param aCString is a ptr to a 1-byte cstr
|
||||
*/
|
||||
nsCAutoString::nsCAutoString(const char* aCString,PRInt32 aLength) : nsCString() {
|
||||
nsStr::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aCString,aLength);
|
||||
}
|
||||
@@ -1841,21 +1848,22 @@ nsCAutoString::nsCAutoString(const char* aCString,PRInt32 aLength) : nsCString()
|
||||
*/
|
||||
nsCAutoString::nsCAutoString(const CBufDescriptor& aBuffer) : nsCString() {
|
||||
if(!aBuffer.mBuffer) {
|
||||
nsStr::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
}
|
||||
else {
|
||||
nsStr::Initialize(*this,aBuffer.mBuffer,aBuffer.mCapacity,aBuffer.mLength,aBuffer.mCharSize,!aBuffer.mStackBased);
|
||||
Initialize(*this,aBuffer.mBuffer,aBuffer.mCapacity,aBuffer.mLength,aBuffer.mCharSize,!aBuffer.mStackBased);
|
||||
}
|
||||
if(!aBuffer.mIsConst)
|
||||
AddNullTerminator(*this); //this isn't really needed, but it guarantees that folks don't pass string constants.
|
||||
}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* Copy construct from uni-string
|
||||
* @param aString is a ptr to a unistr
|
||||
*/
|
||||
nsCAutoString::nsCAutoString(const PRUnichar* aString,PRInt32 aLength) : nsCString() {
|
||||
nsStr::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aString,aLength);
|
||||
}
|
||||
@@ -1865,7 +1873,7 @@ nsCAutoString::nsCAutoString(const PRUnichar* aString,PRInt32 aLength) : nsCStri
|
||||
* @param
|
||||
*/
|
||||
nsCAutoString::nsCAutoString(const nsStr& aString) : nsCString() {
|
||||
nsStr::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aString);
|
||||
}
|
||||
@@ -1877,10 +1885,12 @@ nsCAutoString::nsCAutoString(const nsStr& aString) : nsCString() {
|
||||
* @param
|
||||
*/
|
||||
nsCAutoString::nsCAutoString(PRUnichar aChar) : nsCString(){
|
||||
nsStr::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aChar);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* construct from a subsumeable string
|
||||
|
||||
@@ -50,6 +50,20 @@
|
||||
#else
|
||||
#define NS_LITERAL_STRING(s) (s)
|
||||
#define NS_LITERAL_CSTRING(s) (s)
|
||||
|
||||
inline
|
||||
char
|
||||
nsLiteralChar( char c )
|
||||
{
|
||||
return c;
|
||||
}
|
||||
|
||||
inline
|
||||
PRUnichar
|
||||
nsLiteralPRUnichar( PRUnichar c )
|
||||
{
|
||||
return c;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -65,34 +79,26 @@ class NS_COM nsCString :
|
||||
protected:
|
||||
virtual const char* GetReadableFragment( nsReadableFragment<char>&, nsFragmentRequest, PRUint32 ) const;
|
||||
virtual char* GetWritableFragment( nsWritableFragment<char>&, nsFragmentRequest, PRUint32 );
|
||||
|
||||
public:
|
||||
nsCString( const nsAReadableCString& );
|
||||
|
||||
#ifdef HAVE_AMBIGUITY_RESOLVING_CPP_USING
|
||||
using nsAWritableCString::Append;
|
||||
using nsAWritableCString::Insert;
|
||||
#else
|
||||
virtual void Append( const nsAReadableCString& aReadable ) {
|
||||
nsAWritableCString::Append(aReadable);
|
||||
}
|
||||
|
||||
virtual void Insert( const nsAReadableCString& aReadable, PRUint32 atPosition ) {
|
||||
nsAWritableCString::Insert(aReadable, atPosition);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
public:
|
||||
void AppendChar( char );
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
nsCString();
|
||||
|
||||
/**
|
||||
* This is our copy constructor
|
||||
* @param reference to another nsCString
|
||||
*/
|
||||
nsCString(const nsCString& aString);
|
||||
|
||||
#ifdef NEW_STRING_APIS
|
||||
nsCString( const nsAReadableCString& );
|
||||
|
||||
nsCString(const char*);
|
||||
nsCString(const char*, PRInt32);
|
||||
#else
|
||||
/**
|
||||
* This constructor accepts an isolatin string
|
||||
* @param aCString is a ptr to a 1-byte cstr
|
||||
@@ -110,12 +116,7 @@ public:
|
||||
* @param reference to another nsCString
|
||||
*/
|
||||
nsCString(const nsStr&);
|
||||
|
||||
/**
|
||||
* This is our copy constructor
|
||||
* @param reference to another nsCString
|
||||
*/
|
||||
nsCString(const nsCString& aString);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This constructor takes a subsumestr
|
||||
@@ -335,10 +336,10 @@ public:
|
||||
/**********************************************************************
|
||||
string conversion methods...
|
||||
*********************************************************************/
|
||||
#ifndef STASTANDALONE_STRING_TESTS
|
||||
//#ifndef STANDALONE_STRING_TESTS
|
||||
operator char*() {return mStr;}
|
||||
operator const char*() const {return (const char*)mStr;}
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
/**
|
||||
* This method constructs a new nsCString that is a clone
|
||||
@@ -399,91 +400,46 @@ public:
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
#ifdef NEW_STRING_APIS
|
||||
#ifdef HAVE_AMBIGUITY_RESOLVING_CPP_USING
|
||||
using nsAWritableCString::Assign;
|
||||
#else
|
||||
virtual void Assign( const nsAReadableCString& aReadable ) {
|
||||
nsAWritableCString::Assign(aReadable);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
nsCString& Assign(const char* aString,PRInt32 aCount=-1);
|
||||
nsCString& Assign(char aChar);
|
||||
|
||||
void AssignWithConversion(const PRUnichar*,PRInt32=-1);
|
||||
void AssignWithConversion(PRUnichar);
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsCString& Assign(const char* aString,PRInt32 aCount=-1);
|
||||
nsCString& Assign(char aChar);
|
||||
|
||||
nsCString& Assign(const nsStr& aString,PRInt32 aCount=-1);
|
||||
nsCString& Assign(const PRUnichar* aString,PRInt32 aCount=-1) { AssignWithConversion(aString, aCount); return *this; }
|
||||
nsCString& Assign(PRUnichar aChar) { AssignWithConversion(aChar); return *this; }
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Functionally equivalent to assign or operator=
|
||||
*
|
||||
*/
|
||||
nsCString& SetString(const char* aString,PRInt32 aLength=-1) {return Assign(aString,aLength);}
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsCString& SetString(const nsStr& aString,PRInt32 aLength=-1) {return Assign(aString,aLength);}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* here come a bunch of assignment operators...
|
||||
* @param aString: string to be added to this
|
||||
* @return this
|
||||
*/
|
||||
#ifdef NEW_STRING_APIS
|
||||
#ifdef HAVE_AMBIGUITY_RESOLVING_CPP_USING
|
||||
using nsAWritableCString::operator=;
|
||||
#else
|
||||
nsCString& operator=( const nsAReadableCString& aReadable ) { nsAWritableCString::operator=(aReadable); return *this; }
|
||||
#endif
|
||||
#endif
|
||||
nsCString& operator=(PRUnichar aChar) {return Assign(aChar);}
|
||||
nsCString& operator=(char aChar) {AssignWithConversion(aChar); return *this;}
|
||||
nsCString& operator=(const PRUnichar* aString) {AssignWithConversion(aString); return *this;}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsCString& operator=(const nsCString& aString) {return Assign(aString);}
|
||||
nsCString& operator=(const nsStr& aString) {return Assign(aString);}
|
||||
nsCString& operator=(const char* aCString) {return Assign(aCString);}
|
||||
#endif
|
||||
|
||||
// Yes, I know this makes assignment from a |nsSubsumeString| not do the special thing
|
||||
// |nsSubsumeString| needs to go away
|
||||
#ifdef AIX
|
||||
nsCString& operator=(const nsSubsumeCStr& aSubsumeString); // AIX requires a const here
|
||||
#else
|
||||
nsCString& operator=(nsSubsumeCStr& aSubsumeString);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Here's a bunch of methods that append varying types...
|
||||
* @param various...
|
||||
* @return this
|
||||
*/
|
||||
#ifdef NEW_STRING_APIS
|
||||
#ifdef HAVE_AMBIGUITY_RESOLVING_CPP_USING
|
||||
using nsAWritableCString::operator+=;
|
||||
#else
|
||||
nsCString& operator+=( const nsAReadableCString& aReadable ) { nsAWritableCString::operator+=(aReadable); return *this; }
|
||||
#endif
|
||||
#endif
|
||||
nsCString& operator+=(const PRUnichar aChar){return Append(aChar);}
|
||||
nsCString& operator+=(const char aChar){return Append(aChar);}
|
||||
nsCString& operator+=(const int anInt){return Append(anInt,10);}
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsCString& operator+=(const nsCString& aString){return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsCString& operator+=(const char* aCString) {return Append(aCString);}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Appends n characters from given string to this,
|
||||
* This version computes the length of your given string
|
||||
*
|
||||
* @param aString is the source to be appended to this
|
||||
* @return number of chars copied
|
||||
*/
|
||||
nsCString& Append(const nsCString& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
|
||||
|
||||
/*
|
||||
@@ -495,13 +451,35 @@ public:
|
||||
*
|
||||
* @return number of chars copied
|
||||
*/
|
||||
nsCString& Append(const nsCString& aString,PRInt32 aCount);
|
||||
|
||||
void AppendWithConversion(PRInt32 aInteger,PRInt32 aRadix=10); //radix=8,10 or 16
|
||||
void AppendWithConversion(float aFloat);
|
||||
void AppendWithConversion(PRUnichar aChar);
|
||||
// Why no |AppendWithConversion(const PRUnichar*)|?
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsCString& Append(const nsStr& aString,PRInt32 aCount=-1);
|
||||
nsCString& Append(const nsCString& aString,PRInt32 aCount);
|
||||
nsCString& Append(const nsCString& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsCString& Append(const char* aString,PRInt32 aCount=-1);
|
||||
nsCString& Append(PRUnichar aChar);
|
||||
nsCString& Append(char aChar);
|
||||
nsCString& Append(PRInt32 aInteger,PRInt32 aRadix=10); //radix=8,10 or 16
|
||||
nsCString& Append(float aFloat);
|
||||
|
||||
nsCString& Append(PRUnichar aChar) {AppendWithConversion(aChar); return *this;}
|
||||
nsCString& Append(PRInt32 aInteger,PRInt32 aRadix=10) {AppendWithConversion(aInteger,aRadix); return *this;}
|
||||
nsCString& Append(float aFloat) {AppendWithConversion(aFloat); return *this;}
|
||||
|
||||
/**
|
||||
* Here's a bunch of methods that append varying types...
|
||||
* @param various...
|
||||
* @return this
|
||||
*/
|
||||
nsCString& operator+=(const nsCString& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsCString& operator+=(const char* aCString) {return Append(aCString);}
|
||||
|
||||
nsCString& operator+=(const PRUnichar aChar) {return Append(aChar);}
|
||||
nsCString& operator+=(const char aChar) {return Append(aChar);}
|
||||
nsCString& operator+=(const int anInt) {return Append(anInt,10);}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copies n characters from this string to given string,
|
||||
@@ -537,6 +515,10 @@ public:
|
||||
*/
|
||||
PRUint32 Right(nsCString& aCopy,PRInt32 aCount) const;
|
||||
|
||||
void InsertWithConversion(PRUnichar aChar,PRUint32 anOffset);
|
||||
// Why no |InsertWithConversion(PRUnichar*)|?
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/*
|
||||
* This method inserts n chars from given string into this
|
||||
* string at str[anOffset].
|
||||
@@ -568,8 +550,9 @@ public:
|
||||
* @param anOffset is insert pos in str
|
||||
* @return the number of chars inserted into this string
|
||||
*/
|
||||
nsCString& Insert(PRUnichar aChar,PRUint32 anOffset);
|
||||
nsCString& Insert(PRUnichar aChar,PRUint32 anOffset) {InsertWithConversion(aChar,anOffset); return *this;}
|
||||
nsCString& Insert(char aChar,PRUint32 anOffset);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This method is used to cut characters in this string
|
||||
@@ -781,12 +764,18 @@ extern NS_COM int fputs(const nsCString& aString, FILE* out);
|
||||
class NS_COM nsCAutoString : public nsCString {
|
||||
public:
|
||||
|
||||
virtual ~nsCAutoString();
|
||||
|
||||
nsCAutoString();
|
||||
nsCAutoString(const nsCAutoString& aString);
|
||||
nsCAutoString(const char* aString,PRInt32 aLength=-1);
|
||||
nsCAutoString(const CBufDescriptor& aBuffer);
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsCAutoString(const PRUnichar* aString,PRInt32 aLength=-1);
|
||||
nsCAutoString(const nsStr& aString);
|
||||
nsCAutoString(const nsCAutoString& aString);
|
||||
nsCAutoString(PRUnichar aChar);
|
||||
#endif
|
||||
|
||||
#ifdef AIX
|
||||
nsCAutoString(const nsSubsumeCStr& aSubsumeStr); // AIX requires a const
|
||||
@@ -794,8 +783,6 @@ public:
|
||||
nsCAutoString(nsSubsumeCStr& aSubsumeStr);
|
||||
#endif // AIX
|
||||
|
||||
nsCAutoString(PRUnichar aChar);
|
||||
virtual ~nsCAutoString();
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsCAutoString& operator=(const nsCAutoString& aString) {nsCString::Assign(aString); return *this;}
|
||||
|
||||
@@ -52,7 +52,7 @@ static void Subsume(nsStr& aDest,nsStr& aSource){
|
||||
aSource.mStr=0;
|
||||
}
|
||||
else{
|
||||
nsStr::Assign(aDest,aSource,0,aSource.mLength);
|
||||
nsStr::StrAssign(aDest,aSource,0,aSource.mLength);
|
||||
}
|
||||
}
|
||||
else nsStr::Truncate(aDest,0);
|
||||
@@ -63,9 +63,10 @@ static void Subsume(nsStr& aDest,nsStr& aSource){
|
||||
* Default constructor.
|
||||
*/
|
||||
nsString::nsString() {
|
||||
nsStr::Initialize(*this,eTwoByte);
|
||||
Initialize(*this,eTwoByte);
|
||||
}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* This constructor accepts an ascii string
|
||||
* @update gess 1/4/99
|
||||
@@ -73,9 +74,17 @@ nsString::nsString() {
|
||||
* @param aLength tells us how many chars to copy from given CString
|
||||
*/
|
||||
nsString::nsString(const char* aCString,PRInt32 aCount){
|
||||
nsStr::Initialize(*this,eTwoByte);
|
||||
Initialize(*this,eTwoByte);
|
||||
AssignWithConversion(aCString,aCount);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NEW_STRING_APIS
|
||||
nsString::nsString(const PRUnichar* aString) {
|
||||
Initialize(*this,eTwoByte);
|
||||
Assign(aString);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This constructor accepts a unicode string
|
||||
@@ -84,19 +93,21 @@ nsString::nsString(const char* aCString,PRInt32 aCount){
|
||||
* @param aLength tells us how many chars to copy from given aString
|
||||
*/
|
||||
nsString::nsString(const PRUnichar* aString,PRInt32 aCount) {
|
||||
nsStr::Initialize(*this,eTwoByte);
|
||||
Initialize(*this,eTwoByte);
|
||||
Assign(aString,aCount);
|
||||
}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* This constructor works for all other nsSTr derivatives
|
||||
* @update gess 1/4/99
|
||||
* @param reference to another nsCString
|
||||
*/
|
||||
nsString::nsString(const nsStr &aString) {
|
||||
nsStr::Initialize(*this,eTwoByte);
|
||||
nsStr::Assign(*this,aString,0,aString.mLength);
|
||||
Initialize(*this,eTwoByte);
|
||||
StrAssign(*this,aString,0,aString.mLength);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This is our copy constructor
|
||||
@@ -104,8 +115,8 @@ nsString::nsString(const nsStr &aString) {
|
||||
* @param reference to another nsString
|
||||
*/
|
||||
nsString::nsString(const nsString& aString) {
|
||||
nsStr::Initialize(*this,eTwoByte);
|
||||
nsStr::Assign(*this,aString,0,aString.mLength);
|
||||
Initialize(*this,eTwoByte);
|
||||
StrAssign(*this,aString,0,aString.mLength);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,13 +126,13 @@ nsString::nsString(const nsString& aString) {
|
||||
*/
|
||||
#ifdef AIX
|
||||
nsString::nsString(const nsSubsumeStr& aSubsumeStr) {
|
||||
nsStr::Initialize(*this,eTwoByte);
|
||||
Initialize(*this,eTwoByte);
|
||||
|
||||
nsSubsumeStr temp(aSubsumeStr); // a temp is needed for the AIX compiler
|
||||
Subsume(*this,temp);
|
||||
#else
|
||||
nsString::nsString(nsSubsumeStr& aSubsumeStr) {
|
||||
nsStr::Initialize(*this,eTwoByte);
|
||||
Initialize(*this,eTwoByte);
|
||||
|
||||
Subsume(*this,aSubsumeStr);
|
||||
#endif /* AIX */
|
||||
@@ -167,15 +178,11 @@ PRUnichar* nsString::GetWritableFragment( nsWritableFragment<PRUnichar>& aFragme
|
||||
}
|
||||
|
||||
nsString::nsString( const nsAReadableString& aReadable ) {
|
||||
nsStr::Initialize(*this,eTwoByte);
|
||||
Initialize(*this,eTwoByte);
|
||||
Assign(aReadable);
|
||||
}
|
||||
#endif
|
||||
|
||||
void nsString::AppendChar( PRUnichar aChar ) {
|
||||
Append(aChar);
|
||||
}
|
||||
|
||||
void nsString::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const {
|
||||
if (aResult) {
|
||||
*aResult = sizeof(*this) + mCapacity * mCharSize;
|
||||
@@ -305,7 +312,7 @@ PRBool nsString::SetCharAt(PRUnichar aChar,PRUint32 anIndex){
|
||||
*/
|
||||
nsSubsumeStr nsString::operator+(const nsStr& aString){
|
||||
nsString temp(*this); //make a temp string the same size as this...
|
||||
nsStr::Append(temp,aString,0,aString.mLength);
|
||||
nsStr::StrAppend(temp,aString,0,aString.mLength);
|
||||
return nsSubsumeStr(temp);
|
||||
}
|
||||
|
||||
@@ -317,7 +324,7 @@ nsSubsumeStr nsString::operator+(const nsStr& aString){
|
||||
*/
|
||||
nsSubsumeStr nsString::operator+(const nsString& aString){
|
||||
nsString temp(*this); //make a temp string the same size as this...
|
||||
nsStr::Append(temp,aString,0,aString.mLength);
|
||||
nsStr::StrAppend(temp,aString,0,aString.mLength);
|
||||
return nsSubsumeStr(temp);
|
||||
}
|
||||
|
||||
@@ -584,7 +591,7 @@ nsString& nsString::ReplaceSubstring(const nsString& aTarget,const nsString& aNe
|
||||
//this is the worst case: the newvalue is larger than the substr it's replacing
|
||||
//so we have to insert some characters...
|
||||
PRInt32 theInsLen=aNewValue.mLength-aTarget.mLength;
|
||||
nsStr::Insert(*this,theIndex,aNewValue,0,theInsLen);
|
||||
StrInsert(*this,theIndex,aNewValue,0,theInsLen);
|
||||
}
|
||||
nsStr::Overwrite(*this,aNewValue,theIndex);
|
||||
}
|
||||
@@ -833,7 +840,7 @@ char* nsString::ToCString(char* aBuf, PRUint32 aBufLength,PRUint32 anOffset) con
|
||||
|
||||
CBufDescriptor theDescr(aBuf,PR_TRUE,aBufLength,0);
|
||||
nsCAutoString temp(theDescr);
|
||||
nsStr::Assign(temp, *this, anOffset, aBufLength-1);
|
||||
nsStr::StrAssign(temp, *this, anOffset, aBufLength-1);
|
||||
temp.mStr=0;
|
||||
}
|
||||
return aBuf;
|
||||
@@ -977,13 +984,13 @@ PRInt32 nsString::ToInteger(PRInt32* anErrorCode,PRUint32 aRadix) const {
|
||||
*********************************************************************/
|
||||
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* assign given nsStr (or derivative) to this one
|
||||
* @update gess 01/04/99
|
||||
* @param aString: nsStr to be appended
|
||||
* @return this
|
||||
*/
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsString& nsString::Assign(const nsStr& aString,PRInt32 aCount) {
|
||||
if(this!=&aString){
|
||||
nsStr::Truncate(*this,0);
|
||||
@@ -992,7 +999,7 @@ nsString& nsString::Assign(const nsStr& aString,PRInt32 aCount) {
|
||||
aCount=aString.mLength;
|
||||
else aCount=MinInt(aCount,aString.mLength);
|
||||
|
||||
nsStr::Assign(*this,aString,0,aCount);
|
||||
StrAssign(*this,aString,0,aCount);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@@ -1010,10 +1017,20 @@ nsString& nsString::Assign(const nsStr& aString,PRInt32 aCount) {
|
||||
void nsString::AssignWithConversion(const char* aCString,PRInt32 aCount) {
|
||||
nsStr::Truncate(*this,0);
|
||||
if(aCString){
|
||||
Append(aCString,aCount);
|
||||
AppendWithConversion(aCString,aCount);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NEW_STRING_APIS
|
||||
void nsString::AssignWithConversion(const char* aCString) {
|
||||
nsStr::Truncate(*this,0);
|
||||
if(aCString){
|
||||
AppendWithConversion(aCString);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* assign given unichar* to this string
|
||||
* @update gess 01/04/99
|
||||
@@ -1030,6 +1047,7 @@ nsString& nsString::Assign(const PRUnichar* aString,PRInt32 aCount) {
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* assign given char to this string
|
||||
@@ -1039,9 +1057,10 @@ nsString& nsString::Assign(const PRUnichar* aString,PRInt32 aCount) {
|
||||
*/
|
||||
void nsString::AssignWithConversion(char aChar) {
|
||||
nsStr::Truncate(*this,0);
|
||||
Append(aChar);
|
||||
AppendWithConversion(aChar);
|
||||
}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* assign given unichar to this string
|
||||
* @update gess 01/04/99
|
||||
@@ -1052,7 +1071,9 @@ nsString& nsString::Assign(PRUnichar aChar) {
|
||||
nsStr::Truncate(*this,0);
|
||||
return Append(aChar);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* WARNING! THIS IS A VERY SPECIAL METHOD.
|
||||
* This method "steals" the contents of aSource and hands it to aDest.
|
||||
@@ -1071,40 +1092,7 @@ nsString& nsString::operator=(const nsSubsumeStr& aSubsumeString) {
|
||||
#endif // AIX
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* append given string to this string;
|
||||
* @update gess 01/04/99
|
||||
* @param aString : string to be appended to this
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Append(const nsStr& aString,PRInt32 aCount) {
|
||||
|
||||
if(aCount<0)
|
||||
aCount=aString.mLength;
|
||||
else aCount=MinInt(aCount,aString.mLength);
|
||||
|
||||
if(0<aCount)
|
||||
nsStr::Append(*this,aString,0,aCount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* append given string to this string
|
||||
* I don't think we need this method now that we have the previous one.
|
||||
* @update gess 01/04/99
|
||||
* @param aString : string to be appended to this
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Append(const nsString& aString,PRInt32 aCount) {
|
||||
if(aCount<0)
|
||||
aCount=aString.mLength;
|
||||
else aCount=MinInt(aCount,aString.mLength);
|
||||
if(0<aCount)
|
||||
nsStr::Append(*this,aString,0,aCount);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* append given c-string to this string
|
||||
@@ -1115,10 +1103,10 @@ nsString& nsString::Append(const nsString& aString,PRInt32 aCount) {
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Append(const char* aCString,PRInt32 aCount) {
|
||||
void nsString::AppendWithConversion(const char* aCString,PRInt32 aCount) {
|
||||
if(aCString && aCount){ //if astring is null or count==0 there's nothing to do
|
||||
nsStr temp;
|
||||
Initialize(temp,eOneByte);
|
||||
nsStr::Initialize(temp,eOneByte);
|
||||
temp.mStr=(char*)aCString;
|
||||
|
||||
if(0<aCount) {
|
||||
@@ -1138,45 +1126,8 @@ nsString& nsString::Append(const char* aCString,PRInt32 aCount) {
|
||||
else aCount=temp.mLength=nsCRT::strlen(aCString);
|
||||
|
||||
if(0<aCount)
|
||||
nsStr::Append(*this,temp,0,aCount);
|
||||
StrAppend(*this,temp,0,aCount);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* append given unicode string to this
|
||||
* @update gess 01/04/99
|
||||
* @param aString : string to be appended to this
|
||||
* @param aCount -- length of given buffer or -1 if you want me to compute length.
|
||||
* NOTE: IFF you pass -1 as aCount, then your buffer must be null terminated.
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Append(const PRUnichar* aString,PRInt32 aCount) {
|
||||
if(aString && aCount){ //if astring is null or count==0 there's nothing to do
|
||||
nsStr temp;
|
||||
Initialize(temp,eTwoByte);
|
||||
temp.mUStr=(PRUnichar*)aString;
|
||||
|
||||
if(0<aCount) {
|
||||
temp.mLength=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,temp.mLength);
|
||||
if(kNotFound<len) {
|
||||
NS_WARNING(kPossibleNull);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
else aCount=temp.mLength=nsCRT::strlen(aString);
|
||||
|
||||
if(0<aCount)
|
||||
nsStr::Append(*this,temp,0,aCount);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1185,34 +1136,15 @@ nsString& nsString::Append(const PRUnichar* aString,PRInt32 aCount) {
|
||||
* @param aChar: char to be appended
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Append(char aChar) {
|
||||
void nsString::AppendWithConversion(char aChar) {
|
||||
char buf[2]={0,0};
|
||||
buf[0]=aChar;
|
||||
|
||||
nsStr temp;
|
||||
Initialize(temp,eOneByte);
|
||||
nsStr::Initialize(temp,eOneByte);
|
||||
temp.mStr=buf;
|
||||
temp.mLength=1;
|
||||
nsStr::Append(*this,temp,0,1);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* append given unichar to this string
|
||||
* @update gess 01/04/99
|
||||
* @param aChar: char to be appended to this
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Append(PRUnichar aChar) {
|
||||
PRUnichar buf[2]={0,0};
|
||||
buf[0]=aChar;
|
||||
|
||||
nsStr temp;
|
||||
Initialize(temp,eTwoByte);
|
||||
temp.mUStr=buf;
|
||||
temp.mLength=1;
|
||||
nsStr::Append(*this,temp,0,1);
|
||||
return *this;
|
||||
StrAppend(*this,temp,0,1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1222,7 +1154,7 @@ nsString& nsString::Append(PRUnichar aChar) {
|
||||
* @param aRadix:
|
||||
* @return
|
||||
*/
|
||||
nsString& nsString::Append(PRInt32 anInteger,PRInt32 aRadix) {
|
||||
void nsString::AppendWithConversion(PRInt32 anInteger,PRInt32 aRadix) {
|
||||
|
||||
PRUint32 theInt=(PRUint32)anInteger;
|
||||
|
||||
@@ -1250,7 +1182,7 @@ nsString& nsString::Append(PRInt32 anInteger,PRInt32 aRadix) {
|
||||
theInt-=theDiv*mask1;
|
||||
mask1/=aRadix;
|
||||
}
|
||||
return Append(buf);
|
||||
AppendWithConversion(buf);
|
||||
}
|
||||
|
||||
|
||||
@@ -1260,16 +1192,105 @@ nsString& nsString::Append(PRInt32 anInteger,PRInt32 aRadix) {
|
||||
* @param aFloat:
|
||||
* @return
|
||||
*/
|
||||
nsString& nsString::Append(float aFloat){
|
||||
void nsString::AppendWithConversion(float aFloat){
|
||||
char buf[40];
|
||||
// *** XX UNCOMMENT THIS LINE
|
||||
//PR_snprintf(buf, sizeof(buf), "%g", aFloat);
|
||||
sprintf(buf,"%g",aFloat);
|
||||
Append(buf);
|
||||
AppendWithConversion(buf);
|
||||
}
|
||||
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* append given string to this string;
|
||||
* @update gess 01/04/99
|
||||
* @param aString : string to be appended to this
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Append(const nsStr& aString,PRInt32 aCount) {
|
||||
|
||||
if(aCount<0)
|
||||
aCount=aString.mLength;
|
||||
else aCount=MinInt(aCount,aString.mLength);
|
||||
|
||||
if(0<aCount)
|
||||
StrAppend(*this,aString,0,aCount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* append given string to this string
|
||||
* I don't think we need this method now that we have the previous one.
|
||||
* @update gess 01/04/99
|
||||
* @param aString : string to be appended to this
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Append(const nsString& aString,PRInt32 aCount) {
|
||||
if(aCount<0)
|
||||
aCount=aString.mLength;
|
||||
else aCount=MinInt(aCount,aString.mLength);
|
||||
if(0<aCount)
|
||||
StrAppend(*this,aString,0,aCount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* append given unicode string to this
|
||||
* @update gess 01/04/99
|
||||
* @param aString : string to be appended to this
|
||||
* @param aCount -- length of given buffer or -1 if you want me to compute length.
|
||||
* NOTE: IFF you pass -1 as aCount, then your buffer must be null terminated.
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Append(const PRUnichar* aString,PRInt32 aCount) {
|
||||
if(aString && aCount){ //if astring is null or count==0 there's nothing to do
|
||||
nsStr temp;
|
||||
nsStr::Initialize(temp,eTwoByte);
|
||||
temp.mUStr=(PRUnichar*)aString;
|
||||
|
||||
if(0<aCount) {
|
||||
temp.mLength=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,temp.mLength);
|
||||
if(kNotFound<len) {
|
||||
NS_WARNING(kPossibleNull);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
else aCount=temp.mLength=nsCRT::strlen(aString);
|
||||
|
||||
if(0<aCount)
|
||||
StrAppend(*this,temp,0,aCount);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* append given unichar to this string
|
||||
* @update gess 01/04/99
|
||||
* @param aChar: char to be appended to this
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Append(PRUnichar aChar) {
|
||||
PRUnichar buf[2]={0,0};
|
||||
buf[0]=aChar;
|
||||
|
||||
nsStr temp;
|
||||
nsStr::Initialize(temp,eTwoByte);
|
||||
temp.mUStr=buf;
|
||||
temp.mLength=1;
|
||||
StrAppend(*this,temp,0,1);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copies n characters from this left of this string to given string,
|
||||
*
|
||||
@@ -1283,7 +1304,7 @@ PRUint32 nsString::Left(nsString& aDest,PRInt32 aCount) const{
|
||||
if(aCount<0)
|
||||
aCount=mLength;
|
||||
else aCount=MinInt(aCount,mLength);
|
||||
nsStr::Assign(aDest,*this,0,aCount);
|
||||
nsStr::StrAssign(aDest,*this,0,aCount);
|
||||
|
||||
return aDest.mLength;
|
||||
}
|
||||
@@ -1301,7 +1322,7 @@ PRUint32 nsString::Mid(nsString& aDest,PRUint32 anOffset,PRInt32 aCount) const{
|
||||
if(aCount<0)
|
||||
aCount=mLength;
|
||||
else aCount=MinInt(aCount,mLength);
|
||||
nsStr::Assign(aDest,*this,anOffset,aCount);
|
||||
nsStr::StrAssign(aDest,*this,anOffset,aCount);
|
||||
|
||||
return aDest.mLength;
|
||||
}
|
||||
@@ -1320,20 +1341,6 @@ PRUint32 nsString::Right(nsString& aDest,PRInt32 aCount) const{
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This method inserts n chars from given string into this
|
||||
* string at str[anOffset].
|
||||
*
|
||||
* @update gess 4/1/98
|
||||
* @param aString -- source String to be inserted into this
|
||||
* @param anOffset -- insertion position within this str
|
||||
* @param aCount -- number of chars to be copied from aCopy
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Insert(const nsString& aCopy,PRUint32 anOffset,PRInt32 aCount) {
|
||||
nsStr::Insert(*this,anOffset,aCopy,0,aCount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a char* into this string at a specified offset.
|
||||
@@ -1346,7 +1353,7 @@ nsString& nsString::Insert(const nsString& aCopy,PRUint32 anOffset,PRInt32 aCoun
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Insert(const char* aCString,PRUint32 anOffset,PRInt32 aCount){
|
||||
void nsString::InsertWithConversion(const char* aCString,PRUint32 anOffset,PRInt32 aCount){
|
||||
if(aCString && aCount){
|
||||
nsStr temp;
|
||||
nsStr::Initialize(temp,eOneByte);
|
||||
@@ -1368,10 +1375,25 @@ nsString& nsString::Insert(const char* aCString,PRUint32 anOffset,PRInt32 aCount
|
||||
else aCount=temp.mLength=nsCRT::strlen(aCString);
|
||||
|
||||
if(0<aCount){
|
||||
nsStr::Insert(*this,anOffset,temp,0,aCount);
|
||||
StrInsert(*this,anOffset,temp,0,aCount);
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/*
|
||||
* This method inserts n chars from given string into this
|
||||
* string at str[anOffset].
|
||||
*
|
||||
* @update gess 4/1/98
|
||||
* @param aString -- source String to be inserted into this
|
||||
* @param anOffset -- insertion position within this str
|
||||
* @param aCount -- number of chars to be copied from aCopy
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Insert(const nsString& aCopy,PRUint32 anOffset,PRInt32 aCount) {
|
||||
StrInsert(*this,anOffset,aCopy,0,aCount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@@ -1408,7 +1430,7 @@ nsString& nsString::Insert(const PRUnichar* aString,PRUint32 anOffset,PRInt32 aC
|
||||
else aCount=temp.mLength=nsCRT::strlen(aString);
|
||||
|
||||
if(0<aCount){
|
||||
nsStr::Insert(*this,anOffset,temp,0,aCount);
|
||||
StrInsert(*this,anOffset,temp,0,aCount);
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
@@ -1431,9 +1453,10 @@ nsString& nsString::Insert(PRUnichar aChar,PRUint32 anOffset){
|
||||
nsStr::Initialize(temp,eTwoByte);
|
||||
temp.mUStr=theBuffer;
|
||||
temp.mLength=1;
|
||||
nsStr::Insert(*this,anOffset,temp,0,1);
|
||||
StrInsert(*this,anOffset,temp,0,1);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This method is used to cut characters in this string
|
||||
@@ -2224,7 +2247,7 @@ void nsString::DebugDump(void) const {
|
||||
nsCAutoString temp;
|
||||
|
||||
if(eTwoByte==mCharSize) {
|
||||
nsStr::Assign(temp, *this, 0, mLength);
|
||||
nsStr::StrAssign(temp, *this, 0, mLength);
|
||||
theBuffer=temp.GetBuffer();
|
||||
}
|
||||
|
||||
@@ -2245,28 +2268,17 @@ void nsString::DebugDump(void) const {
|
||||
*
|
||||
*/
|
||||
nsAutoString::nsAutoString() : nsString() {
|
||||
nsStr::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy construct from ascii c-string
|
||||
* @param aCString is a ptr to a 1-byte cstr
|
||||
* @param aLength tells us how many chars to copy from aCString
|
||||
*/
|
||||
nsAutoString::nsAutoString(const char* aCString,PRInt32 aLength) : nsString() {
|
||||
nsStr::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aCString,aLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy construct from uni-string
|
||||
* @param aString is a ptr to a unistr
|
||||
* @param aLength tells us how many chars to copy from aString
|
||||
*/
|
||||
nsAutoString::nsAutoString(const PRUnichar* aString,PRInt32 aLength) : nsString() {
|
||||
nsStr::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aString,aLength);
|
||||
}
|
||||
@@ -2277,31 +2289,44 @@ nsAutoString::nsAutoString(const PRUnichar* aString,PRInt32 aLength) : nsString(
|
||||
*/
|
||||
nsAutoString::nsAutoString(const CBufDescriptor& aBuffer) : nsString() {
|
||||
if(!aBuffer.mBuffer) {
|
||||
nsStr::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
}
|
||||
else {
|
||||
nsStr::Initialize(*this,aBuffer.mBuffer,aBuffer.mCapacity,aBuffer.mLength,aBuffer.mCharSize,!aBuffer.mStackBased);
|
||||
Initialize(*this,aBuffer.mBuffer,aBuffer.mCapacity,aBuffer.mLength,aBuffer.mCharSize,!aBuffer.mStackBased);
|
||||
}
|
||||
if(!aBuffer.mIsConst)
|
||||
AddNullTerminator(*this);
|
||||
}
|
||||
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* Copy construct from ascii c-string
|
||||
* @param aCString is a ptr to a 1-byte cstr
|
||||
* @param aLength tells us how many chars to copy from aCString
|
||||
*/
|
||||
nsAutoString::nsAutoString(const char* aCString,PRInt32 aLength) : nsString() {
|
||||
Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aCString,aLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy construct from an nsStr
|
||||
* @param
|
||||
*/
|
||||
nsAutoString::nsAutoString(const nsStr& aString) : nsString() {
|
||||
nsStr::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aString);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Default copy constructor
|
||||
*/
|
||||
nsAutoString::nsAutoString(const nsAutoString& aString) : nsString() {
|
||||
nsStr::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aString);
|
||||
}
|
||||
@@ -2312,7 +2337,7 @@ nsAutoString::nsAutoString(const nsAutoString& aString) : nsString() {
|
||||
* @param
|
||||
*/
|
||||
nsAutoString::nsAutoString(PRUnichar aChar) : nsString(){
|
||||
nsStr::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aChar);
|
||||
}
|
||||
|
||||
@@ -65,38 +65,36 @@ class NS_COM nsString :
|
||||
#endif
|
||||
public nsStr {
|
||||
|
||||
#ifdef NEW_STRING_APIS
|
||||
protected:
|
||||
#ifdef NEW_STRING_APIS
|
||||
virtual const PRUnichar* GetReadableFragment( nsReadableFragment<PRUnichar>&, nsFragmentRequest, PRUint32 ) const;
|
||||
virtual PRUnichar* GetWritableFragment( nsWritableFragment<PRUnichar>&, nsFragmentRequest, PRUint32 );
|
||||
|
||||
public:
|
||||
nsString( const nsAReadableString& );
|
||||
|
||||
#ifdef HAVE_AMBIGUITY_RESOLVING_CPP_USING
|
||||
using nsAWritableString::Append;
|
||||
using nsAWritableString::Insert;
|
||||
#else
|
||||
virtual void Append( const nsAReadableString& aReadable ) {
|
||||
nsAWritableString::Append(aReadable);
|
||||
}
|
||||
|
||||
virtual void Insert( const nsAReadableString& aReadable, PRUint32 atPosition ) {
|
||||
nsAWritableString::Insert(aReadable, atPosition);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
public:
|
||||
void AppendChar( PRUnichar );
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
nsString();
|
||||
|
||||
/**
|
||||
* This is our copy constructor
|
||||
* @param reference to another nsString
|
||||
*/
|
||||
nsString(const nsString& aString);
|
||||
|
||||
#ifdef NEW_STRING_APIS
|
||||
nsString(const nsAReadableString&);
|
||||
|
||||
nsString(const PRUnichar*);
|
||||
nsString(const PRUnichar*, PRInt32);
|
||||
#else
|
||||
/**
|
||||
* This constructor accepts a unichar string
|
||||
* @param aCString is a ptr to a 2-byte cstr
|
||||
*/
|
||||
nsString(const PRUnichar* aString,PRInt32 aCount=-1);
|
||||
|
||||
/**
|
||||
* This constructor accepts an isolatin string
|
||||
@@ -104,23 +102,13 @@ public:
|
||||
*/
|
||||
nsString(const char* aCString,PRInt32 aCount=-1);
|
||||
|
||||
/**
|
||||
* This constructor accepts a unichar string
|
||||
* @param aCString is a ptr to a 2-byte cstr
|
||||
*/
|
||||
nsString(const PRUnichar* aString,PRInt32 aCount=-1);
|
||||
|
||||
/**
|
||||
* This is a copy constructor that accepts an nsStr
|
||||
* @param reference to another nsString
|
||||
*/
|
||||
nsString(const nsStr&);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This is our copy constructor
|
||||
* @param reference to another nsString
|
||||
*/
|
||||
nsString(const nsString& aString);
|
||||
|
||||
/**
|
||||
* This constructor takes a subsumestr
|
||||
@@ -440,94 +428,52 @@ public:
|
||||
|
||||
* @return this
|
||||
*/
|
||||
|
||||
void AssignWithConversion(char);
|
||||
#ifdef NEW_STRING_APIS
|
||||
#ifdef HAVE_AMBIGUITY_RESOLVING_CPP_USING
|
||||
using nsAWritableString::Assign;
|
||||
void AssignWithConversion(const char*);
|
||||
void AssignWithConversion(const char*, PRInt32);
|
||||
#else
|
||||
virtual void Assign( const nsAReadableString& aReadable ) {
|
||||
nsAWritableString::Assign(aReadable);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
void AssignWithConversion(const char*, PRInt32=-1);
|
||||
|
||||
nsString& Assign(const PRUnichar* aString,PRInt32 aCount=-1);
|
||||
nsString& Assign(PRUnichar aChar);
|
||||
|
||||
void AssignWithConversion(const char*, PRInt32=-1);
|
||||
void AssignWithConversion(char);
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsString& Assign(const nsStr& aString,PRInt32 aCount=-1);
|
||||
nsString& Assign(const char* aString,PRInt32 aCount=-1) { AssignWithConversion(aString, aCount); return *this; }
|
||||
nsString& Assign(char aChar) { AssignWithConversion(aChar); return *this; }
|
||||
#endif
|
||||
|
||||
nsString& Assign(const char* aString,PRInt32 aCount=-1) { AssignWithConversion(aString, aCount); return *this; }
|
||||
nsString& Assign(char aChar) { AssignWithConversion(aChar); return *this; }
|
||||
|
||||
/**
|
||||
* Functionally equivalent to assign or operator=
|
||||
*
|
||||
*/
|
||||
nsString& SetString(const char* aString,PRInt32 aLength=-1) {AssignWithConversion(aString, aLength); return *this;}
|
||||
#ifdef NEW_STRING_APIS
|
||||
nsString& SetString(const nsString& aString,PRInt32 aLength=-1) {Assign(aString); return *this;}
|
||||
nsString& SetString(const PRUnichar* aString,PRInt32 aLength=-1) {Assign(aString); return *this;}
|
||||
#else
|
||||
nsString& SetString(const nsString& aString,PRInt32 aLength=-1) {return Assign(aString, aLength);}
|
||||
nsString& SetString(const PRUnichar* aString,PRInt32 aLength=-1) {return Assign(aString, aLength);}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* here come a bunch of assignment operators...
|
||||
* @param aString: string to be added to this
|
||||
* @return this
|
||||
*/
|
||||
#ifdef NEW_STRING_APIS
|
||||
#ifdef HAVE_AMBIGUITY_RESOLVING_CPP_USING
|
||||
using nsAWritableString::operator=;
|
||||
#else
|
||||
nsString& operator=( const nsAReadableString& aReadable ) { nsAWritableString::operator=(aReadable); return *this; }
|
||||
#endif
|
||||
#endif
|
||||
nsString& operator=(PRUnichar aChar) {return Assign(aChar);}
|
||||
nsString& operator=(char aChar) {AssignWithConversion(aChar); return *this;}
|
||||
nsString& operator=(const char* aCString) {AssignWithConversion(aCString); return *this;}
|
||||
nsString& operator=(PRUnichar aChar) {Assign(aChar); return *this;}
|
||||
nsString& operator=(char aChar) {AssignWithConversion(aChar); return *this;}
|
||||
nsString& operator=(const char* aCString) {AssignWithConversion(aCString); return *this;}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsString& operator=(const nsString& aString) {return Assign(aString);}
|
||||
nsString& operator=(const nsStr& aString) {return Assign(aString);}
|
||||
nsString& operator=(const nsString& aString) {return Assign(aString);}
|
||||
nsString& operator=(const nsStr& aString) {return Assign(aString);}
|
||||
nsString& operator=(const PRUnichar* aString) {return Assign(aString);}
|
||||
#endif
|
||||
|
||||
// Yes, I know this makes assignment from a |nsSubsumeString| not do the special thing
|
||||
// |nsSubsumeString| needs to go away
|
||||
#ifdef AIX
|
||||
nsString& operator=(const nsSubsumeStr& aSubsumeString); // AIX requires a const here
|
||||
#else
|
||||
nsString& operator=(nsSubsumeStr& aSubsumeString);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Here's a bunch of methods that append varying types...
|
||||
* @param various...
|
||||
* @return this
|
||||
*/
|
||||
#ifdef NEW_STRING_APIS
|
||||
#ifdef HAVE_AMBIGUITY_RESOLVING_CPP_USING
|
||||
using nsAWritableString::operator+=;
|
||||
#else
|
||||
nsString& operator+=( const nsAReadableString& aReadable ) { nsAWritableString::operator+=(aReadable); return *this; }
|
||||
#endif
|
||||
#endif
|
||||
nsString& operator+=(const char* aCString) {return Append(aCString);}
|
||||
nsString& operator+=(const char aChar) {
|
||||
return Append((PRUnichar) (unsigned char)aChar);
|
||||
}
|
||||
nsString& operator+=(const PRUnichar aChar){return Append(aChar);}
|
||||
nsString& operator+=(const int anInt){return Append(anInt,10);}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsString& operator+=(const nsStr& aString){return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsString& operator+=(const nsString& aString){return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsString& operator+=(const PRUnichar* aUCString) {return Append(aUCString);}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Appends n characters from given string to this,
|
||||
* This version computes the length of your given string
|
||||
@@ -535,9 +481,16 @@ public:
|
||||
* @param aString is the source to be appended to this
|
||||
* @return number of chars copied
|
||||
*/
|
||||
nsString& Append(const nsStr& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsString& Append(const nsString& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
|
||||
|
||||
void AppendWithConversion(PRInt32, PRInt32=10); //radix=8,10 or 16
|
||||
void AppendWithConversion(float);
|
||||
void AppendWithConversion(char);
|
||||
|
||||
#ifdef NEW_STRING_APIS
|
||||
void AppendWithConversion(const char*);
|
||||
void AppendWithConversion(const char*, PRInt32);
|
||||
#else
|
||||
void AppendWithConversion(const char*, PRInt32=-1);
|
||||
|
||||
/*
|
||||
* Appends n characters from given string to this,
|
||||
@@ -548,13 +501,32 @@ public:
|
||||
* @return number of chars copied
|
||||
*/
|
||||
nsString& Append(const nsStr& aString,PRInt32 aCount);
|
||||
nsString& Append(const nsStr& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsString& Append(const nsString& aString,PRInt32 aCount);
|
||||
nsString& Append(const char* aString,PRInt32 aCount=-1);
|
||||
nsString& Append(const nsString& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
|
||||
nsString& Append(const PRUnichar* aString,PRInt32 aCount=-1);
|
||||
nsString& Append(char aChar);
|
||||
nsString& Append(PRUnichar aChar);
|
||||
nsString& Append(PRInt32 aInteger,PRInt32 aRadix=10); //radix=8,10 or 16
|
||||
nsString& Append(float aFloat);
|
||||
|
||||
nsString& Append(const char* aString,PRInt32 aCount=-1) {AppendWithConversion(aString,aCount); return *this;}
|
||||
nsString& Append(char aChar) {AppendWithConversion(aChar); return *this;}
|
||||
nsString& Append(PRInt32 aInteger,PRInt32 aRadix=10) {AppendWithConversion(aInteger,aRadix); return *this;}
|
||||
nsString& Append(float aFloat) {AppendWithConversion(aFloat); return *this;}
|
||||
|
||||
/**
|
||||
* Here's a bunch of methods that append varying types...
|
||||
* @param various...
|
||||
* @return this
|
||||
*/
|
||||
nsString& operator+=(const char* aCString) {return Append(aCString);}
|
||||
nsString& operator+=(const char aChar) {return Append((PRUnichar) (unsigned char)aChar);}
|
||||
nsString& operator+=(const PRUnichar aChar) {return Append(aChar);}
|
||||
nsString& operator+=(const int anInt) {return Append(anInt,10);}
|
||||
|
||||
nsString& operator+=(const nsStr& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsString& operator+=(const nsString& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsString& operator+=(const PRUnichar* aUCString) {return Append(aUCString);}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copies n characters from this string to given string,
|
||||
@@ -590,6 +562,10 @@ public:
|
||||
*/
|
||||
PRUint32 Right(nsString& aCopy,PRInt32 aCount) const;
|
||||
|
||||
|
||||
//void InsertWithConversion(char);
|
||||
void InsertWithConversion(const char*, PRUint32, PRInt32=-1);
|
||||
#ifndef NEW_STRING_APIS
|
||||
/*
|
||||
* This method inserts n chars from given string into this
|
||||
* string at str[anOffset].
|
||||
@@ -611,7 +587,7 @@ public:
|
||||
* @param anOffset is insert pos in str
|
||||
* @return the number of chars inserted into this string
|
||||
*/
|
||||
nsString& Insert(const char* aChar,PRUint32 anOffset,PRInt32 aCount=-1);
|
||||
nsString& Insert(const char* aChar,PRUint32 anOffset,PRInt32 aCount=-1) {InsertWithConversion(aChar, anOffset, aCount); return *this;}
|
||||
nsString& Insert(const PRUnichar* aChar,PRUint32 anOffset,PRInt32 aCount=-1);
|
||||
|
||||
/**
|
||||
@@ -622,9 +598,12 @@ public:
|
||||
* @param anOffset is insert pos in str
|
||||
* @return the number of chars inserted into this string
|
||||
*/
|
||||
//nsString& Insert(char aChar,PRUint32 anOffset);
|
||||
//nsString& Insert(char aChar,PRUint32 anOffset) {InsertWithConversion(aChar,anOffset); return *this;}
|
||||
nsString& Insert(PRUnichar aChar,PRUint32 anOffset);
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/*
|
||||
* This method is used to cut characters in this string
|
||||
* starting at anOffset, continuing for aCount chars.
|
||||
@@ -633,7 +612,6 @@ public:
|
||||
* @param aCount -- number of chars to be cut
|
||||
* @return *this
|
||||
*/
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsString& Cut(PRUint32 anOffset,PRInt32 aCount);
|
||||
#endif
|
||||
|
||||
@@ -797,6 +775,7 @@ public:
|
||||
PRBool operator>=(const char* aString) const;
|
||||
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.
|
||||
@@ -876,13 +855,17 @@ extern NS_COM int fputs(const nsString& aString, FILE* out);
|
||||
class NS_COM nsAutoString : public nsString {
|
||||
public:
|
||||
|
||||
virtual ~nsAutoString();
|
||||
nsAutoString();
|
||||
nsAutoString(const char* aCString,PRInt32 aLength=-1);
|
||||
nsAutoString(const PRUnichar* aString,PRInt32 aLength=-1);
|
||||
|
||||
nsAutoString(const CBufDescriptor& aBuffer);
|
||||
nsAutoString(const nsStr& aString);
|
||||
nsAutoString(const nsAutoString& aString);
|
||||
nsAutoString(const PRUnichar* aString,PRInt32 aLength=-1);
|
||||
nsAutoString(PRUnichar aChar);
|
||||
nsAutoString(const CBufDescriptor& aBuffer);
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsAutoString(const char* aCString,PRInt32 aLength=-1);
|
||||
nsAutoString(const nsStr& aString);
|
||||
#endif
|
||||
|
||||
#ifdef AIX
|
||||
nsAutoString(const nsSubsumeStr& aSubsumeStr); // AIX requires a const
|
||||
@@ -890,8 +873,6 @@ public:
|
||||
nsAutoString(nsSubsumeStr& aSubsumeStr);
|
||||
#endif // AIX
|
||||
|
||||
nsAutoString(PRUnichar aChar);
|
||||
virtual ~nsAutoString();
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsAutoString& operator=(const nsStr& aString) {nsString::Assign(aString); return *this;}
|
||||
|
||||
@@ -120,7 +120,7 @@ PRBool nsStr::GrowCapacity(nsStr& aDest,PRUint32 aNewLength) {
|
||||
result=EnsureCapacity(theTempStr,aNewLength);
|
||||
if(result) {
|
||||
if(aDest.mLength) {
|
||||
Append(theTempStr,aDest,0,aDest.mLength);
|
||||
StrAppend(theTempStr,aDest,0,aDest.mLength);
|
||||
}
|
||||
Free(aDest);
|
||||
aDest.mStr = theTempStr.mStr;
|
||||
@@ -140,10 +140,10 @@ PRBool nsStr::GrowCapacity(nsStr& aDest,PRUint32 aNewLength) {
|
||||
* @param aSource is where chars are copied from
|
||||
* @param aCount is the number of chars copied from aSource
|
||||
*/
|
||||
void nsStr::Assign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount){
|
||||
void nsStr::StrAssign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount){
|
||||
if(&aDest!=&aSource){
|
||||
Truncate(aDest,0);
|
||||
Append(aDest,aSource,anOffset,aCount);
|
||||
StrAppend(aDest,aSource,anOffset,aCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ void nsStr::Assign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 a
|
||||
* @param aSource is where char are copied from
|
||||
* @aCount is the number of bytes to be copied
|
||||
*/
|
||||
void nsStr::Append(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount){
|
||||
void nsStr::StrAppend(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount){
|
||||
if(anOffset<aSource.mLength){
|
||||
PRUint32 theRealLen=(aCount<0) ? aSource.mLength : MinInt(aCount,aSource.mLength);
|
||||
PRUint32 theLength=(anOffset+theRealLen<aSource.mLength) ? theRealLen : (aSource.mLength-anOffset);
|
||||
@@ -188,7 +188,7 @@ void nsStr::Append(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 a
|
||||
* @param aSrcOffset is where in aSource chars are copied from
|
||||
* @param aCount is the number of chars from aSource to be inserted into aDest
|
||||
*/
|
||||
void nsStr::Insert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount){
|
||||
void nsStr::StrInsert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount){
|
||||
//there are a few cases for insert:
|
||||
// 1. You're inserting chars into an empty string (assign)
|
||||
// 2. You're inserting onto the end of a string (append)
|
||||
@@ -211,14 +211,14 @@ void nsStr::Insert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUin
|
||||
|
||||
if(isBigEnough) {
|
||||
if(aDestOffset) {
|
||||
Append(theTempStr,aDest,0,aDestOffset); //first copy leftmost data...
|
||||
StrAppend(theTempStr,aDest,0,aDestOffset); //first copy leftmost data...
|
||||
}
|
||||
|
||||
Append(theTempStr,aSource,0,aSource.mLength); //next copy inserted (new) data
|
||||
StrAppend(theTempStr,aSource,0,aSource.mLength); //next copy inserted (new) data
|
||||
|
||||
PRUint32 theRemains=aDest.mLength-aDestOffset;
|
||||
if(theRemains) {
|
||||
Append(theTempStr,aDest,aDestOffset,theRemains); //next copy rightmost data
|
||||
StrAppend(theTempStr,aDest,aDestOffset,theRemains); //next copy rightmost data
|
||||
}
|
||||
|
||||
Free(aDest);
|
||||
@@ -245,9 +245,9 @@ void nsStr::Insert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUin
|
||||
}//if
|
||||
//else nothing to do!
|
||||
}
|
||||
else Append(aDest,aSource,0,aCount);
|
||||
else StrAppend(aDest,aSource,0,aCount);
|
||||
}
|
||||
else Append(aDest,aSource,0,aCount);
|
||||
else StrAppend(aDest,aSource,0,aCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -833,7 +833,7 @@ nsStringInfo::nsStringInfo(nsStr& str)
|
||||
: mCount(0)
|
||||
{
|
||||
nsStr::Initialize(mStr, str.mCharSize);
|
||||
nsStr::Assign(mStr, str, 0, -1);
|
||||
nsStr::StrAssign(mStr, str, 0, -1);
|
||||
// nsStr::Print(mStr, stdout);
|
||||
// fputc('\n', stdout);
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ struct NS_COM nsStr {
|
||||
* @param aCount tells us the (max) # of chars to copy
|
||||
* @param anAgent is the allocator to be used for alloc/free operations
|
||||
*/
|
||||
static void Append(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount);
|
||||
static void StrAppend(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount);
|
||||
|
||||
/**
|
||||
* These methods are used to assign contents of a source string to dest string
|
||||
@@ -295,7 +295,7 @@ struct NS_COM nsStr {
|
||||
* @param aCount tells us the (max) # of chars to copy
|
||||
* @param anAgent is the allocator to be used for alloc/free operations
|
||||
*/
|
||||
static void Assign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount);
|
||||
static void StrAssign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount);
|
||||
|
||||
/**
|
||||
* These methods are used to insert content from source string to the dest nsStr
|
||||
@@ -308,7 +308,19 @@ struct NS_COM nsStr {
|
||||
* @param aCount tells us the (max) # of chars to insert
|
||||
* @param anAgent is the allocator to be used for alloc/free operations
|
||||
*/
|
||||
static void Insert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount);
|
||||
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.
|
||||
|
||||
@@ -53,7 +53,7 @@ static void CSubsume(nsStr& aDest,nsStr& aSource){
|
||||
aSource.mStr=0;
|
||||
}
|
||||
else{
|
||||
nsStr::Assign(aDest,aSource,0,aSource.mLength);
|
||||
nsStr::StrAssign(aDest,aSource,0,aSource.mLength);
|
||||
}
|
||||
}
|
||||
else nsStr::Truncate(aDest,0);
|
||||
@@ -64,9 +64,16 @@ static void CSubsume(nsStr& aDest,nsStr& aSource){
|
||||
* Default constructor.
|
||||
*/
|
||||
nsCString::nsCString() {
|
||||
nsStr::Initialize(*this,eOneByte);
|
||||
Initialize(*this,eOneByte);
|
||||
}
|
||||
|
||||
#ifdef NEW_STRING_APIS
|
||||
nsCString::nsCString(const char* aCString) {
|
||||
Initialize(*this,eOneByte);
|
||||
Assign(aCString);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This constructor accepts an ascii string
|
||||
* @update gess 1/4/99
|
||||
@@ -74,10 +81,11 @@ nsCString::nsCString() {
|
||||
* @param aLength tells us how many chars to copy from given CString
|
||||
*/
|
||||
nsCString::nsCString(const char* aCString,PRInt32 aLength) {
|
||||
nsStr::Initialize(*this,eOneByte);
|
||||
Initialize(*this,eOneByte);
|
||||
Assign(aCString,aLength);
|
||||
}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* This constructor accepts a unicode string
|
||||
* @update gess 1/4/99
|
||||
@@ -85,7 +93,7 @@ nsCString::nsCString(const char* aCString,PRInt32 aLength) {
|
||||
* @param aLength tells us how many chars to copy from given aString
|
||||
*/
|
||||
nsCString::nsCString(const PRUnichar* aString,PRInt32 aLength) {
|
||||
nsStr::Initialize(*this,eOneByte);
|
||||
Initialize(*this,eOneByte);
|
||||
AssignWithConversion(aString,aLength);
|
||||
}
|
||||
|
||||
@@ -95,9 +103,10 @@ nsCString::nsCString(const PRUnichar* aString,PRInt32 aLength) {
|
||||
* @param reference to another nsCString
|
||||
*/
|
||||
nsCString::nsCString(const nsStr &aString) {
|
||||
nsStr::Initialize(*this,eOneByte);
|
||||
nsStr::Assign(*this,aString,0,aString.mLength);
|
||||
Initialize(*this,eOneByte);
|
||||
StrAssign(*this,aString,0,aString.mLength);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This is our copy constructor
|
||||
@@ -105,8 +114,8 @@ nsCString::nsCString(const nsStr &aString) {
|
||||
* @param reference to another nsCString
|
||||
*/
|
||||
nsCString::nsCString(const nsCString& aString) {
|
||||
nsStr::Initialize(*this,aString.mCharSize);
|
||||
nsStr::Assign(*this,aString,0,aString.mLength);
|
||||
Initialize(*this,aString.mCharSize);
|
||||
StrAssign(*this,aString,0,aString.mLength);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,7 +131,7 @@ nsCString::nsCString(nsSubsumeCStr& aSubsumeStr) {
|
||||
* Destructor
|
||||
*/
|
||||
nsCString::~nsCString() {
|
||||
nsStr::Destroy(*this);
|
||||
Destroy(*this);
|
||||
}
|
||||
|
||||
#ifdef NEW_STRING_APIS
|
||||
@@ -157,15 +166,11 @@ char* nsCString::GetWritableFragment( nsWritableFragment<char>& aFragment, nsFra
|
||||
}
|
||||
|
||||
nsCString::nsCString( const nsAReadableCString& aReadable ) {
|
||||
nsStr::Initialize(*this,eOneByte);
|
||||
Initialize(*this,eOneByte);
|
||||
Assign(aReadable);
|
||||
}
|
||||
#endif
|
||||
|
||||
void nsCString::AppendChar( char aChar ) {
|
||||
Append(aChar);
|
||||
}
|
||||
|
||||
void nsCString::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const {
|
||||
if (aResult) {
|
||||
*aResult = sizeof(*this) + mCapacity * mCharSize;
|
||||
@@ -271,7 +276,7 @@ PRBool nsCString::SetCharAt(PRUnichar aChar,PRUint32 anIndex){
|
||||
*/
|
||||
nsSubsumeCStr nsCString::operator+(const nsCString& aString){
|
||||
nsCString temp(*this); //make a temp string the same size as this...
|
||||
nsStr::Append(temp,aString,0,aString.mLength);
|
||||
nsStr::StrAppend(temp,aString,0,aString.mLength);
|
||||
return nsSubsumeCStr(temp);
|
||||
}
|
||||
|
||||
@@ -521,7 +526,7 @@ nsCString& nsCString::ReplaceSubstring(const nsCString& aTarget,const nsCString&
|
||||
//this is the worst case: the newvalue is larger than the substr it's replacing
|
||||
//so we have to insert some characters...
|
||||
PRInt32 theInsLen=aNewValue.mLength-aTarget.mLength;
|
||||
nsStr::Insert(*this,theIndex,aNewValue,0,theInsLen);
|
||||
StrInsert(*this,theIndex,aNewValue,0,theInsLen);
|
||||
}
|
||||
nsStr::Overwrite(*this,aNewValue,theIndex);
|
||||
}
|
||||
@@ -841,11 +846,10 @@ nsCString& nsCString::Assign(const nsStr& aString,PRInt32 aCount) {
|
||||
aCount=aString.mLength;
|
||||
else aCount=MinInt(aCount,aString.mLength);
|
||||
|
||||
nsStr::Assign(*this,aString,0,aCount);
|
||||
StrAssign(*this,aString,0,aCount);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* assign given char* to this string
|
||||
@@ -864,55 +868,6 @@ nsCString& nsCString::Assign(const char* aCString,PRInt32 aCount) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* assign given unichar* to this string
|
||||
* @update gess 01/04/99
|
||||
* @param aCString: buffer to be assigned to this
|
||||
* @param aCount -- length of given buffer or -1 if you want me to compute length.
|
||||
* NOTE: IFF you pass -1 as aCount, then your buffer must be null terminated.
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
void nsCString::AssignWithConversion(const PRUnichar* aString,PRInt32 aCount) {
|
||||
nsStr::Truncate(*this,0);
|
||||
|
||||
if(aString && aCount){
|
||||
nsStr temp;
|
||||
Initialize(temp,eTwoByte);
|
||||
temp.mUStr=(PRUnichar*)aString;
|
||||
|
||||
if(0<aCount) {
|
||||
temp.mLength=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,temp.mLength);
|
||||
if(kNotFound<len) {
|
||||
NS_WARNING(kPossibleNull);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
else aCount=temp.mLength=nsCRT::strlen(aString);
|
||||
|
||||
if(0<aCount)
|
||||
nsStr::Append(*this,temp,0,aCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* assign given unichar to this string
|
||||
* @update gess 01/04/99
|
||||
* @param aChar: char to be assignd to this
|
||||
* @return this
|
||||
*/
|
||||
void nsCString::AssignWithConversion(PRUnichar aChar) {
|
||||
nsStr::Truncate(*this,0);
|
||||
Append(aChar);
|
||||
}
|
||||
|
||||
/**
|
||||
* assign given char to this string
|
||||
* @update gess 01/04/99
|
||||
@@ -942,7 +897,58 @@ nsCString& nsCString::operator=(nsSubsumeCStr& aSubsumeString) {
|
||||
#endif // AIX
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* assign given unichar* to this string
|
||||
* @update gess 01/04/99
|
||||
* @param aCString: buffer to be assigned to this
|
||||
* @param aCount -- length of given buffer or -1 if you want me to compute length.
|
||||
* NOTE: IFF you pass -1 as aCount, then your buffer must be null terminated.
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
void nsCString::AssignWithConversion(const PRUnichar* aString,PRInt32 aCount) {
|
||||
nsStr::Truncate(*this,0);
|
||||
|
||||
if(aString && aCount){
|
||||
nsStr temp;
|
||||
nsStr::Initialize(temp,eTwoByte);
|
||||
temp.mUStr=(PRUnichar*)aString;
|
||||
|
||||
if(0<aCount) {
|
||||
temp.mLength=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,temp.mLength);
|
||||
if(kNotFound<len) {
|
||||
NS_WARNING(kPossibleNull);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
else aCount=temp.mLength=nsCRT::strlen(aString);
|
||||
|
||||
if(0<aCount)
|
||||
StrAppend(*this,temp,0,aCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* assign given unichar to this string
|
||||
* @update gess 01/04/99
|
||||
* @param aChar: char to be assignd to this
|
||||
* @return this
|
||||
*/
|
||||
void nsCString::AssignWithConversion(PRUnichar aChar) {
|
||||
nsStr::Truncate(*this,0);
|
||||
Append(aChar);
|
||||
}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* append given string to this string
|
||||
* @update gess 01/04/99
|
||||
@@ -954,7 +960,7 @@ nsCString& nsCString::Append(const nsCString& aString,PRInt32 aCount) {
|
||||
aCount=aString.mLength;
|
||||
else aCount=MinInt(aCount,aString.mLength);
|
||||
if(0<aCount)
|
||||
nsStr::Append(*this,aString,0,aCount);
|
||||
StrAppend(*this,aString,0,aCount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -971,7 +977,7 @@ nsCString& nsCString::Append(const nsStr& aString,PRInt32 aCount) {
|
||||
else aCount=MinInt(aCount,aString.mLength);
|
||||
|
||||
if(0<aCount)
|
||||
nsStr::Append(*this,aString,0,aCount);
|
||||
StrAppend(*this,aString,0,aCount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -987,7 +993,7 @@ nsCString& nsCString::Append(const nsStr& aString,PRInt32 aCount) {
|
||||
nsCString& nsCString::Append(const char* aCString,PRInt32 aCount) {
|
||||
if(aCString){
|
||||
nsStr temp;
|
||||
Initialize(temp,eOneByte);
|
||||
nsStr::Initialize(temp,eOneByte);
|
||||
temp.mStr=(char*)aCString;
|
||||
|
||||
if(0<aCount) {
|
||||
@@ -996,30 +1002,11 @@ nsCString& nsCString::Append(const char* aCString,PRInt32 aCount) {
|
||||
else aCount=temp.mLength=nsCRT::strlen(aCString);
|
||||
|
||||
if(0<aCount)
|
||||
nsStr::Append(*this,temp,0,aCount);
|
||||
StrAppend(*this,temp,0,aCount);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* append given char to this string
|
||||
* @update gess 01/04/99
|
||||
* @param aChar: char to be appended to this
|
||||
* @return this
|
||||
*/
|
||||
nsCString& nsCString::Append(PRUnichar aChar) {
|
||||
PRUnichar buf[2]={0,0};
|
||||
buf[0]=aChar;
|
||||
|
||||
nsStr temp;
|
||||
Initialize(temp,eTwoByte);
|
||||
temp.mUStr=buf;
|
||||
temp.mLength=1;
|
||||
nsStr::Append(*this,temp,0,1);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* append given unichar to this string
|
||||
* @update gess 01/04/99
|
||||
@@ -1031,12 +1018,30 @@ nsCString& nsCString::Append(char aChar) {
|
||||
buf[0]=aChar;
|
||||
|
||||
nsStr temp;
|
||||
Initialize(temp,eOneByte);
|
||||
nsStr::Initialize(temp,eOneByte);
|
||||
temp.mStr=buf;
|
||||
temp.mLength=1;
|
||||
nsStr::Append(*this,temp,0,1);
|
||||
StrAppend(*this,temp,0,1);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* append given char to this string
|
||||
* @update gess 01/04/99
|
||||
* @param aChar: char to be appended to this
|
||||
* @return this
|
||||
*/
|
||||
void nsCString::AppendWithConversion(PRUnichar aChar) {
|
||||
PRUnichar buf[2]={0,0};
|
||||
buf[0]=aChar;
|
||||
|
||||
nsStr temp;
|
||||
nsStr::Initialize(temp,eTwoByte);
|
||||
temp.mUStr=buf;
|
||||
temp.mLength=1;
|
||||
StrAppend(*this,temp,0,1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Append the given integer to this string
|
||||
@@ -1045,7 +1050,7 @@ nsCString& nsCString::Append(char aChar) {
|
||||
* @param aRadix:
|
||||
* @return
|
||||
*/
|
||||
nsCString& nsCString::Append(PRInt32 anInteger,PRInt32 aRadix) {
|
||||
void nsCString::AppendWithConversion(PRInt32 anInteger,PRInt32 aRadix) {
|
||||
|
||||
PRUint32 theInt=(PRUint32)anInteger;
|
||||
|
||||
@@ -1073,7 +1078,7 @@ nsCString& nsCString::Append(PRInt32 anInteger,PRInt32 aRadix) {
|
||||
theInt-=theDiv*mask1;
|
||||
mask1/=aRadix;
|
||||
}
|
||||
return Append(buf);
|
||||
Append(buf);
|
||||
}
|
||||
|
||||
|
||||
@@ -1083,12 +1088,12 @@ nsCString& nsCString::Append(PRInt32 anInteger,PRInt32 aRadix) {
|
||||
* @param aFloat:
|
||||
* @return
|
||||
*/
|
||||
nsCString& nsCString::Append(float aFloat){
|
||||
void nsCString::AppendWithConversion(float aFloat){
|
||||
char buf[40];
|
||||
// *** XX UNCOMMENT THIS LINE
|
||||
//PR_snprintf(buf, sizeof(buf), "%g", aFloat);
|
||||
sprintf(buf,"%g",aFloat);
|
||||
return Append(buf);
|
||||
Append(buf);
|
||||
}
|
||||
|
||||
|
||||
@@ -1104,7 +1109,7 @@ PRUint32 nsCString::Left(nsCString& aDest,PRInt32 aCount) const{
|
||||
if(aCount<0)
|
||||
aCount=mLength;
|
||||
else aCount=MinInt(aCount,mLength);
|
||||
nsStr::Assign(aDest,*this,0,aCount);
|
||||
StrAssign(aDest,*this,0,aCount);
|
||||
return aDest.mLength;
|
||||
}
|
||||
|
||||
@@ -1121,7 +1126,7 @@ PRUint32 nsCString::Mid(nsCString& aDest,PRUint32 anOffset,PRInt32 aCount) const
|
||||
if(aCount<0)
|
||||
aCount=mLength;
|
||||
else aCount=MinInt(aCount,mLength);
|
||||
nsStr::Assign(aDest,*this,anOffset,aCount);
|
||||
StrAssign(aDest,*this,anOffset,aCount);
|
||||
return aDest.mLength;
|
||||
}
|
||||
|
||||
@@ -1139,6 +1144,25 @@ PRUint32 nsCString::Right(nsCString& aDest,PRInt32 aCount) const{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert a single unichar into this string at a specified offset.
|
||||
*
|
||||
* @update gess4/22/98
|
||||
* @param aChar unichar to be inserted into this string
|
||||
* @param anOffset is insert pos in str
|
||||
* @return this
|
||||
*/
|
||||
void nsCString::InsertWithConversion(PRUnichar aChar,PRUint32 anOffset){
|
||||
PRUnichar theBuffer[2]={0,0};
|
||||
theBuffer[0]=aChar;
|
||||
nsStr temp;
|
||||
nsStr::Initialize(temp,eTwoByte);
|
||||
temp.mUStr=theBuffer;
|
||||
temp.mLength=1;
|
||||
StrInsert(*this,anOffset,temp,0,1);
|
||||
}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/*
|
||||
* This method inserts n chars from given string into this
|
||||
* string at str[anOffset].
|
||||
@@ -1151,7 +1175,7 @@ PRUint32 nsCString::Right(nsCString& aDest,PRInt32 aCount) const{
|
||||
*/
|
||||
nsCString& nsCString::Insert(const nsCString& aString,PRUint32 anOffset,PRInt32 aCount) {
|
||||
|
||||
nsStr::Insert(*this,anOffset,aString,0,aCount);
|
||||
StrInsert(*this,anOffset,aString,0,aCount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -1186,32 +1210,13 @@ nsCString& nsCString::Insert(const char* aCString,PRUint32 anOffset,PRInt32 aCou
|
||||
else aCount=temp.mLength=nsCRT::strlen(aCString);
|
||||
|
||||
if(temp.mLength && (0<aCount)){
|
||||
nsStr::Insert(*this,anOffset,temp,0,aCount);
|
||||
StrInsert(*this,anOffset,temp,0,aCount);
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert a single unichar into this string at a specified offset.
|
||||
*
|
||||
* @update gess4/22/98
|
||||
* @param aChar unichar to be inserted into this string
|
||||
* @param anOffset is insert pos in str
|
||||
* @return this
|
||||
*/
|
||||
nsCString& nsCString::Insert(PRUnichar aChar,PRUint32 anOffset){
|
||||
PRUnichar theBuffer[2]={0,0};
|
||||
theBuffer[0]=aChar;
|
||||
nsStr temp;
|
||||
nsStr::Initialize(temp,eTwoByte);
|
||||
temp.mUStr=theBuffer;
|
||||
temp.mLength=1;
|
||||
nsStr::Insert(*this,anOffset,temp,0,1);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a single uni-char into this string at
|
||||
* a specified offset.
|
||||
@@ -1228,9 +1233,11 @@ nsCString& nsCString::Insert(char aChar,PRUint32 anOffset){
|
||||
nsStr::Initialize(temp,eOneByte);
|
||||
temp.mStr=theBuffer;
|
||||
temp.mLength=1;
|
||||
nsStr::Insert(*this,anOffset,temp,0,1);
|
||||
StrInsert(*this,anOffset,temp,0,1);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* This method is used to cut characters in this string
|
||||
@@ -1810,7 +1817,7 @@ void nsCString::DebugDump(void) const {
|
||||
*
|
||||
*/
|
||||
nsCAutoString::nsCAutoString() : nsCString(){
|
||||
nsStr::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
|
||||
}
|
||||
@@ -1819,7 +1826,7 @@ nsCAutoString::nsCAutoString() : nsCString(){
|
||||
* Default constructor
|
||||
*/
|
||||
nsCAutoString::nsCAutoString(const nsCAutoString& aString) : nsCString() {
|
||||
nsStr::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aString);
|
||||
}
|
||||
@@ -1830,7 +1837,7 @@ nsCAutoString::nsCAutoString(const nsCAutoString& aString) : nsCString() {
|
||||
* @param aCString is a ptr to a 1-byte cstr
|
||||
*/
|
||||
nsCAutoString::nsCAutoString(const char* aCString,PRInt32 aLength) : nsCString() {
|
||||
nsStr::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aCString,aLength);
|
||||
}
|
||||
@@ -1841,21 +1848,22 @@ nsCAutoString::nsCAutoString(const char* aCString,PRInt32 aLength) : nsCString()
|
||||
*/
|
||||
nsCAutoString::nsCAutoString(const CBufDescriptor& aBuffer) : nsCString() {
|
||||
if(!aBuffer.mBuffer) {
|
||||
nsStr::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
}
|
||||
else {
|
||||
nsStr::Initialize(*this,aBuffer.mBuffer,aBuffer.mCapacity,aBuffer.mLength,aBuffer.mCharSize,!aBuffer.mStackBased);
|
||||
Initialize(*this,aBuffer.mBuffer,aBuffer.mCapacity,aBuffer.mLength,aBuffer.mCharSize,!aBuffer.mStackBased);
|
||||
}
|
||||
if(!aBuffer.mIsConst)
|
||||
AddNullTerminator(*this); //this isn't really needed, but it guarantees that folks don't pass string constants.
|
||||
}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* Copy construct from uni-string
|
||||
* @param aString is a ptr to a unistr
|
||||
*/
|
||||
nsCAutoString::nsCAutoString(const PRUnichar* aString,PRInt32 aLength) : nsCString() {
|
||||
nsStr::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aString,aLength);
|
||||
}
|
||||
@@ -1865,7 +1873,7 @@ nsCAutoString::nsCAutoString(const PRUnichar* aString,PRInt32 aLength) : nsCStri
|
||||
* @param
|
||||
*/
|
||||
nsCAutoString::nsCAutoString(const nsStr& aString) : nsCString() {
|
||||
nsStr::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aString);
|
||||
}
|
||||
@@ -1877,10 +1885,12 @@ nsCAutoString::nsCAutoString(const nsStr& aString) : nsCString() {
|
||||
* @param
|
||||
*/
|
||||
nsCAutoString::nsCAutoString(PRUnichar aChar) : nsCString(){
|
||||
nsStr::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aChar);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* construct from a subsumeable string
|
||||
|
||||
@@ -50,6 +50,20 @@
|
||||
#else
|
||||
#define NS_LITERAL_STRING(s) (s)
|
||||
#define NS_LITERAL_CSTRING(s) (s)
|
||||
|
||||
inline
|
||||
char
|
||||
nsLiteralChar( char c )
|
||||
{
|
||||
return c;
|
||||
}
|
||||
|
||||
inline
|
||||
PRUnichar
|
||||
nsLiteralPRUnichar( PRUnichar c )
|
||||
{
|
||||
return c;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -65,34 +79,26 @@ class NS_COM nsCString :
|
||||
protected:
|
||||
virtual const char* GetReadableFragment( nsReadableFragment<char>&, nsFragmentRequest, PRUint32 ) const;
|
||||
virtual char* GetWritableFragment( nsWritableFragment<char>&, nsFragmentRequest, PRUint32 );
|
||||
|
||||
public:
|
||||
nsCString( const nsAReadableCString& );
|
||||
|
||||
#ifdef HAVE_AMBIGUITY_RESOLVING_CPP_USING
|
||||
using nsAWritableCString::Append;
|
||||
using nsAWritableCString::Insert;
|
||||
#else
|
||||
virtual void Append( const nsAReadableCString& aReadable ) {
|
||||
nsAWritableCString::Append(aReadable);
|
||||
}
|
||||
|
||||
virtual void Insert( const nsAReadableCString& aReadable, PRUint32 atPosition ) {
|
||||
nsAWritableCString::Insert(aReadable, atPosition);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
public:
|
||||
void AppendChar( char );
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
nsCString();
|
||||
|
||||
/**
|
||||
* This is our copy constructor
|
||||
* @param reference to another nsCString
|
||||
*/
|
||||
nsCString(const nsCString& aString);
|
||||
|
||||
#ifdef NEW_STRING_APIS
|
||||
nsCString( const nsAReadableCString& );
|
||||
|
||||
nsCString(const char*);
|
||||
nsCString(const char*, PRInt32);
|
||||
#else
|
||||
/**
|
||||
* This constructor accepts an isolatin string
|
||||
* @param aCString is a ptr to a 1-byte cstr
|
||||
@@ -110,12 +116,7 @@ public:
|
||||
* @param reference to another nsCString
|
||||
*/
|
||||
nsCString(const nsStr&);
|
||||
|
||||
/**
|
||||
* This is our copy constructor
|
||||
* @param reference to another nsCString
|
||||
*/
|
||||
nsCString(const nsCString& aString);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This constructor takes a subsumestr
|
||||
@@ -335,10 +336,10 @@ public:
|
||||
/**********************************************************************
|
||||
string conversion methods...
|
||||
*********************************************************************/
|
||||
#ifndef STASTANDALONE_STRING_TESTS
|
||||
//#ifndef STANDALONE_STRING_TESTS
|
||||
operator char*() {return mStr;}
|
||||
operator const char*() const {return (const char*)mStr;}
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
/**
|
||||
* This method constructs a new nsCString that is a clone
|
||||
@@ -399,91 +400,46 @@ public:
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
#ifdef NEW_STRING_APIS
|
||||
#ifdef HAVE_AMBIGUITY_RESOLVING_CPP_USING
|
||||
using nsAWritableCString::Assign;
|
||||
#else
|
||||
virtual void Assign( const nsAReadableCString& aReadable ) {
|
||||
nsAWritableCString::Assign(aReadable);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
nsCString& Assign(const char* aString,PRInt32 aCount=-1);
|
||||
nsCString& Assign(char aChar);
|
||||
|
||||
void AssignWithConversion(const PRUnichar*,PRInt32=-1);
|
||||
void AssignWithConversion(PRUnichar);
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsCString& Assign(const char* aString,PRInt32 aCount=-1);
|
||||
nsCString& Assign(char aChar);
|
||||
|
||||
nsCString& Assign(const nsStr& aString,PRInt32 aCount=-1);
|
||||
nsCString& Assign(const PRUnichar* aString,PRInt32 aCount=-1) { AssignWithConversion(aString, aCount); return *this; }
|
||||
nsCString& Assign(PRUnichar aChar) { AssignWithConversion(aChar); return *this; }
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Functionally equivalent to assign or operator=
|
||||
*
|
||||
*/
|
||||
nsCString& SetString(const char* aString,PRInt32 aLength=-1) {return Assign(aString,aLength);}
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsCString& SetString(const nsStr& aString,PRInt32 aLength=-1) {return Assign(aString,aLength);}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* here come a bunch of assignment operators...
|
||||
* @param aString: string to be added to this
|
||||
* @return this
|
||||
*/
|
||||
#ifdef NEW_STRING_APIS
|
||||
#ifdef HAVE_AMBIGUITY_RESOLVING_CPP_USING
|
||||
using nsAWritableCString::operator=;
|
||||
#else
|
||||
nsCString& operator=( const nsAReadableCString& aReadable ) { nsAWritableCString::operator=(aReadable); return *this; }
|
||||
#endif
|
||||
#endif
|
||||
nsCString& operator=(PRUnichar aChar) {return Assign(aChar);}
|
||||
nsCString& operator=(char aChar) {AssignWithConversion(aChar); return *this;}
|
||||
nsCString& operator=(const PRUnichar* aString) {AssignWithConversion(aString); return *this;}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsCString& operator=(const nsCString& aString) {return Assign(aString);}
|
||||
nsCString& operator=(const nsStr& aString) {return Assign(aString);}
|
||||
nsCString& operator=(const char* aCString) {return Assign(aCString);}
|
||||
#endif
|
||||
|
||||
// Yes, I know this makes assignment from a |nsSubsumeString| not do the special thing
|
||||
// |nsSubsumeString| needs to go away
|
||||
#ifdef AIX
|
||||
nsCString& operator=(const nsSubsumeCStr& aSubsumeString); // AIX requires a const here
|
||||
#else
|
||||
nsCString& operator=(nsSubsumeCStr& aSubsumeString);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Here's a bunch of methods that append varying types...
|
||||
* @param various...
|
||||
* @return this
|
||||
*/
|
||||
#ifdef NEW_STRING_APIS
|
||||
#ifdef HAVE_AMBIGUITY_RESOLVING_CPP_USING
|
||||
using nsAWritableCString::operator+=;
|
||||
#else
|
||||
nsCString& operator+=( const nsAReadableCString& aReadable ) { nsAWritableCString::operator+=(aReadable); return *this; }
|
||||
#endif
|
||||
#endif
|
||||
nsCString& operator+=(const PRUnichar aChar){return Append(aChar);}
|
||||
nsCString& operator+=(const char aChar){return Append(aChar);}
|
||||
nsCString& operator+=(const int anInt){return Append(anInt,10);}
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsCString& operator+=(const nsCString& aString){return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsCString& operator+=(const char* aCString) {return Append(aCString);}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Appends n characters from given string to this,
|
||||
* This version computes the length of your given string
|
||||
*
|
||||
* @param aString is the source to be appended to this
|
||||
* @return number of chars copied
|
||||
*/
|
||||
nsCString& Append(const nsCString& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
|
||||
|
||||
/*
|
||||
@@ -495,13 +451,35 @@ public:
|
||||
*
|
||||
* @return number of chars copied
|
||||
*/
|
||||
nsCString& Append(const nsCString& aString,PRInt32 aCount);
|
||||
|
||||
void AppendWithConversion(PRInt32 aInteger,PRInt32 aRadix=10); //radix=8,10 or 16
|
||||
void AppendWithConversion(float aFloat);
|
||||
void AppendWithConversion(PRUnichar aChar);
|
||||
// Why no |AppendWithConversion(const PRUnichar*)|?
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsCString& Append(const nsStr& aString,PRInt32 aCount=-1);
|
||||
nsCString& Append(const nsCString& aString,PRInt32 aCount);
|
||||
nsCString& Append(const nsCString& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsCString& Append(const char* aString,PRInt32 aCount=-1);
|
||||
nsCString& Append(PRUnichar aChar);
|
||||
nsCString& Append(char aChar);
|
||||
nsCString& Append(PRInt32 aInteger,PRInt32 aRadix=10); //radix=8,10 or 16
|
||||
nsCString& Append(float aFloat);
|
||||
|
||||
nsCString& Append(PRUnichar aChar) {AppendWithConversion(aChar); return *this;}
|
||||
nsCString& Append(PRInt32 aInteger,PRInt32 aRadix=10) {AppendWithConversion(aInteger,aRadix); return *this;}
|
||||
nsCString& Append(float aFloat) {AppendWithConversion(aFloat); return *this;}
|
||||
|
||||
/**
|
||||
* Here's a bunch of methods that append varying types...
|
||||
* @param various...
|
||||
* @return this
|
||||
*/
|
||||
nsCString& operator+=(const nsCString& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsCString& operator+=(const char* aCString) {return Append(aCString);}
|
||||
|
||||
nsCString& operator+=(const PRUnichar aChar) {return Append(aChar);}
|
||||
nsCString& operator+=(const char aChar) {return Append(aChar);}
|
||||
nsCString& operator+=(const int anInt) {return Append(anInt,10);}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copies n characters from this string to given string,
|
||||
@@ -537,6 +515,10 @@ public:
|
||||
*/
|
||||
PRUint32 Right(nsCString& aCopy,PRInt32 aCount) const;
|
||||
|
||||
void InsertWithConversion(PRUnichar aChar,PRUint32 anOffset);
|
||||
// Why no |InsertWithConversion(PRUnichar*)|?
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/*
|
||||
* This method inserts n chars from given string into this
|
||||
* string at str[anOffset].
|
||||
@@ -568,8 +550,9 @@ public:
|
||||
* @param anOffset is insert pos in str
|
||||
* @return the number of chars inserted into this string
|
||||
*/
|
||||
nsCString& Insert(PRUnichar aChar,PRUint32 anOffset);
|
||||
nsCString& Insert(PRUnichar aChar,PRUint32 anOffset) {InsertWithConversion(aChar,anOffset); return *this;}
|
||||
nsCString& Insert(char aChar,PRUint32 anOffset);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This method is used to cut characters in this string
|
||||
@@ -781,12 +764,18 @@ extern NS_COM int fputs(const nsCString& aString, FILE* out);
|
||||
class NS_COM nsCAutoString : public nsCString {
|
||||
public:
|
||||
|
||||
virtual ~nsCAutoString();
|
||||
|
||||
nsCAutoString();
|
||||
nsCAutoString(const nsCAutoString& aString);
|
||||
nsCAutoString(const char* aString,PRInt32 aLength=-1);
|
||||
nsCAutoString(const CBufDescriptor& aBuffer);
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsCAutoString(const PRUnichar* aString,PRInt32 aLength=-1);
|
||||
nsCAutoString(const nsStr& aString);
|
||||
nsCAutoString(const nsCAutoString& aString);
|
||||
nsCAutoString(PRUnichar aChar);
|
||||
#endif
|
||||
|
||||
#ifdef AIX
|
||||
nsCAutoString(const nsSubsumeCStr& aSubsumeStr); // AIX requires a const
|
||||
@@ -794,8 +783,6 @@ public:
|
||||
nsCAutoString(nsSubsumeCStr& aSubsumeStr);
|
||||
#endif // AIX
|
||||
|
||||
nsCAutoString(PRUnichar aChar);
|
||||
virtual ~nsCAutoString();
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsCAutoString& operator=(const nsCAutoString& aString) {nsCString::Assign(aString); return *this;}
|
||||
|
||||
@@ -52,7 +52,7 @@ static void Subsume(nsStr& aDest,nsStr& aSource){
|
||||
aSource.mStr=0;
|
||||
}
|
||||
else{
|
||||
nsStr::Assign(aDest,aSource,0,aSource.mLength);
|
||||
nsStr::StrAssign(aDest,aSource,0,aSource.mLength);
|
||||
}
|
||||
}
|
||||
else nsStr::Truncate(aDest,0);
|
||||
@@ -63,9 +63,10 @@ static void Subsume(nsStr& aDest,nsStr& aSource){
|
||||
* Default constructor.
|
||||
*/
|
||||
nsString::nsString() {
|
||||
nsStr::Initialize(*this,eTwoByte);
|
||||
Initialize(*this,eTwoByte);
|
||||
}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* This constructor accepts an ascii string
|
||||
* @update gess 1/4/99
|
||||
@@ -73,9 +74,17 @@ nsString::nsString() {
|
||||
* @param aLength tells us how many chars to copy from given CString
|
||||
*/
|
||||
nsString::nsString(const char* aCString,PRInt32 aCount){
|
||||
nsStr::Initialize(*this,eTwoByte);
|
||||
Initialize(*this,eTwoByte);
|
||||
AssignWithConversion(aCString,aCount);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NEW_STRING_APIS
|
||||
nsString::nsString(const PRUnichar* aString) {
|
||||
Initialize(*this,eTwoByte);
|
||||
Assign(aString);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This constructor accepts a unicode string
|
||||
@@ -84,19 +93,21 @@ nsString::nsString(const char* aCString,PRInt32 aCount){
|
||||
* @param aLength tells us how many chars to copy from given aString
|
||||
*/
|
||||
nsString::nsString(const PRUnichar* aString,PRInt32 aCount) {
|
||||
nsStr::Initialize(*this,eTwoByte);
|
||||
Initialize(*this,eTwoByte);
|
||||
Assign(aString,aCount);
|
||||
}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* This constructor works for all other nsSTr derivatives
|
||||
* @update gess 1/4/99
|
||||
* @param reference to another nsCString
|
||||
*/
|
||||
nsString::nsString(const nsStr &aString) {
|
||||
nsStr::Initialize(*this,eTwoByte);
|
||||
nsStr::Assign(*this,aString,0,aString.mLength);
|
||||
Initialize(*this,eTwoByte);
|
||||
StrAssign(*this,aString,0,aString.mLength);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This is our copy constructor
|
||||
@@ -104,8 +115,8 @@ nsString::nsString(const nsStr &aString) {
|
||||
* @param reference to another nsString
|
||||
*/
|
||||
nsString::nsString(const nsString& aString) {
|
||||
nsStr::Initialize(*this,eTwoByte);
|
||||
nsStr::Assign(*this,aString,0,aString.mLength);
|
||||
Initialize(*this,eTwoByte);
|
||||
StrAssign(*this,aString,0,aString.mLength);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,13 +126,13 @@ nsString::nsString(const nsString& aString) {
|
||||
*/
|
||||
#ifdef AIX
|
||||
nsString::nsString(const nsSubsumeStr& aSubsumeStr) {
|
||||
nsStr::Initialize(*this,eTwoByte);
|
||||
Initialize(*this,eTwoByte);
|
||||
|
||||
nsSubsumeStr temp(aSubsumeStr); // a temp is needed for the AIX compiler
|
||||
Subsume(*this,temp);
|
||||
#else
|
||||
nsString::nsString(nsSubsumeStr& aSubsumeStr) {
|
||||
nsStr::Initialize(*this,eTwoByte);
|
||||
Initialize(*this,eTwoByte);
|
||||
|
||||
Subsume(*this,aSubsumeStr);
|
||||
#endif /* AIX */
|
||||
@@ -167,15 +178,11 @@ PRUnichar* nsString::GetWritableFragment( nsWritableFragment<PRUnichar>& aFragme
|
||||
}
|
||||
|
||||
nsString::nsString( const nsAReadableString& aReadable ) {
|
||||
nsStr::Initialize(*this,eTwoByte);
|
||||
Initialize(*this,eTwoByte);
|
||||
Assign(aReadable);
|
||||
}
|
||||
#endif
|
||||
|
||||
void nsString::AppendChar( PRUnichar aChar ) {
|
||||
Append(aChar);
|
||||
}
|
||||
|
||||
void nsString::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const {
|
||||
if (aResult) {
|
||||
*aResult = sizeof(*this) + mCapacity * mCharSize;
|
||||
@@ -305,7 +312,7 @@ PRBool nsString::SetCharAt(PRUnichar aChar,PRUint32 anIndex){
|
||||
*/
|
||||
nsSubsumeStr nsString::operator+(const nsStr& aString){
|
||||
nsString temp(*this); //make a temp string the same size as this...
|
||||
nsStr::Append(temp,aString,0,aString.mLength);
|
||||
nsStr::StrAppend(temp,aString,0,aString.mLength);
|
||||
return nsSubsumeStr(temp);
|
||||
}
|
||||
|
||||
@@ -317,7 +324,7 @@ nsSubsumeStr nsString::operator+(const nsStr& aString){
|
||||
*/
|
||||
nsSubsumeStr nsString::operator+(const nsString& aString){
|
||||
nsString temp(*this); //make a temp string the same size as this...
|
||||
nsStr::Append(temp,aString,0,aString.mLength);
|
||||
nsStr::StrAppend(temp,aString,0,aString.mLength);
|
||||
return nsSubsumeStr(temp);
|
||||
}
|
||||
|
||||
@@ -584,7 +591,7 @@ nsString& nsString::ReplaceSubstring(const nsString& aTarget,const nsString& aNe
|
||||
//this is the worst case: the newvalue is larger than the substr it's replacing
|
||||
//so we have to insert some characters...
|
||||
PRInt32 theInsLen=aNewValue.mLength-aTarget.mLength;
|
||||
nsStr::Insert(*this,theIndex,aNewValue,0,theInsLen);
|
||||
StrInsert(*this,theIndex,aNewValue,0,theInsLen);
|
||||
}
|
||||
nsStr::Overwrite(*this,aNewValue,theIndex);
|
||||
}
|
||||
@@ -833,7 +840,7 @@ char* nsString::ToCString(char* aBuf, PRUint32 aBufLength,PRUint32 anOffset) con
|
||||
|
||||
CBufDescriptor theDescr(aBuf,PR_TRUE,aBufLength,0);
|
||||
nsCAutoString temp(theDescr);
|
||||
nsStr::Assign(temp, *this, anOffset, aBufLength-1);
|
||||
nsStr::StrAssign(temp, *this, anOffset, aBufLength-1);
|
||||
temp.mStr=0;
|
||||
}
|
||||
return aBuf;
|
||||
@@ -977,13 +984,13 @@ PRInt32 nsString::ToInteger(PRInt32* anErrorCode,PRUint32 aRadix) const {
|
||||
*********************************************************************/
|
||||
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* assign given nsStr (or derivative) to this one
|
||||
* @update gess 01/04/99
|
||||
* @param aString: nsStr to be appended
|
||||
* @return this
|
||||
*/
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsString& nsString::Assign(const nsStr& aString,PRInt32 aCount) {
|
||||
if(this!=&aString){
|
||||
nsStr::Truncate(*this,0);
|
||||
@@ -992,7 +999,7 @@ nsString& nsString::Assign(const nsStr& aString,PRInt32 aCount) {
|
||||
aCount=aString.mLength;
|
||||
else aCount=MinInt(aCount,aString.mLength);
|
||||
|
||||
nsStr::Assign(*this,aString,0,aCount);
|
||||
StrAssign(*this,aString,0,aCount);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@@ -1010,10 +1017,20 @@ nsString& nsString::Assign(const nsStr& aString,PRInt32 aCount) {
|
||||
void nsString::AssignWithConversion(const char* aCString,PRInt32 aCount) {
|
||||
nsStr::Truncate(*this,0);
|
||||
if(aCString){
|
||||
Append(aCString,aCount);
|
||||
AppendWithConversion(aCString,aCount);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NEW_STRING_APIS
|
||||
void nsString::AssignWithConversion(const char* aCString) {
|
||||
nsStr::Truncate(*this,0);
|
||||
if(aCString){
|
||||
AppendWithConversion(aCString);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* assign given unichar* to this string
|
||||
* @update gess 01/04/99
|
||||
@@ -1030,6 +1047,7 @@ nsString& nsString::Assign(const PRUnichar* aString,PRInt32 aCount) {
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* assign given char to this string
|
||||
@@ -1039,9 +1057,10 @@ nsString& nsString::Assign(const PRUnichar* aString,PRInt32 aCount) {
|
||||
*/
|
||||
void nsString::AssignWithConversion(char aChar) {
|
||||
nsStr::Truncate(*this,0);
|
||||
Append(aChar);
|
||||
AppendWithConversion(aChar);
|
||||
}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* assign given unichar to this string
|
||||
* @update gess 01/04/99
|
||||
@@ -1052,7 +1071,9 @@ nsString& nsString::Assign(PRUnichar aChar) {
|
||||
nsStr::Truncate(*this,0);
|
||||
return Append(aChar);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* WARNING! THIS IS A VERY SPECIAL METHOD.
|
||||
* This method "steals" the contents of aSource and hands it to aDest.
|
||||
@@ -1071,40 +1092,7 @@ nsString& nsString::operator=(const nsSubsumeStr& aSubsumeString) {
|
||||
#endif // AIX
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* append given string to this string;
|
||||
* @update gess 01/04/99
|
||||
* @param aString : string to be appended to this
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Append(const nsStr& aString,PRInt32 aCount) {
|
||||
|
||||
if(aCount<0)
|
||||
aCount=aString.mLength;
|
||||
else aCount=MinInt(aCount,aString.mLength);
|
||||
|
||||
if(0<aCount)
|
||||
nsStr::Append(*this,aString,0,aCount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* append given string to this string
|
||||
* I don't think we need this method now that we have the previous one.
|
||||
* @update gess 01/04/99
|
||||
* @param aString : string to be appended to this
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Append(const nsString& aString,PRInt32 aCount) {
|
||||
if(aCount<0)
|
||||
aCount=aString.mLength;
|
||||
else aCount=MinInt(aCount,aString.mLength);
|
||||
if(0<aCount)
|
||||
nsStr::Append(*this,aString,0,aCount);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* append given c-string to this string
|
||||
@@ -1115,10 +1103,10 @@ nsString& nsString::Append(const nsString& aString,PRInt32 aCount) {
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Append(const char* aCString,PRInt32 aCount) {
|
||||
void nsString::AppendWithConversion(const char* aCString,PRInt32 aCount) {
|
||||
if(aCString && aCount){ //if astring is null or count==0 there's nothing to do
|
||||
nsStr temp;
|
||||
Initialize(temp,eOneByte);
|
||||
nsStr::Initialize(temp,eOneByte);
|
||||
temp.mStr=(char*)aCString;
|
||||
|
||||
if(0<aCount) {
|
||||
@@ -1138,45 +1126,8 @@ nsString& nsString::Append(const char* aCString,PRInt32 aCount) {
|
||||
else aCount=temp.mLength=nsCRT::strlen(aCString);
|
||||
|
||||
if(0<aCount)
|
||||
nsStr::Append(*this,temp,0,aCount);
|
||||
StrAppend(*this,temp,0,aCount);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* append given unicode string to this
|
||||
* @update gess 01/04/99
|
||||
* @param aString : string to be appended to this
|
||||
* @param aCount -- length of given buffer or -1 if you want me to compute length.
|
||||
* NOTE: IFF you pass -1 as aCount, then your buffer must be null terminated.
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Append(const PRUnichar* aString,PRInt32 aCount) {
|
||||
if(aString && aCount){ //if astring is null or count==0 there's nothing to do
|
||||
nsStr temp;
|
||||
Initialize(temp,eTwoByte);
|
||||
temp.mUStr=(PRUnichar*)aString;
|
||||
|
||||
if(0<aCount) {
|
||||
temp.mLength=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,temp.mLength);
|
||||
if(kNotFound<len) {
|
||||
NS_WARNING(kPossibleNull);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
else aCount=temp.mLength=nsCRT::strlen(aString);
|
||||
|
||||
if(0<aCount)
|
||||
nsStr::Append(*this,temp,0,aCount);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1185,34 +1136,15 @@ nsString& nsString::Append(const PRUnichar* aString,PRInt32 aCount) {
|
||||
* @param aChar: char to be appended
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Append(char aChar) {
|
||||
void nsString::AppendWithConversion(char aChar) {
|
||||
char buf[2]={0,0};
|
||||
buf[0]=aChar;
|
||||
|
||||
nsStr temp;
|
||||
Initialize(temp,eOneByte);
|
||||
nsStr::Initialize(temp,eOneByte);
|
||||
temp.mStr=buf;
|
||||
temp.mLength=1;
|
||||
nsStr::Append(*this,temp,0,1);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* append given unichar to this string
|
||||
* @update gess 01/04/99
|
||||
* @param aChar: char to be appended to this
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Append(PRUnichar aChar) {
|
||||
PRUnichar buf[2]={0,0};
|
||||
buf[0]=aChar;
|
||||
|
||||
nsStr temp;
|
||||
Initialize(temp,eTwoByte);
|
||||
temp.mUStr=buf;
|
||||
temp.mLength=1;
|
||||
nsStr::Append(*this,temp,0,1);
|
||||
return *this;
|
||||
StrAppend(*this,temp,0,1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1222,7 +1154,7 @@ nsString& nsString::Append(PRUnichar aChar) {
|
||||
* @param aRadix:
|
||||
* @return
|
||||
*/
|
||||
nsString& nsString::Append(PRInt32 anInteger,PRInt32 aRadix) {
|
||||
void nsString::AppendWithConversion(PRInt32 anInteger,PRInt32 aRadix) {
|
||||
|
||||
PRUint32 theInt=(PRUint32)anInteger;
|
||||
|
||||
@@ -1250,7 +1182,7 @@ nsString& nsString::Append(PRInt32 anInteger,PRInt32 aRadix) {
|
||||
theInt-=theDiv*mask1;
|
||||
mask1/=aRadix;
|
||||
}
|
||||
return Append(buf);
|
||||
AppendWithConversion(buf);
|
||||
}
|
||||
|
||||
|
||||
@@ -1260,16 +1192,105 @@ nsString& nsString::Append(PRInt32 anInteger,PRInt32 aRadix) {
|
||||
* @param aFloat:
|
||||
* @return
|
||||
*/
|
||||
nsString& nsString::Append(float aFloat){
|
||||
void nsString::AppendWithConversion(float aFloat){
|
||||
char buf[40];
|
||||
// *** XX UNCOMMENT THIS LINE
|
||||
//PR_snprintf(buf, sizeof(buf), "%g", aFloat);
|
||||
sprintf(buf,"%g",aFloat);
|
||||
Append(buf);
|
||||
AppendWithConversion(buf);
|
||||
}
|
||||
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* append given string to this string;
|
||||
* @update gess 01/04/99
|
||||
* @param aString : string to be appended to this
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Append(const nsStr& aString,PRInt32 aCount) {
|
||||
|
||||
if(aCount<0)
|
||||
aCount=aString.mLength;
|
||||
else aCount=MinInt(aCount,aString.mLength);
|
||||
|
||||
if(0<aCount)
|
||||
StrAppend(*this,aString,0,aCount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* append given string to this string
|
||||
* I don't think we need this method now that we have the previous one.
|
||||
* @update gess 01/04/99
|
||||
* @param aString : string to be appended to this
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Append(const nsString& aString,PRInt32 aCount) {
|
||||
if(aCount<0)
|
||||
aCount=aString.mLength;
|
||||
else aCount=MinInt(aCount,aString.mLength);
|
||||
if(0<aCount)
|
||||
StrAppend(*this,aString,0,aCount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* append given unicode string to this
|
||||
* @update gess 01/04/99
|
||||
* @param aString : string to be appended to this
|
||||
* @param aCount -- length of given buffer or -1 if you want me to compute length.
|
||||
* NOTE: IFF you pass -1 as aCount, then your buffer must be null terminated.
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Append(const PRUnichar* aString,PRInt32 aCount) {
|
||||
if(aString && aCount){ //if astring is null or count==0 there's nothing to do
|
||||
nsStr temp;
|
||||
nsStr::Initialize(temp,eTwoByte);
|
||||
temp.mUStr=(PRUnichar*)aString;
|
||||
|
||||
if(0<aCount) {
|
||||
temp.mLength=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,temp.mLength);
|
||||
if(kNotFound<len) {
|
||||
NS_WARNING(kPossibleNull);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
else aCount=temp.mLength=nsCRT::strlen(aString);
|
||||
|
||||
if(0<aCount)
|
||||
StrAppend(*this,temp,0,aCount);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* append given unichar to this string
|
||||
* @update gess 01/04/99
|
||||
* @param aChar: char to be appended to this
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Append(PRUnichar aChar) {
|
||||
PRUnichar buf[2]={0,0};
|
||||
buf[0]=aChar;
|
||||
|
||||
nsStr temp;
|
||||
nsStr::Initialize(temp,eTwoByte);
|
||||
temp.mUStr=buf;
|
||||
temp.mLength=1;
|
||||
StrAppend(*this,temp,0,1);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copies n characters from this left of this string to given string,
|
||||
*
|
||||
@@ -1283,7 +1304,7 @@ PRUint32 nsString::Left(nsString& aDest,PRInt32 aCount) const{
|
||||
if(aCount<0)
|
||||
aCount=mLength;
|
||||
else aCount=MinInt(aCount,mLength);
|
||||
nsStr::Assign(aDest,*this,0,aCount);
|
||||
nsStr::StrAssign(aDest,*this,0,aCount);
|
||||
|
||||
return aDest.mLength;
|
||||
}
|
||||
@@ -1301,7 +1322,7 @@ PRUint32 nsString::Mid(nsString& aDest,PRUint32 anOffset,PRInt32 aCount) const{
|
||||
if(aCount<0)
|
||||
aCount=mLength;
|
||||
else aCount=MinInt(aCount,mLength);
|
||||
nsStr::Assign(aDest,*this,anOffset,aCount);
|
||||
nsStr::StrAssign(aDest,*this,anOffset,aCount);
|
||||
|
||||
return aDest.mLength;
|
||||
}
|
||||
@@ -1320,20 +1341,6 @@ PRUint32 nsString::Right(nsString& aDest,PRInt32 aCount) const{
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This method inserts n chars from given string into this
|
||||
* string at str[anOffset].
|
||||
*
|
||||
* @update gess 4/1/98
|
||||
* @param aString -- source String to be inserted into this
|
||||
* @param anOffset -- insertion position within this str
|
||||
* @param aCount -- number of chars to be copied from aCopy
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Insert(const nsString& aCopy,PRUint32 anOffset,PRInt32 aCount) {
|
||||
nsStr::Insert(*this,anOffset,aCopy,0,aCount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a char* into this string at a specified offset.
|
||||
@@ -1346,7 +1353,7 @@ nsString& nsString::Insert(const nsString& aCopy,PRUint32 anOffset,PRInt32 aCoun
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Insert(const char* aCString,PRUint32 anOffset,PRInt32 aCount){
|
||||
void nsString::InsertWithConversion(const char* aCString,PRUint32 anOffset,PRInt32 aCount){
|
||||
if(aCString && aCount){
|
||||
nsStr temp;
|
||||
nsStr::Initialize(temp,eOneByte);
|
||||
@@ -1368,10 +1375,25 @@ nsString& nsString::Insert(const char* aCString,PRUint32 anOffset,PRInt32 aCount
|
||||
else aCount=temp.mLength=nsCRT::strlen(aCString);
|
||||
|
||||
if(0<aCount){
|
||||
nsStr::Insert(*this,anOffset,temp,0,aCount);
|
||||
StrInsert(*this,anOffset,temp,0,aCount);
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/*
|
||||
* This method inserts n chars from given string into this
|
||||
* string at str[anOffset].
|
||||
*
|
||||
* @update gess 4/1/98
|
||||
* @param aString -- source String to be inserted into this
|
||||
* @param anOffset -- insertion position within this str
|
||||
* @param aCount -- number of chars to be copied from aCopy
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Insert(const nsString& aCopy,PRUint32 anOffset,PRInt32 aCount) {
|
||||
StrInsert(*this,anOffset,aCopy,0,aCount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@@ -1408,7 +1430,7 @@ nsString& nsString::Insert(const PRUnichar* aString,PRUint32 anOffset,PRInt32 aC
|
||||
else aCount=temp.mLength=nsCRT::strlen(aString);
|
||||
|
||||
if(0<aCount){
|
||||
nsStr::Insert(*this,anOffset,temp,0,aCount);
|
||||
StrInsert(*this,anOffset,temp,0,aCount);
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
@@ -1431,9 +1453,10 @@ nsString& nsString::Insert(PRUnichar aChar,PRUint32 anOffset){
|
||||
nsStr::Initialize(temp,eTwoByte);
|
||||
temp.mUStr=theBuffer;
|
||||
temp.mLength=1;
|
||||
nsStr::Insert(*this,anOffset,temp,0,1);
|
||||
StrInsert(*this,anOffset,temp,0,1);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This method is used to cut characters in this string
|
||||
@@ -2224,7 +2247,7 @@ void nsString::DebugDump(void) const {
|
||||
nsCAutoString temp;
|
||||
|
||||
if(eTwoByte==mCharSize) {
|
||||
nsStr::Assign(temp, *this, 0, mLength);
|
||||
nsStr::StrAssign(temp, *this, 0, mLength);
|
||||
theBuffer=temp.GetBuffer();
|
||||
}
|
||||
|
||||
@@ -2245,28 +2268,17 @@ void nsString::DebugDump(void) const {
|
||||
*
|
||||
*/
|
||||
nsAutoString::nsAutoString() : nsString() {
|
||||
nsStr::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy construct from ascii c-string
|
||||
* @param aCString is a ptr to a 1-byte cstr
|
||||
* @param aLength tells us how many chars to copy from aCString
|
||||
*/
|
||||
nsAutoString::nsAutoString(const char* aCString,PRInt32 aLength) : nsString() {
|
||||
nsStr::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aCString,aLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy construct from uni-string
|
||||
* @param aString is a ptr to a unistr
|
||||
* @param aLength tells us how many chars to copy from aString
|
||||
*/
|
||||
nsAutoString::nsAutoString(const PRUnichar* aString,PRInt32 aLength) : nsString() {
|
||||
nsStr::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aString,aLength);
|
||||
}
|
||||
@@ -2277,31 +2289,44 @@ nsAutoString::nsAutoString(const PRUnichar* aString,PRInt32 aLength) : nsString(
|
||||
*/
|
||||
nsAutoString::nsAutoString(const CBufDescriptor& aBuffer) : nsString() {
|
||||
if(!aBuffer.mBuffer) {
|
||||
nsStr::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
}
|
||||
else {
|
||||
nsStr::Initialize(*this,aBuffer.mBuffer,aBuffer.mCapacity,aBuffer.mLength,aBuffer.mCharSize,!aBuffer.mStackBased);
|
||||
Initialize(*this,aBuffer.mBuffer,aBuffer.mCapacity,aBuffer.mLength,aBuffer.mCharSize,!aBuffer.mStackBased);
|
||||
}
|
||||
if(!aBuffer.mIsConst)
|
||||
AddNullTerminator(*this);
|
||||
}
|
||||
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* Copy construct from ascii c-string
|
||||
* @param aCString is a ptr to a 1-byte cstr
|
||||
* @param aLength tells us how many chars to copy from aCString
|
||||
*/
|
||||
nsAutoString::nsAutoString(const char* aCString,PRInt32 aLength) : nsString() {
|
||||
Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aCString,aLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy construct from an nsStr
|
||||
* @param
|
||||
*/
|
||||
nsAutoString::nsAutoString(const nsStr& aString) : nsString() {
|
||||
nsStr::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aString);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Default copy constructor
|
||||
*/
|
||||
nsAutoString::nsAutoString(const nsAutoString& aString) : nsString() {
|
||||
nsStr::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aString);
|
||||
}
|
||||
@@ -2312,7 +2337,7 @@ nsAutoString::nsAutoString(const nsAutoString& aString) : nsString() {
|
||||
* @param
|
||||
*/
|
||||
nsAutoString::nsAutoString(PRUnichar aChar) : nsString(){
|
||||
nsStr::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aChar);
|
||||
}
|
||||
|
||||
@@ -65,38 +65,36 @@ class NS_COM nsString :
|
||||
#endif
|
||||
public nsStr {
|
||||
|
||||
#ifdef NEW_STRING_APIS
|
||||
protected:
|
||||
#ifdef NEW_STRING_APIS
|
||||
virtual const PRUnichar* GetReadableFragment( nsReadableFragment<PRUnichar>&, nsFragmentRequest, PRUint32 ) const;
|
||||
virtual PRUnichar* GetWritableFragment( nsWritableFragment<PRUnichar>&, nsFragmentRequest, PRUint32 );
|
||||
|
||||
public:
|
||||
nsString( const nsAReadableString& );
|
||||
|
||||
#ifdef HAVE_AMBIGUITY_RESOLVING_CPP_USING
|
||||
using nsAWritableString::Append;
|
||||
using nsAWritableString::Insert;
|
||||
#else
|
||||
virtual void Append( const nsAReadableString& aReadable ) {
|
||||
nsAWritableString::Append(aReadable);
|
||||
}
|
||||
|
||||
virtual void Insert( const nsAReadableString& aReadable, PRUint32 atPosition ) {
|
||||
nsAWritableString::Insert(aReadable, atPosition);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
public:
|
||||
void AppendChar( PRUnichar );
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
nsString();
|
||||
|
||||
/**
|
||||
* This is our copy constructor
|
||||
* @param reference to another nsString
|
||||
*/
|
||||
nsString(const nsString& aString);
|
||||
|
||||
#ifdef NEW_STRING_APIS
|
||||
nsString(const nsAReadableString&);
|
||||
|
||||
nsString(const PRUnichar*);
|
||||
nsString(const PRUnichar*, PRInt32);
|
||||
#else
|
||||
/**
|
||||
* This constructor accepts a unichar string
|
||||
* @param aCString is a ptr to a 2-byte cstr
|
||||
*/
|
||||
nsString(const PRUnichar* aString,PRInt32 aCount=-1);
|
||||
|
||||
/**
|
||||
* This constructor accepts an isolatin string
|
||||
@@ -104,23 +102,13 @@ public:
|
||||
*/
|
||||
nsString(const char* aCString,PRInt32 aCount=-1);
|
||||
|
||||
/**
|
||||
* This constructor accepts a unichar string
|
||||
* @param aCString is a ptr to a 2-byte cstr
|
||||
*/
|
||||
nsString(const PRUnichar* aString,PRInt32 aCount=-1);
|
||||
|
||||
/**
|
||||
* This is a copy constructor that accepts an nsStr
|
||||
* @param reference to another nsString
|
||||
*/
|
||||
nsString(const nsStr&);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This is our copy constructor
|
||||
* @param reference to another nsString
|
||||
*/
|
||||
nsString(const nsString& aString);
|
||||
|
||||
/**
|
||||
* This constructor takes a subsumestr
|
||||
@@ -440,94 +428,52 @@ public:
|
||||
|
||||
* @return this
|
||||
*/
|
||||
|
||||
void AssignWithConversion(char);
|
||||
#ifdef NEW_STRING_APIS
|
||||
#ifdef HAVE_AMBIGUITY_RESOLVING_CPP_USING
|
||||
using nsAWritableString::Assign;
|
||||
void AssignWithConversion(const char*);
|
||||
void AssignWithConversion(const char*, PRInt32);
|
||||
#else
|
||||
virtual void Assign( const nsAReadableString& aReadable ) {
|
||||
nsAWritableString::Assign(aReadable);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
void AssignWithConversion(const char*, PRInt32=-1);
|
||||
|
||||
nsString& Assign(const PRUnichar* aString,PRInt32 aCount=-1);
|
||||
nsString& Assign(PRUnichar aChar);
|
||||
|
||||
void AssignWithConversion(const char*, PRInt32=-1);
|
||||
void AssignWithConversion(char);
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsString& Assign(const nsStr& aString,PRInt32 aCount=-1);
|
||||
nsString& Assign(const char* aString,PRInt32 aCount=-1) { AssignWithConversion(aString, aCount); return *this; }
|
||||
nsString& Assign(char aChar) { AssignWithConversion(aChar); return *this; }
|
||||
#endif
|
||||
|
||||
nsString& Assign(const char* aString,PRInt32 aCount=-1) { AssignWithConversion(aString, aCount); return *this; }
|
||||
nsString& Assign(char aChar) { AssignWithConversion(aChar); return *this; }
|
||||
|
||||
/**
|
||||
* Functionally equivalent to assign or operator=
|
||||
*
|
||||
*/
|
||||
nsString& SetString(const char* aString,PRInt32 aLength=-1) {AssignWithConversion(aString, aLength); return *this;}
|
||||
#ifdef NEW_STRING_APIS
|
||||
nsString& SetString(const nsString& aString,PRInt32 aLength=-1) {Assign(aString); return *this;}
|
||||
nsString& SetString(const PRUnichar* aString,PRInt32 aLength=-1) {Assign(aString); return *this;}
|
||||
#else
|
||||
nsString& SetString(const nsString& aString,PRInt32 aLength=-1) {return Assign(aString, aLength);}
|
||||
nsString& SetString(const PRUnichar* aString,PRInt32 aLength=-1) {return Assign(aString, aLength);}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* here come a bunch of assignment operators...
|
||||
* @param aString: string to be added to this
|
||||
* @return this
|
||||
*/
|
||||
#ifdef NEW_STRING_APIS
|
||||
#ifdef HAVE_AMBIGUITY_RESOLVING_CPP_USING
|
||||
using nsAWritableString::operator=;
|
||||
#else
|
||||
nsString& operator=( const nsAReadableString& aReadable ) { nsAWritableString::operator=(aReadable); return *this; }
|
||||
#endif
|
||||
#endif
|
||||
nsString& operator=(PRUnichar aChar) {return Assign(aChar);}
|
||||
nsString& operator=(char aChar) {AssignWithConversion(aChar); return *this;}
|
||||
nsString& operator=(const char* aCString) {AssignWithConversion(aCString); return *this;}
|
||||
nsString& operator=(PRUnichar aChar) {Assign(aChar); return *this;}
|
||||
nsString& operator=(char aChar) {AssignWithConversion(aChar); return *this;}
|
||||
nsString& operator=(const char* aCString) {AssignWithConversion(aCString); return *this;}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsString& operator=(const nsString& aString) {return Assign(aString);}
|
||||
nsString& operator=(const nsStr& aString) {return Assign(aString);}
|
||||
nsString& operator=(const nsString& aString) {return Assign(aString);}
|
||||
nsString& operator=(const nsStr& aString) {return Assign(aString);}
|
||||
nsString& operator=(const PRUnichar* aString) {return Assign(aString);}
|
||||
#endif
|
||||
|
||||
// Yes, I know this makes assignment from a |nsSubsumeString| not do the special thing
|
||||
// |nsSubsumeString| needs to go away
|
||||
#ifdef AIX
|
||||
nsString& operator=(const nsSubsumeStr& aSubsumeString); // AIX requires a const here
|
||||
#else
|
||||
nsString& operator=(nsSubsumeStr& aSubsumeString);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Here's a bunch of methods that append varying types...
|
||||
* @param various...
|
||||
* @return this
|
||||
*/
|
||||
#ifdef NEW_STRING_APIS
|
||||
#ifdef HAVE_AMBIGUITY_RESOLVING_CPP_USING
|
||||
using nsAWritableString::operator+=;
|
||||
#else
|
||||
nsString& operator+=( const nsAReadableString& aReadable ) { nsAWritableString::operator+=(aReadable); return *this; }
|
||||
#endif
|
||||
#endif
|
||||
nsString& operator+=(const char* aCString) {return Append(aCString);}
|
||||
nsString& operator+=(const char aChar) {
|
||||
return Append((PRUnichar) (unsigned char)aChar);
|
||||
}
|
||||
nsString& operator+=(const PRUnichar aChar){return Append(aChar);}
|
||||
nsString& operator+=(const int anInt){return Append(anInt,10);}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsString& operator+=(const nsStr& aString){return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsString& operator+=(const nsString& aString){return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsString& operator+=(const PRUnichar* aUCString) {return Append(aUCString);}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Appends n characters from given string to this,
|
||||
* This version computes the length of your given string
|
||||
@@ -535,9 +481,16 @@ public:
|
||||
* @param aString is the source to be appended to this
|
||||
* @return number of chars copied
|
||||
*/
|
||||
nsString& Append(const nsStr& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsString& Append(const nsString& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
|
||||
|
||||
void AppendWithConversion(PRInt32, PRInt32=10); //radix=8,10 or 16
|
||||
void AppendWithConversion(float);
|
||||
void AppendWithConversion(char);
|
||||
|
||||
#ifdef NEW_STRING_APIS
|
||||
void AppendWithConversion(const char*);
|
||||
void AppendWithConversion(const char*, PRInt32);
|
||||
#else
|
||||
void AppendWithConversion(const char*, PRInt32=-1);
|
||||
|
||||
/*
|
||||
* Appends n characters from given string to this,
|
||||
@@ -548,13 +501,32 @@ public:
|
||||
* @return number of chars copied
|
||||
*/
|
||||
nsString& Append(const nsStr& aString,PRInt32 aCount);
|
||||
nsString& Append(const nsStr& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsString& Append(const nsString& aString,PRInt32 aCount);
|
||||
nsString& Append(const char* aString,PRInt32 aCount=-1);
|
||||
nsString& Append(const nsString& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
|
||||
nsString& Append(const PRUnichar* aString,PRInt32 aCount=-1);
|
||||
nsString& Append(char aChar);
|
||||
nsString& Append(PRUnichar aChar);
|
||||
nsString& Append(PRInt32 aInteger,PRInt32 aRadix=10); //radix=8,10 or 16
|
||||
nsString& Append(float aFloat);
|
||||
|
||||
nsString& Append(const char* aString,PRInt32 aCount=-1) {AppendWithConversion(aString,aCount); return *this;}
|
||||
nsString& Append(char aChar) {AppendWithConversion(aChar); return *this;}
|
||||
nsString& Append(PRInt32 aInteger,PRInt32 aRadix=10) {AppendWithConversion(aInteger,aRadix); return *this;}
|
||||
nsString& Append(float aFloat) {AppendWithConversion(aFloat); return *this;}
|
||||
|
||||
/**
|
||||
* Here's a bunch of methods that append varying types...
|
||||
* @param various...
|
||||
* @return this
|
||||
*/
|
||||
nsString& operator+=(const char* aCString) {return Append(aCString);}
|
||||
nsString& operator+=(const char aChar) {return Append((PRUnichar) (unsigned char)aChar);}
|
||||
nsString& operator+=(const PRUnichar aChar) {return Append(aChar);}
|
||||
nsString& operator+=(const int anInt) {return Append(anInt,10);}
|
||||
|
||||
nsString& operator+=(const nsStr& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsString& operator+=(const nsString& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsString& operator+=(const PRUnichar* aUCString) {return Append(aUCString);}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copies n characters from this string to given string,
|
||||
@@ -590,6 +562,10 @@ public:
|
||||
*/
|
||||
PRUint32 Right(nsString& aCopy,PRInt32 aCount) const;
|
||||
|
||||
|
||||
//void InsertWithConversion(char);
|
||||
void InsertWithConversion(const char*, PRUint32, PRInt32=-1);
|
||||
#ifndef NEW_STRING_APIS
|
||||
/*
|
||||
* This method inserts n chars from given string into this
|
||||
* string at str[anOffset].
|
||||
@@ -611,7 +587,7 @@ public:
|
||||
* @param anOffset is insert pos in str
|
||||
* @return the number of chars inserted into this string
|
||||
*/
|
||||
nsString& Insert(const char* aChar,PRUint32 anOffset,PRInt32 aCount=-1);
|
||||
nsString& Insert(const char* aChar,PRUint32 anOffset,PRInt32 aCount=-1) {InsertWithConversion(aChar, anOffset, aCount); return *this;}
|
||||
nsString& Insert(const PRUnichar* aChar,PRUint32 anOffset,PRInt32 aCount=-1);
|
||||
|
||||
/**
|
||||
@@ -622,9 +598,12 @@ public:
|
||||
* @param anOffset is insert pos in str
|
||||
* @return the number of chars inserted into this string
|
||||
*/
|
||||
//nsString& Insert(char aChar,PRUint32 anOffset);
|
||||
//nsString& Insert(char aChar,PRUint32 anOffset) {InsertWithConversion(aChar,anOffset); return *this;}
|
||||
nsString& Insert(PRUnichar aChar,PRUint32 anOffset);
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/*
|
||||
* This method is used to cut characters in this string
|
||||
* starting at anOffset, continuing for aCount chars.
|
||||
@@ -633,7 +612,6 @@ public:
|
||||
* @param aCount -- number of chars to be cut
|
||||
* @return *this
|
||||
*/
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsString& Cut(PRUint32 anOffset,PRInt32 aCount);
|
||||
#endif
|
||||
|
||||
@@ -797,6 +775,7 @@ public:
|
||||
PRBool operator>=(const char* aString) const;
|
||||
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.
|
||||
@@ -876,13 +855,17 @@ extern NS_COM int fputs(const nsString& aString, FILE* out);
|
||||
class NS_COM nsAutoString : public nsString {
|
||||
public:
|
||||
|
||||
virtual ~nsAutoString();
|
||||
nsAutoString();
|
||||
nsAutoString(const char* aCString,PRInt32 aLength=-1);
|
||||
nsAutoString(const PRUnichar* aString,PRInt32 aLength=-1);
|
||||
|
||||
nsAutoString(const CBufDescriptor& aBuffer);
|
||||
nsAutoString(const nsStr& aString);
|
||||
nsAutoString(const nsAutoString& aString);
|
||||
nsAutoString(const PRUnichar* aString,PRInt32 aLength=-1);
|
||||
nsAutoString(PRUnichar aChar);
|
||||
nsAutoString(const CBufDescriptor& aBuffer);
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsAutoString(const char* aCString,PRInt32 aLength=-1);
|
||||
nsAutoString(const nsStr& aString);
|
||||
#endif
|
||||
|
||||
#ifdef AIX
|
||||
nsAutoString(const nsSubsumeStr& aSubsumeStr); // AIX requires a const
|
||||
@@ -890,8 +873,6 @@ public:
|
||||
nsAutoString(nsSubsumeStr& aSubsumeStr);
|
||||
#endif // AIX
|
||||
|
||||
nsAutoString(PRUnichar aChar);
|
||||
virtual ~nsAutoString();
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsAutoString& operator=(const nsStr& aString) {nsString::Assign(aString); return *this;}
|
||||
|
||||
@@ -120,7 +120,7 @@ PRBool nsStr::GrowCapacity(nsStr& aDest,PRUint32 aNewLength) {
|
||||
result=EnsureCapacity(theTempStr,aNewLength);
|
||||
if(result) {
|
||||
if(aDest.mLength) {
|
||||
Append(theTempStr,aDest,0,aDest.mLength);
|
||||
StrAppend(theTempStr,aDest,0,aDest.mLength);
|
||||
}
|
||||
Free(aDest);
|
||||
aDest.mStr = theTempStr.mStr;
|
||||
@@ -140,10 +140,10 @@ PRBool nsStr::GrowCapacity(nsStr& aDest,PRUint32 aNewLength) {
|
||||
* @param aSource is where chars are copied from
|
||||
* @param aCount is the number of chars copied from aSource
|
||||
*/
|
||||
void nsStr::Assign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount){
|
||||
void nsStr::StrAssign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount){
|
||||
if(&aDest!=&aSource){
|
||||
Truncate(aDest,0);
|
||||
Append(aDest,aSource,anOffset,aCount);
|
||||
StrAppend(aDest,aSource,anOffset,aCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ void nsStr::Assign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 a
|
||||
* @param aSource is where char are copied from
|
||||
* @aCount is the number of bytes to be copied
|
||||
*/
|
||||
void nsStr::Append(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount){
|
||||
void nsStr::StrAppend(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount){
|
||||
if(anOffset<aSource.mLength){
|
||||
PRUint32 theRealLen=(aCount<0) ? aSource.mLength : MinInt(aCount,aSource.mLength);
|
||||
PRUint32 theLength=(anOffset+theRealLen<aSource.mLength) ? theRealLen : (aSource.mLength-anOffset);
|
||||
@@ -188,7 +188,7 @@ void nsStr::Append(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 a
|
||||
* @param aSrcOffset is where in aSource chars are copied from
|
||||
* @param aCount is the number of chars from aSource to be inserted into aDest
|
||||
*/
|
||||
void nsStr::Insert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount){
|
||||
void nsStr::StrInsert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount){
|
||||
//there are a few cases for insert:
|
||||
// 1. You're inserting chars into an empty string (assign)
|
||||
// 2. You're inserting onto the end of a string (append)
|
||||
@@ -211,14 +211,14 @@ void nsStr::Insert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUin
|
||||
|
||||
if(isBigEnough) {
|
||||
if(aDestOffset) {
|
||||
Append(theTempStr,aDest,0,aDestOffset); //first copy leftmost data...
|
||||
StrAppend(theTempStr,aDest,0,aDestOffset); //first copy leftmost data...
|
||||
}
|
||||
|
||||
Append(theTempStr,aSource,0,aSource.mLength); //next copy inserted (new) data
|
||||
StrAppend(theTempStr,aSource,0,aSource.mLength); //next copy inserted (new) data
|
||||
|
||||
PRUint32 theRemains=aDest.mLength-aDestOffset;
|
||||
if(theRemains) {
|
||||
Append(theTempStr,aDest,aDestOffset,theRemains); //next copy rightmost data
|
||||
StrAppend(theTempStr,aDest,aDestOffset,theRemains); //next copy rightmost data
|
||||
}
|
||||
|
||||
Free(aDest);
|
||||
@@ -245,9 +245,9 @@ void nsStr::Insert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUin
|
||||
}//if
|
||||
//else nothing to do!
|
||||
}
|
||||
else Append(aDest,aSource,0,aCount);
|
||||
else StrAppend(aDest,aSource,0,aCount);
|
||||
}
|
||||
else Append(aDest,aSource,0,aCount);
|
||||
else StrAppend(aDest,aSource,0,aCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -833,7 +833,7 @@ nsStringInfo::nsStringInfo(nsStr& str)
|
||||
: mCount(0)
|
||||
{
|
||||
nsStr::Initialize(mStr, str.mCharSize);
|
||||
nsStr::Assign(mStr, str, 0, -1);
|
||||
nsStr::StrAssign(mStr, str, 0, -1);
|
||||
// nsStr::Print(mStr, stdout);
|
||||
// fputc('\n', stdout);
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ struct NS_COM nsStr {
|
||||
* @param aCount tells us the (max) # of chars to copy
|
||||
* @param anAgent is the allocator to be used for alloc/free operations
|
||||
*/
|
||||
static void Append(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount);
|
||||
static void StrAppend(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount);
|
||||
|
||||
/**
|
||||
* These methods are used to assign contents of a source string to dest string
|
||||
@@ -295,7 +295,7 @@ struct NS_COM nsStr {
|
||||
* @param aCount tells us the (max) # of chars to copy
|
||||
* @param anAgent is the allocator to be used for alloc/free operations
|
||||
*/
|
||||
static void Assign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount);
|
||||
static void StrAssign(nsStr& aDest,const nsStr& aSource,PRUint32 anOffset,PRInt32 aCount);
|
||||
|
||||
/**
|
||||
* These methods are used to insert content from source string to the dest nsStr
|
||||
@@ -308,7 +308,19 @@ struct NS_COM nsStr {
|
||||
* @param aCount tells us the (max) # of chars to insert
|
||||
* @param anAgent is the allocator to be used for alloc/free operations
|
||||
*/
|
||||
static void Insert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PRUint32 aSrcOffset,PRInt32 aCount);
|
||||
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.
|
||||
|
||||
@@ -53,7 +53,7 @@ static void CSubsume(nsStr& aDest,nsStr& aSource){
|
||||
aSource.mStr=0;
|
||||
}
|
||||
else{
|
||||
nsStr::Assign(aDest,aSource,0,aSource.mLength);
|
||||
nsStr::StrAssign(aDest,aSource,0,aSource.mLength);
|
||||
}
|
||||
}
|
||||
else nsStr::Truncate(aDest,0);
|
||||
@@ -64,9 +64,16 @@ static void CSubsume(nsStr& aDest,nsStr& aSource){
|
||||
* Default constructor.
|
||||
*/
|
||||
nsCString::nsCString() {
|
||||
nsStr::Initialize(*this,eOneByte);
|
||||
Initialize(*this,eOneByte);
|
||||
}
|
||||
|
||||
#ifdef NEW_STRING_APIS
|
||||
nsCString::nsCString(const char* aCString) {
|
||||
Initialize(*this,eOneByte);
|
||||
Assign(aCString);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This constructor accepts an ascii string
|
||||
* @update gess 1/4/99
|
||||
@@ -74,10 +81,11 @@ nsCString::nsCString() {
|
||||
* @param aLength tells us how many chars to copy from given CString
|
||||
*/
|
||||
nsCString::nsCString(const char* aCString,PRInt32 aLength) {
|
||||
nsStr::Initialize(*this,eOneByte);
|
||||
Initialize(*this,eOneByte);
|
||||
Assign(aCString,aLength);
|
||||
}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* This constructor accepts a unicode string
|
||||
* @update gess 1/4/99
|
||||
@@ -85,7 +93,7 @@ nsCString::nsCString(const char* aCString,PRInt32 aLength) {
|
||||
* @param aLength tells us how many chars to copy from given aString
|
||||
*/
|
||||
nsCString::nsCString(const PRUnichar* aString,PRInt32 aLength) {
|
||||
nsStr::Initialize(*this,eOneByte);
|
||||
Initialize(*this,eOneByte);
|
||||
AssignWithConversion(aString,aLength);
|
||||
}
|
||||
|
||||
@@ -95,9 +103,10 @@ nsCString::nsCString(const PRUnichar* aString,PRInt32 aLength) {
|
||||
* @param reference to another nsCString
|
||||
*/
|
||||
nsCString::nsCString(const nsStr &aString) {
|
||||
nsStr::Initialize(*this,eOneByte);
|
||||
nsStr::Assign(*this,aString,0,aString.mLength);
|
||||
Initialize(*this,eOneByte);
|
||||
StrAssign(*this,aString,0,aString.mLength);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This is our copy constructor
|
||||
@@ -105,8 +114,8 @@ nsCString::nsCString(const nsStr &aString) {
|
||||
* @param reference to another nsCString
|
||||
*/
|
||||
nsCString::nsCString(const nsCString& aString) {
|
||||
nsStr::Initialize(*this,aString.mCharSize);
|
||||
nsStr::Assign(*this,aString,0,aString.mLength);
|
||||
Initialize(*this,aString.mCharSize);
|
||||
StrAssign(*this,aString,0,aString.mLength);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,7 +131,7 @@ nsCString::nsCString(nsSubsumeCStr& aSubsumeStr) {
|
||||
* Destructor
|
||||
*/
|
||||
nsCString::~nsCString() {
|
||||
nsStr::Destroy(*this);
|
||||
Destroy(*this);
|
||||
}
|
||||
|
||||
#ifdef NEW_STRING_APIS
|
||||
@@ -157,15 +166,11 @@ char* nsCString::GetWritableFragment( nsWritableFragment<char>& aFragment, nsFra
|
||||
}
|
||||
|
||||
nsCString::nsCString( const nsAReadableCString& aReadable ) {
|
||||
nsStr::Initialize(*this,eOneByte);
|
||||
Initialize(*this,eOneByte);
|
||||
Assign(aReadable);
|
||||
}
|
||||
#endif
|
||||
|
||||
void nsCString::AppendChar( char aChar ) {
|
||||
Append(aChar);
|
||||
}
|
||||
|
||||
void nsCString::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const {
|
||||
if (aResult) {
|
||||
*aResult = sizeof(*this) + mCapacity * mCharSize;
|
||||
@@ -271,7 +276,7 @@ PRBool nsCString::SetCharAt(PRUnichar aChar,PRUint32 anIndex){
|
||||
*/
|
||||
nsSubsumeCStr nsCString::operator+(const nsCString& aString){
|
||||
nsCString temp(*this); //make a temp string the same size as this...
|
||||
nsStr::Append(temp,aString,0,aString.mLength);
|
||||
nsStr::StrAppend(temp,aString,0,aString.mLength);
|
||||
return nsSubsumeCStr(temp);
|
||||
}
|
||||
|
||||
@@ -521,7 +526,7 @@ nsCString& nsCString::ReplaceSubstring(const nsCString& aTarget,const nsCString&
|
||||
//this is the worst case: the newvalue is larger than the substr it's replacing
|
||||
//so we have to insert some characters...
|
||||
PRInt32 theInsLen=aNewValue.mLength-aTarget.mLength;
|
||||
nsStr::Insert(*this,theIndex,aNewValue,0,theInsLen);
|
||||
StrInsert(*this,theIndex,aNewValue,0,theInsLen);
|
||||
}
|
||||
nsStr::Overwrite(*this,aNewValue,theIndex);
|
||||
}
|
||||
@@ -841,11 +846,10 @@ nsCString& nsCString::Assign(const nsStr& aString,PRInt32 aCount) {
|
||||
aCount=aString.mLength;
|
||||
else aCount=MinInt(aCount,aString.mLength);
|
||||
|
||||
nsStr::Assign(*this,aString,0,aCount);
|
||||
StrAssign(*this,aString,0,aCount);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* assign given char* to this string
|
||||
@@ -864,55 +868,6 @@ nsCString& nsCString::Assign(const char* aCString,PRInt32 aCount) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* assign given unichar* to this string
|
||||
* @update gess 01/04/99
|
||||
* @param aCString: buffer to be assigned to this
|
||||
* @param aCount -- length of given buffer or -1 if you want me to compute length.
|
||||
* NOTE: IFF you pass -1 as aCount, then your buffer must be null terminated.
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
void nsCString::AssignWithConversion(const PRUnichar* aString,PRInt32 aCount) {
|
||||
nsStr::Truncate(*this,0);
|
||||
|
||||
if(aString && aCount){
|
||||
nsStr temp;
|
||||
Initialize(temp,eTwoByte);
|
||||
temp.mUStr=(PRUnichar*)aString;
|
||||
|
||||
if(0<aCount) {
|
||||
temp.mLength=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,temp.mLength);
|
||||
if(kNotFound<len) {
|
||||
NS_WARNING(kPossibleNull);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
else aCount=temp.mLength=nsCRT::strlen(aString);
|
||||
|
||||
if(0<aCount)
|
||||
nsStr::Append(*this,temp,0,aCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* assign given unichar to this string
|
||||
* @update gess 01/04/99
|
||||
* @param aChar: char to be assignd to this
|
||||
* @return this
|
||||
*/
|
||||
void nsCString::AssignWithConversion(PRUnichar aChar) {
|
||||
nsStr::Truncate(*this,0);
|
||||
Append(aChar);
|
||||
}
|
||||
|
||||
/**
|
||||
* assign given char to this string
|
||||
* @update gess 01/04/99
|
||||
@@ -942,7 +897,58 @@ nsCString& nsCString::operator=(nsSubsumeCStr& aSubsumeString) {
|
||||
#endif // AIX
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* assign given unichar* to this string
|
||||
* @update gess 01/04/99
|
||||
* @param aCString: buffer to be assigned to this
|
||||
* @param aCount -- length of given buffer or -1 if you want me to compute length.
|
||||
* NOTE: IFF you pass -1 as aCount, then your buffer must be null terminated.
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
void nsCString::AssignWithConversion(const PRUnichar* aString,PRInt32 aCount) {
|
||||
nsStr::Truncate(*this,0);
|
||||
|
||||
if(aString && aCount){
|
||||
nsStr temp;
|
||||
nsStr::Initialize(temp,eTwoByte);
|
||||
temp.mUStr=(PRUnichar*)aString;
|
||||
|
||||
if(0<aCount) {
|
||||
temp.mLength=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,temp.mLength);
|
||||
if(kNotFound<len) {
|
||||
NS_WARNING(kPossibleNull);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
else aCount=temp.mLength=nsCRT::strlen(aString);
|
||||
|
||||
if(0<aCount)
|
||||
StrAppend(*this,temp,0,aCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* assign given unichar to this string
|
||||
* @update gess 01/04/99
|
||||
* @param aChar: char to be assignd to this
|
||||
* @return this
|
||||
*/
|
||||
void nsCString::AssignWithConversion(PRUnichar aChar) {
|
||||
nsStr::Truncate(*this,0);
|
||||
Append(aChar);
|
||||
}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* append given string to this string
|
||||
* @update gess 01/04/99
|
||||
@@ -954,7 +960,7 @@ nsCString& nsCString::Append(const nsCString& aString,PRInt32 aCount) {
|
||||
aCount=aString.mLength;
|
||||
else aCount=MinInt(aCount,aString.mLength);
|
||||
if(0<aCount)
|
||||
nsStr::Append(*this,aString,0,aCount);
|
||||
StrAppend(*this,aString,0,aCount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -971,7 +977,7 @@ nsCString& nsCString::Append(const nsStr& aString,PRInt32 aCount) {
|
||||
else aCount=MinInt(aCount,aString.mLength);
|
||||
|
||||
if(0<aCount)
|
||||
nsStr::Append(*this,aString,0,aCount);
|
||||
StrAppend(*this,aString,0,aCount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -987,7 +993,7 @@ nsCString& nsCString::Append(const nsStr& aString,PRInt32 aCount) {
|
||||
nsCString& nsCString::Append(const char* aCString,PRInt32 aCount) {
|
||||
if(aCString){
|
||||
nsStr temp;
|
||||
Initialize(temp,eOneByte);
|
||||
nsStr::Initialize(temp,eOneByte);
|
||||
temp.mStr=(char*)aCString;
|
||||
|
||||
if(0<aCount) {
|
||||
@@ -996,30 +1002,11 @@ nsCString& nsCString::Append(const char* aCString,PRInt32 aCount) {
|
||||
else aCount=temp.mLength=nsCRT::strlen(aCString);
|
||||
|
||||
if(0<aCount)
|
||||
nsStr::Append(*this,temp,0,aCount);
|
||||
StrAppend(*this,temp,0,aCount);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* append given char to this string
|
||||
* @update gess 01/04/99
|
||||
* @param aChar: char to be appended to this
|
||||
* @return this
|
||||
*/
|
||||
nsCString& nsCString::Append(PRUnichar aChar) {
|
||||
PRUnichar buf[2]={0,0};
|
||||
buf[0]=aChar;
|
||||
|
||||
nsStr temp;
|
||||
Initialize(temp,eTwoByte);
|
||||
temp.mUStr=buf;
|
||||
temp.mLength=1;
|
||||
nsStr::Append(*this,temp,0,1);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* append given unichar to this string
|
||||
* @update gess 01/04/99
|
||||
@@ -1031,12 +1018,30 @@ nsCString& nsCString::Append(char aChar) {
|
||||
buf[0]=aChar;
|
||||
|
||||
nsStr temp;
|
||||
Initialize(temp,eOneByte);
|
||||
nsStr::Initialize(temp,eOneByte);
|
||||
temp.mStr=buf;
|
||||
temp.mLength=1;
|
||||
nsStr::Append(*this,temp,0,1);
|
||||
StrAppend(*this,temp,0,1);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* append given char to this string
|
||||
* @update gess 01/04/99
|
||||
* @param aChar: char to be appended to this
|
||||
* @return this
|
||||
*/
|
||||
void nsCString::AppendWithConversion(PRUnichar aChar) {
|
||||
PRUnichar buf[2]={0,0};
|
||||
buf[0]=aChar;
|
||||
|
||||
nsStr temp;
|
||||
nsStr::Initialize(temp,eTwoByte);
|
||||
temp.mUStr=buf;
|
||||
temp.mLength=1;
|
||||
StrAppend(*this,temp,0,1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Append the given integer to this string
|
||||
@@ -1045,7 +1050,7 @@ nsCString& nsCString::Append(char aChar) {
|
||||
* @param aRadix:
|
||||
* @return
|
||||
*/
|
||||
nsCString& nsCString::Append(PRInt32 anInteger,PRInt32 aRadix) {
|
||||
void nsCString::AppendWithConversion(PRInt32 anInteger,PRInt32 aRadix) {
|
||||
|
||||
PRUint32 theInt=(PRUint32)anInteger;
|
||||
|
||||
@@ -1073,7 +1078,7 @@ nsCString& nsCString::Append(PRInt32 anInteger,PRInt32 aRadix) {
|
||||
theInt-=theDiv*mask1;
|
||||
mask1/=aRadix;
|
||||
}
|
||||
return Append(buf);
|
||||
Append(buf);
|
||||
}
|
||||
|
||||
|
||||
@@ -1083,12 +1088,12 @@ nsCString& nsCString::Append(PRInt32 anInteger,PRInt32 aRadix) {
|
||||
* @param aFloat:
|
||||
* @return
|
||||
*/
|
||||
nsCString& nsCString::Append(float aFloat){
|
||||
void nsCString::AppendWithConversion(float aFloat){
|
||||
char buf[40];
|
||||
// *** XX UNCOMMENT THIS LINE
|
||||
//PR_snprintf(buf, sizeof(buf), "%g", aFloat);
|
||||
sprintf(buf,"%g",aFloat);
|
||||
return Append(buf);
|
||||
Append(buf);
|
||||
}
|
||||
|
||||
|
||||
@@ -1104,7 +1109,7 @@ PRUint32 nsCString::Left(nsCString& aDest,PRInt32 aCount) const{
|
||||
if(aCount<0)
|
||||
aCount=mLength;
|
||||
else aCount=MinInt(aCount,mLength);
|
||||
nsStr::Assign(aDest,*this,0,aCount);
|
||||
StrAssign(aDest,*this,0,aCount);
|
||||
return aDest.mLength;
|
||||
}
|
||||
|
||||
@@ -1121,7 +1126,7 @@ PRUint32 nsCString::Mid(nsCString& aDest,PRUint32 anOffset,PRInt32 aCount) const
|
||||
if(aCount<0)
|
||||
aCount=mLength;
|
||||
else aCount=MinInt(aCount,mLength);
|
||||
nsStr::Assign(aDest,*this,anOffset,aCount);
|
||||
StrAssign(aDest,*this,anOffset,aCount);
|
||||
return aDest.mLength;
|
||||
}
|
||||
|
||||
@@ -1139,6 +1144,25 @@ PRUint32 nsCString::Right(nsCString& aDest,PRInt32 aCount) const{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert a single unichar into this string at a specified offset.
|
||||
*
|
||||
* @update gess4/22/98
|
||||
* @param aChar unichar to be inserted into this string
|
||||
* @param anOffset is insert pos in str
|
||||
* @return this
|
||||
*/
|
||||
void nsCString::InsertWithConversion(PRUnichar aChar,PRUint32 anOffset){
|
||||
PRUnichar theBuffer[2]={0,0};
|
||||
theBuffer[0]=aChar;
|
||||
nsStr temp;
|
||||
nsStr::Initialize(temp,eTwoByte);
|
||||
temp.mUStr=theBuffer;
|
||||
temp.mLength=1;
|
||||
StrInsert(*this,anOffset,temp,0,1);
|
||||
}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/*
|
||||
* This method inserts n chars from given string into this
|
||||
* string at str[anOffset].
|
||||
@@ -1151,7 +1175,7 @@ PRUint32 nsCString::Right(nsCString& aDest,PRInt32 aCount) const{
|
||||
*/
|
||||
nsCString& nsCString::Insert(const nsCString& aString,PRUint32 anOffset,PRInt32 aCount) {
|
||||
|
||||
nsStr::Insert(*this,anOffset,aString,0,aCount);
|
||||
StrInsert(*this,anOffset,aString,0,aCount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -1186,32 +1210,13 @@ nsCString& nsCString::Insert(const char* aCString,PRUint32 anOffset,PRInt32 aCou
|
||||
else aCount=temp.mLength=nsCRT::strlen(aCString);
|
||||
|
||||
if(temp.mLength && (0<aCount)){
|
||||
nsStr::Insert(*this,anOffset,temp,0,aCount);
|
||||
StrInsert(*this,anOffset,temp,0,aCount);
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert a single unichar into this string at a specified offset.
|
||||
*
|
||||
* @update gess4/22/98
|
||||
* @param aChar unichar to be inserted into this string
|
||||
* @param anOffset is insert pos in str
|
||||
* @return this
|
||||
*/
|
||||
nsCString& nsCString::Insert(PRUnichar aChar,PRUint32 anOffset){
|
||||
PRUnichar theBuffer[2]={0,0};
|
||||
theBuffer[0]=aChar;
|
||||
nsStr temp;
|
||||
nsStr::Initialize(temp,eTwoByte);
|
||||
temp.mUStr=theBuffer;
|
||||
temp.mLength=1;
|
||||
nsStr::Insert(*this,anOffset,temp,0,1);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a single uni-char into this string at
|
||||
* a specified offset.
|
||||
@@ -1228,9 +1233,11 @@ nsCString& nsCString::Insert(char aChar,PRUint32 anOffset){
|
||||
nsStr::Initialize(temp,eOneByte);
|
||||
temp.mStr=theBuffer;
|
||||
temp.mLength=1;
|
||||
nsStr::Insert(*this,anOffset,temp,0,1);
|
||||
StrInsert(*this,anOffset,temp,0,1);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* This method is used to cut characters in this string
|
||||
@@ -1810,7 +1817,7 @@ void nsCString::DebugDump(void) const {
|
||||
*
|
||||
*/
|
||||
nsCAutoString::nsCAutoString() : nsCString(){
|
||||
nsStr::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
|
||||
}
|
||||
@@ -1819,7 +1826,7 @@ nsCAutoString::nsCAutoString() : nsCString(){
|
||||
* Default constructor
|
||||
*/
|
||||
nsCAutoString::nsCAutoString(const nsCAutoString& aString) : nsCString() {
|
||||
nsStr::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aString);
|
||||
}
|
||||
@@ -1830,7 +1837,7 @@ nsCAutoString::nsCAutoString(const nsCAutoString& aString) : nsCString() {
|
||||
* @param aCString is a ptr to a 1-byte cstr
|
||||
*/
|
||||
nsCAutoString::nsCAutoString(const char* aCString,PRInt32 aLength) : nsCString() {
|
||||
nsStr::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aCString,aLength);
|
||||
}
|
||||
@@ -1841,21 +1848,22 @@ nsCAutoString::nsCAutoString(const char* aCString,PRInt32 aLength) : nsCString()
|
||||
*/
|
||||
nsCAutoString::nsCAutoString(const CBufDescriptor& aBuffer) : nsCString() {
|
||||
if(!aBuffer.mBuffer) {
|
||||
nsStr::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
}
|
||||
else {
|
||||
nsStr::Initialize(*this,aBuffer.mBuffer,aBuffer.mCapacity,aBuffer.mLength,aBuffer.mCharSize,!aBuffer.mStackBased);
|
||||
Initialize(*this,aBuffer.mBuffer,aBuffer.mCapacity,aBuffer.mLength,aBuffer.mCharSize,!aBuffer.mStackBased);
|
||||
}
|
||||
if(!aBuffer.mIsConst)
|
||||
AddNullTerminator(*this); //this isn't really needed, but it guarantees that folks don't pass string constants.
|
||||
}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* Copy construct from uni-string
|
||||
* @param aString is a ptr to a unistr
|
||||
*/
|
||||
nsCAutoString::nsCAutoString(const PRUnichar* aString,PRInt32 aLength) : nsCString() {
|
||||
nsStr::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aString,aLength);
|
||||
}
|
||||
@@ -1865,7 +1873,7 @@ nsCAutoString::nsCAutoString(const PRUnichar* aString,PRInt32 aLength) : nsCStri
|
||||
* @param
|
||||
*/
|
||||
nsCAutoString::nsCAutoString(const nsStr& aString) : nsCString() {
|
||||
nsStr::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aString);
|
||||
}
|
||||
@@ -1877,10 +1885,12 @@ nsCAutoString::nsCAutoString(const nsStr& aString) : nsCString() {
|
||||
* @param
|
||||
*/
|
||||
nsCAutoString::nsCAutoString(PRUnichar aChar) : nsCString(){
|
||||
nsStr::Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aChar);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* construct from a subsumeable string
|
||||
|
||||
@@ -50,6 +50,20 @@
|
||||
#else
|
||||
#define NS_LITERAL_STRING(s) (s)
|
||||
#define NS_LITERAL_CSTRING(s) (s)
|
||||
|
||||
inline
|
||||
char
|
||||
nsLiteralChar( char c )
|
||||
{
|
||||
return c;
|
||||
}
|
||||
|
||||
inline
|
||||
PRUnichar
|
||||
nsLiteralPRUnichar( PRUnichar c )
|
||||
{
|
||||
return c;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -65,34 +79,26 @@ class NS_COM nsCString :
|
||||
protected:
|
||||
virtual const char* GetReadableFragment( nsReadableFragment<char>&, nsFragmentRequest, PRUint32 ) const;
|
||||
virtual char* GetWritableFragment( nsWritableFragment<char>&, nsFragmentRequest, PRUint32 );
|
||||
|
||||
public:
|
||||
nsCString( const nsAReadableCString& );
|
||||
|
||||
#ifdef HAVE_AMBIGUITY_RESOLVING_CPP_USING
|
||||
using nsAWritableCString::Append;
|
||||
using nsAWritableCString::Insert;
|
||||
#else
|
||||
virtual void Append( const nsAReadableCString& aReadable ) {
|
||||
nsAWritableCString::Append(aReadable);
|
||||
}
|
||||
|
||||
virtual void Insert( const nsAReadableCString& aReadable, PRUint32 atPosition ) {
|
||||
nsAWritableCString::Insert(aReadable, atPosition);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
public:
|
||||
void AppendChar( char );
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
nsCString();
|
||||
|
||||
/**
|
||||
* This is our copy constructor
|
||||
* @param reference to another nsCString
|
||||
*/
|
||||
nsCString(const nsCString& aString);
|
||||
|
||||
#ifdef NEW_STRING_APIS
|
||||
nsCString( const nsAReadableCString& );
|
||||
|
||||
nsCString(const char*);
|
||||
nsCString(const char*, PRInt32);
|
||||
#else
|
||||
/**
|
||||
* This constructor accepts an isolatin string
|
||||
* @param aCString is a ptr to a 1-byte cstr
|
||||
@@ -110,12 +116,7 @@ public:
|
||||
* @param reference to another nsCString
|
||||
*/
|
||||
nsCString(const nsStr&);
|
||||
|
||||
/**
|
||||
* This is our copy constructor
|
||||
* @param reference to another nsCString
|
||||
*/
|
||||
nsCString(const nsCString& aString);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This constructor takes a subsumestr
|
||||
@@ -335,10 +336,10 @@ public:
|
||||
/**********************************************************************
|
||||
string conversion methods...
|
||||
*********************************************************************/
|
||||
#ifndef STASTANDALONE_STRING_TESTS
|
||||
//#ifndef STANDALONE_STRING_TESTS
|
||||
operator char*() {return mStr;}
|
||||
operator const char*() const {return (const char*)mStr;}
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
/**
|
||||
* This method constructs a new nsCString that is a clone
|
||||
@@ -399,91 +400,46 @@ public:
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
#ifdef NEW_STRING_APIS
|
||||
#ifdef HAVE_AMBIGUITY_RESOLVING_CPP_USING
|
||||
using nsAWritableCString::Assign;
|
||||
#else
|
||||
virtual void Assign( const nsAReadableCString& aReadable ) {
|
||||
nsAWritableCString::Assign(aReadable);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
nsCString& Assign(const char* aString,PRInt32 aCount=-1);
|
||||
nsCString& Assign(char aChar);
|
||||
|
||||
void AssignWithConversion(const PRUnichar*,PRInt32=-1);
|
||||
void AssignWithConversion(PRUnichar);
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsCString& Assign(const char* aString,PRInt32 aCount=-1);
|
||||
nsCString& Assign(char aChar);
|
||||
|
||||
nsCString& Assign(const nsStr& aString,PRInt32 aCount=-1);
|
||||
nsCString& Assign(const PRUnichar* aString,PRInt32 aCount=-1) { AssignWithConversion(aString, aCount); return *this; }
|
||||
nsCString& Assign(PRUnichar aChar) { AssignWithConversion(aChar); return *this; }
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Functionally equivalent to assign or operator=
|
||||
*
|
||||
*/
|
||||
nsCString& SetString(const char* aString,PRInt32 aLength=-1) {return Assign(aString,aLength);}
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsCString& SetString(const nsStr& aString,PRInt32 aLength=-1) {return Assign(aString,aLength);}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* here come a bunch of assignment operators...
|
||||
* @param aString: string to be added to this
|
||||
* @return this
|
||||
*/
|
||||
#ifdef NEW_STRING_APIS
|
||||
#ifdef HAVE_AMBIGUITY_RESOLVING_CPP_USING
|
||||
using nsAWritableCString::operator=;
|
||||
#else
|
||||
nsCString& operator=( const nsAReadableCString& aReadable ) { nsAWritableCString::operator=(aReadable); return *this; }
|
||||
#endif
|
||||
#endif
|
||||
nsCString& operator=(PRUnichar aChar) {return Assign(aChar);}
|
||||
nsCString& operator=(char aChar) {AssignWithConversion(aChar); return *this;}
|
||||
nsCString& operator=(const PRUnichar* aString) {AssignWithConversion(aString); return *this;}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsCString& operator=(const nsCString& aString) {return Assign(aString);}
|
||||
nsCString& operator=(const nsStr& aString) {return Assign(aString);}
|
||||
nsCString& operator=(const char* aCString) {return Assign(aCString);}
|
||||
#endif
|
||||
|
||||
// Yes, I know this makes assignment from a |nsSubsumeString| not do the special thing
|
||||
// |nsSubsumeString| needs to go away
|
||||
#ifdef AIX
|
||||
nsCString& operator=(const nsSubsumeCStr& aSubsumeString); // AIX requires a const here
|
||||
#else
|
||||
nsCString& operator=(nsSubsumeCStr& aSubsumeString);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Here's a bunch of methods that append varying types...
|
||||
* @param various...
|
||||
* @return this
|
||||
*/
|
||||
#ifdef NEW_STRING_APIS
|
||||
#ifdef HAVE_AMBIGUITY_RESOLVING_CPP_USING
|
||||
using nsAWritableCString::operator+=;
|
||||
#else
|
||||
nsCString& operator+=( const nsAReadableCString& aReadable ) { nsAWritableCString::operator+=(aReadable); return *this; }
|
||||
#endif
|
||||
#endif
|
||||
nsCString& operator+=(const PRUnichar aChar){return Append(aChar);}
|
||||
nsCString& operator+=(const char aChar){return Append(aChar);}
|
||||
nsCString& operator+=(const int anInt){return Append(anInt,10);}
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsCString& operator+=(const nsCString& aString){return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsCString& operator+=(const char* aCString) {return Append(aCString);}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Appends n characters from given string to this,
|
||||
* This version computes the length of your given string
|
||||
*
|
||||
* @param aString is the source to be appended to this
|
||||
* @return number of chars copied
|
||||
*/
|
||||
nsCString& Append(const nsCString& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
|
||||
|
||||
/*
|
||||
@@ -495,13 +451,35 @@ public:
|
||||
*
|
||||
* @return number of chars copied
|
||||
*/
|
||||
nsCString& Append(const nsCString& aString,PRInt32 aCount);
|
||||
|
||||
void AppendWithConversion(PRInt32 aInteger,PRInt32 aRadix=10); //radix=8,10 or 16
|
||||
void AppendWithConversion(float aFloat);
|
||||
void AppendWithConversion(PRUnichar aChar);
|
||||
// Why no |AppendWithConversion(const PRUnichar*)|?
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsCString& Append(const nsStr& aString,PRInt32 aCount=-1);
|
||||
nsCString& Append(const nsCString& aString,PRInt32 aCount);
|
||||
nsCString& Append(const nsCString& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsCString& Append(const char* aString,PRInt32 aCount=-1);
|
||||
nsCString& Append(PRUnichar aChar);
|
||||
nsCString& Append(char aChar);
|
||||
nsCString& Append(PRInt32 aInteger,PRInt32 aRadix=10); //radix=8,10 or 16
|
||||
nsCString& Append(float aFloat);
|
||||
|
||||
nsCString& Append(PRUnichar aChar) {AppendWithConversion(aChar); return *this;}
|
||||
nsCString& Append(PRInt32 aInteger,PRInt32 aRadix=10) {AppendWithConversion(aInteger,aRadix); return *this;}
|
||||
nsCString& Append(float aFloat) {AppendWithConversion(aFloat); return *this;}
|
||||
|
||||
/**
|
||||
* Here's a bunch of methods that append varying types...
|
||||
* @param various...
|
||||
* @return this
|
||||
*/
|
||||
nsCString& operator+=(const nsCString& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsCString& operator+=(const char* aCString) {return Append(aCString);}
|
||||
|
||||
nsCString& operator+=(const PRUnichar aChar) {return Append(aChar);}
|
||||
nsCString& operator+=(const char aChar) {return Append(aChar);}
|
||||
nsCString& operator+=(const int anInt) {return Append(anInt,10);}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copies n characters from this string to given string,
|
||||
@@ -537,6 +515,10 @@ public:
|
||||
*/
|
||||
PRUint32 Right(nsCString& aCopy,PRInt32 aCount) const;
|
||||
|
||||
void InsertWithConversion(PRUnichar aChar,PRUint32 anOffset);
|
||||
// Why no |InsertWithConversion(PRUnichar*)|?
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/*
|
||||
* This method inserts n chars from given string into this
|
||||
* string at str[anOffset].
|
||||
@@ -568,8 +550,9 @@ public:
|
||||
* @param anOffset is insert pos in str
|
||||
* @return the number of chars inserted into this string
|
||||
*/
|
||||
nsCString& Insert(PRUnichar aChar,PRUint32 anOffset);
|
||||
nsCString& Insert(PRUnichar aChar,PRUint32 anOffset) {InsertWithConversion(aChar,anOffset); return *this;}
|
||||
nsCString& Insert(char aChar,PRUint32 anOffset);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This method is used to cut characters in this string
|
||||
@@ -781,12 +764,18 @@ extern NS_COM int fputs(const nsCString& aString, FILE* out);
|
||||
class NS_COM nsCAutoString : public nsCString {
|
||||
public:
|
||||
|
||||
virtual ~nsCAutoString();
|
||||
|
||||
nsCAutoString();
|
||||
nsCAutoString(const nsCAutoString& aString);
|
||||
nsCAutoString(const char* aString,PRInt32 aLength=-1);
|
||||
nsCAutoString(const CBufDescriptor& aBuffer);
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsCAutoString(const PRUnichar* aString,PRInt32 aLength=-1);
|
||||
nsCAutoString(const nsStr& aString);
|
||||
nsCAutoString(const nsCAutoString& aString);
|
||||
nsCAutoString(PRUnichar aChar);
|
||||
#endif
|
||||
|
||||
#ifdef AIX
|
||||
nsCAutoString(const nsSubsumeCStr& aSubsumeStr); // AIX requires a const
|
||||
@@ -794,8 +783,6 @@ public:
|
||||
nsCAutoString(nsSubsumeCStr& aSubsumeStr);
|
||||
#endif // AIX
|
||||
|
||||
nsCAutoString(PRUnichar aChar);
|
||||
virtual ~nsCAutoString();
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsCAutoString& operator=(const nsCAutoString& aString) {nsCString::Assign(aString); return *this;}
|
||||
|
||||
@@ -52,7 +52,7 @@ static void Subsume(nsStr& aDest,nsStr& aSource){
|
||||
aSource.mStr=0;
|
||||
}
|
||||
else{
|
||||
nsStr::Assign(aDest,aSource,0,aSource.mLength);
|
||||
nsStr::StrAssign(aDest,aSource,0,aSource.mLength);
|
||||
}
|
||||
}
|
||||
else nsStr::Truncate(aDest,0);
|
||||
@@ -63,9 +63,10 @@ static void Subsume(nsStr& aDest,nsStr& aSource){
|
||||
* Default constructor.
|
||||
*/
|
||||
nsString::nsString() {
|
||||
nsStr::Initialize(*this,eTwoByte);
|
||||
Initialize(*this,eTwoByte);
|
||||
}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* This constructor accepts an ascii string
|
||||
* @update gess 1/4/99
|
||||
@@ -73,9 +74,17 @@ nsString::nsString() {
|
||||
* @param aLength tells us how many chars to copy from given CString
|
||||
*/
|
||||
nsString::nsString(const char* aCString,PRInt32 aCount){
|
||||
nsStr::Initialize(*this,eTwoByte);
|
||||
Initialize(*this,eTwoByte);
|
||||
AssignWithConversion(aCString,aCount);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NEW_STRING_APIS
|
||||
nsString::nsString(const PRUnichar* aString) {
|
||||
Initialize(*this,eTwoByte);
|
||||
Assign(aString);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This constructor accepts a unicode string
|
||||
@@ -84,19 +93,21 @@ nsString::nsString(const char* aCString,PRInt32 aCount){
|
||||
* @param aLength tells us how many chars to copy from given aString
|
||||
*/
|
||||
nsString::nsString(const PRUnichar* aString,PRInt32 aCount) {
|
||||
nsStr::Initialize(*this,eTwoByte);
|
||||
Initialize(*this,eTwoByte);
|
||||
Assign(aString,aCount);
|
||||
}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* This constructor works for all other nsSTr derivatives
|
||||
* @update gess 1/4/99
|
||||
* @param reference to another nsCString
|
||||
*/
|
||||
nsString::nsString(const nsStr &aString) {
|
||||
nsStr::Initialize(*this,eTwoByte);
|
||||
nsStr::Assign(*this,aString,0,aString.mLength);
|
||||
Initialize(*this,eTwoByte);
|
||||
StrAssign(*this,aString,0,aString.mLength);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This is our copy constructor
|
||||
@@ -104,8 +115,8 @@ nsString::nsString(const nsStr &aString) {
|
||||
* @param reference to another nsString
|
||||
*/
|
||||
nsString::nsString(const nsString& aString) {
|
||||
nsStr::Initialize(*this,eTwoByte);
|
||||
nsStr::Assign(*this,aString,0,aString.mLength);
|
||||
Initialize(*this,eTwoByte);
|
||||
StrAssign(*this,aString,0,aString.mLength);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,13 +126,13 @@ nsString::nsString(const nsString& aString) {
|
||||
*/
|
||||
#ifdef AIX
|
||||
nsString::nsString(const nsSubsumeStr& aSubsumeStr) {
|
||||
nsStr::Initialize(*this,eTwoByte);
|
||||
Initialize(*this,eTwoByte);
|
||||
|
||||
nsSubsumeStr temp(aSubsumeStr); // a temp is needed for the AIX compiler
|
||||
Subsume(*this,temp);
|
||||
#else
|
||||
nsString::nsString(nsSubsumeStr& aSubsumeStr) {
|
||||
nsStr::Initialize(*this,eTwoByte);
|
||||
Initialize(*this,eTwoByte);
|
||||
|
||||
Subsume(*this,aSubsumeStr);
|
||||
#endif /* AIX */
|
||||
@@ -167,15 +178,11 @@ PRUnichar* nsString::GetWritableFragment( nsWritableFragment<PRUnichar>& aFragme
|
||||
}
|
||||
|
||||
nsString::nsString( const nsAReadableString& aReadable ) {
|
||||
nsStr::Initialize(*this,eTwoByte);
|
||||
Initialize(*this,eTwoByte);
|
||||
Assign(aReadable);
|
||||
}
|
||||
#endif
|
||||
|
||||
void nsString::AppendChar( PRUnichar aChar ) {
|
||||
Append(aChar);
|
||||
}
|
||||
|
||||
void nsString::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const {
|
||||
if (aResult) {
|
||||
*aResult = sizeof(*this) + mCapacity * mCharSize;
|
||||
@@ -305,7 +312,7 @@ PRBool nsString::SetCharAt(PRUnichar aChar,PRUint32 anIndex){
|
||||
*/
|
||||
nsSubsumeStr nsString::operator+(const nsStr& aString){
|
||||
nsString temp(*this); //make a temp string the same size as this...
|
||||
nsStr::Append(temp,aString,0,aString.mLength);
|
||||
nsStr::StrAppend(temp,aString,0,aString.mLength);
|
||||
return nsSubsumeStr(temp);
|
||||
}
|
||||
|
||||
@@ -317,7 +324,7 @@ nsSubsumeStr nsString::operator+(const nsStr& aString){
|
||||
*/
|
||||
nsSubsumeStr nsString::operator+(const nsString& aString){
|
||||
nsString temp(*this); //make a temp string the same size as this...
|
||||
nsStr::Append(temp,aString,0,aString.mLength);
|
||||
nsStr::StrAppend(temp,aString,0,aString.mLength);
|
||||
return nsSubsumeStr(temp);
|
||||
}
|
||||
|
||||
@@ -584,7 +591,7 @@ nsString& nsString::ReplaceSubstring(const nsString& aTarget,const nsString& aNe
|
||||
//this is the worst case: the newvalue is larger than the substr it's replacing
|
||||
//so we have to insert some characters...
|
||||
PRInt32 theInsLen=aNewValue.mLength-aTarget.mLength;
|
||||
nsStr::Insert(*this,theIndex,aNewValue,0,theInsLen);
|
||||
StrInsert(*this,theIndex,aNewValue,0,theInsLen);
|
||||
}
|
||||
nsStr::Overwrite(*this,aNewValue,theIndex);
|
||||
}
|
||||
@@ -833,7 +840,7 @@ char* nsString::ToCString(char* aBuf, PRUint32 aBufLength,PRUint32 anOffset) con
|
||||
|
||||
CBufDescriptor theDescr(aBuf,PR_TRUE,aBufLength,0);
|
||||
nsCAutoString temp(theDescr);
|
||||
nsStr::Assign(temp, *this, anOffset, aBufLength-1);
|
||||
nsStr::StrAssign(temp, *this, anOffset, aBufLength-1);
|
||||
temp.mStr=0;
|
||||
}
|
||||
return aBuf;
|
||||
@@ -977,13 +984,13 @@ PRInt32 nsString::ToInteger(PRInt32* anErrorCode,PRUint32 aRadix) const {
|
||||
*********************************************************************/
|
||||
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* assign given nsStr (or derivative) to this one
|
||||
* @update gess 01/04/99
|
||||
* @param aString: nsStr to be appended
|
||||
* @return this
|
||||
*/
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsString& nsString::Assign(const nsStr& aString,PRInt32 aCount) {
|
||||
if(this!=&aString){
|
||||
nsStr::Truncate(*this,0);
|
||||
@@ -992,7 +999,7 @@ nsString& nsString::Assign(const nsStr& aString,PRInt32 aCount) {
|
||||
aCount=aString.mLength;
|
||||
else aCount=MinInt(aCount,aString.mLength);
|
||||
|
||||
nsStr::Assign(*this,aString,0,aCount);
|
||||
StrAssign(*this,aString,0,aCount);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@@ -1010,10 +1017,20 @@ nsString& nsString::Assign(const nsStr& aString,PRInt32 aCount) {
|
||||
void nsString::AssignWithConversion(const char* aCString,PRInt32 aCount) {
|
||||
nsStr::Truncate(*this,0);
|
||||
if(aCString){
|
||||
Append(aCString,aCount);
|
||||
AppendWithConversion(aCString,aCount);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NEW_STRING_APIS
|
||||
void nsString::AssignWithConversion(const char* aCString) {
|
||||
nsStr::Truncate(*this,0);
|
||||
if(aCString){
|
||||
AppendWithConversion(aCString);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* assign given unichar* to this string
|
||||
* @update gess 01/04/99
|
||||
@@ -1030,6 +1047,7 @@ nsString& nsString::Assign(const PRUnichar* aString,PRInt32 aCount) {
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* assign given char to this string
|
||||
@@ -1039,9 +1057,10 @@ nsString& nsString::Assign(const PRUnichar* aString,PRInt32 aCount) {
|
||||
*/
|
||||
void nsString::AssignWithConversion(char aChar) {
|
||||
nsStr::Truncate(*this,0);
|
||||
Append(aChar);
|
||||
AppendWithConversion(aChar);
|
||||
}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* assign given unichar to this string
|
||||
* @update gess 01/04/99
|
||||
@@ -1052,7 +1071,9 @@ nsString& nsString::Assign(PRUnichar aChar) {
|
||||
nsStr::Truncate(*this,0);
|
||||
return Append(aChar);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* WARNING! THIS IS A VERY SPECIAL METHOD.
|
||||
* This method "steals" the contents of aSource and hands it to aDest.
|
||||
@@ -1071,40 +1092,7 @@ nsString& nsString::operator=(const nsSubsumeStr& aSubsumeString) {
|
||||
#endif // AIX
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* append given string to this string;
|
||||
* @update gess 01/04/99
|
||||
* @param aString : string to be appended to this
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Append(const nsStr& aString,PRInt32 aCount) {
|
||||
|
||||
if(aCount<0)
|
||||
aCount=aString.mLength;
|
||||
else aCount=MinInt(aCount,aString.mLength);
|
||||
|
||||
if(0<aCount)
|
||||
nsStr::Append(*this,aString,0,aCount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* append given string to this string
|
||||
* I don't think we need this method now that we have the previous one.
|
||||
* @update gess 01/04/99
|
||||
* @param aString : string to be appended to this
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Append(const nsString& aString,PRInt32 aCount) {
|
||||
if(aCount<0)
|
||||
aCount=aString.mLength;
|
||||
else aCount=MinInt(aCount,aString.mLength);
|
||||
if(0<aCount)
|
||||
nsStr::Append(*this,aString,0,aCount);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* append given c-string to this string
|
||||
@@ -1115,10 +1103,10 @@ nsString& nsString::Append(const nsString& aString,PRInt32 aCount) {
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Append(const char* aCString,PRInt32 aCount) {
|
||||
void nsString::AppendWithConversion(const char* aCString,PRInt32 aCount) {
|
||||
if(aCString && aCount){ //if astring is null or count==0 there's nothing to do
|
||||
nsStr temp;
|
||||
Initialize(temp,eOneByte);
|
||||
nsStr::Initialize(temp,eOneByte);
|
||||
temp.mStr=(char*)aCString;
|
||||
|
||||
if(0<aCount) {
|
||||
@@ -1138,45 +1126,8 @@ nsString& nsString::Append(const char* aCString,PRInt32 aCount) {
|
||||
else aCount=temp.mLength=nsCRT::strlen(aCString);
|
||||
|
||||
if(0<aCount)
|
||||
nsStr::Append(*this,temp,0,aCount);
|
||||
StrAppend(*this,temp,0,aCount);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* append given unicode string to this
|
||||
* @update gess 01/04/99
|
||||
* @param aString : string to be appended to this
|
||||
* @param aCount -- length of given buffer or -1 if you want me to compute length.
|
||||
* NOTE: IFF you pass -1 as aCount, then your buffer must be null terminated.
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Append(const PRUnichar* aString,PRInt32 aCount) {
|
||||
if(aString && aCount){ //if astring is null or count==0 there's nothing to do
|
||||
nsStr temp;
|
||||
Initialize(temp,eTwoByte);
|
||||
temp.mUStr=(PRUnichar*)aString;
|
||||
|
||||
if(0<aCount) {
|
||||
temp.mLength=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,temp.mLength);
|
||||
if(kNotFound<len) {
|
||||
NS_WARNING(kPossibleNull);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
else aCount=temp.mLength=nsCRT::strlen(aString);
|
||||
|
||||
if(0<aCount)
|
||||
nsStr::Append(*this,temp,0,aCount);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1185,34 +1136,15 @@ nsString& nsString::Append(const PRUnichar* aString,PRInt32 aCount) {
|
||||
* @param aChar: char to be appended
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Append(char aChar) {
|
||||
void nsString::AppendWithConversion(char aChar) {
|
||||
char buf[2]={0,0};
|
||||
buf[0]=aChar;
|
||||
|
||||
nsStr temp;
|
||||
Initialize(temp,eOneByte);
|
||||
nsStr::Initialize(temp,eOneByte);
|
||||
temp.mStr=buf;
|
||||
temp.mLength=1;
|
||||
nsStr::Append(*this,temp,0,1);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* append given unichar to this string
|
||||
* @update gess 01/04/99
|
||||
* @param aChar: char to be appended to this
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Append(PRUnichar aChar) {
|
||||
PRUnichar buf[2]={0,0};
|
||||
buf[0]=aChar;
|
||||
|
||||
nsStr temp;
|
||||
Initialize(temp,eTwoByte);
|
||||
temp.mUStr=buf;
|
||||
temp.mLength=1;
|
||||
nsStr::Append(*this,temp,0,1);
|
||||
return *this;
|
||||
StrAppend(*this,temp,0,1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1222,7 +1154,7 @@ nsString& nsString::Append(PRUnichar aChar) {
|
||||
* @param aRadix:
|
||||
* @return
|
||||
*/
|
||||
nsString& nsString::Append(PRInt32 anInteger,PRInt32 aRadix) {
|
||||
void nsString::AppendWithConversion(PRInt32 anInteger,PRInt32 aRadix) {
|
||||
|
||||
PRUint32 theInt=(PRUint32)anInteger;
|
||||
|
||||
@@ -1250,7 +1182,7 @@ nsString& nsString::Append(PRInt32 anInteger,PRInt32 aRadix) {
|
||||
theInt-=theDiv*mask1;
|
||||
mask1/=aRadix;
|
||||
}
|
||||
return Append(buf);
|
||||
AppendWithConversion(buf);
|
||||
}
|
||||
|
||||
|
||||
@@ -1260,16 +1192,105 @@ nsString& nsString::Append(PRInt32 anInteger,PRInt32 aRadix) {
|
||||
* @param aFloat:
|
||||
* @return
|
||||
*/
|
||||
nsString& nsString::Append(float aFloat){
|
||||
void nsString::AppendWithConversion(float aFloat){
|
||||
char buf[40];
|
||||
// *** XX UNCOMMENT THIS LINE
|
||||
//PR_snprintf(buf, sizeof(buf), "%g", aFloat);
|
||||
sprintf(buf,"%g",aFloat);
|
||||
Append(buf);
|
||||
AppendWithConversion(buf);
|
||||
}
|
||||
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* append given string to this string;
|
||||
* @update gess 01/04/99
|
||||
* @param aString : string to be appended to this
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Append(const nsStr& aString,PRInt32 aCount) {
|
||||
|
||||
if(aCount<0)
|
||||
aCount=aString.mLength;
|
||||
else aCount=MinInt(aCount,aString.mLength);
|
||||
|
||||
if(0<aCount)
|
||||
StrAppend(*this,aString,0,aCount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* append given string to this string
|
||||
* I don't think we need this method now that we have the previous one.
|
||||
* @update gess 01/04/99
|
||||
* @param aString : string to be appended to this
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Append(const nsString& aString,PRInt32 aCount) {
|
||||
if(aCount<0)
|
||||
aCount=aString.mLength;
|
||||
else aCount=MinInt(aCount,aString.mLength);
|
||||
if(0<aCount)
|
||||
StrAppend(*this,aString,0,aCount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* append given unicode string to this
|
||||
* @update gess 01/04/99
|
||||
* @param aString : string to be appended to this
|
||||
* @param aCount -- length of given buffer or -1 if you want me to compute length.
|
||||
* NOTE: IFF you pass -1 as aCount, then your buffer must be null terminated.
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Append(const PRUnichar* aString,PRInt32 aCount) {
|
||||
if(aString && aCount){ //if astring is null or count==0 there's nothing to do
|
||||
nsStr temp;
|
||||
nsStr::Initialize(temp,eTwoByte);
|
||||
temp.mUStr=(PRUnichar*)aString;
|
||||
|
||||
if(0<aCount) {
|
||||
temp.mLength=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,temp.mLength);
|
||||
if(kNotFound<len) {
|
||||
NS_WARNING(kPossibleNull);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
else aCount=temp.mLength=nsCRT::strlen(aString);
|
||||
|
||||
if(0<aCount)
|
||||
StrAppend(*this,temp,0,aCount);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* append given unichar to this string
|
||||
* @update gess 01/04/99
|
||||
* @param aChar: char to be appended to this
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Append(PRUnichar aChar) {
|
||||
PRUnichar buf[2]={0,0};
|
||||
buf[0]=aChar;
|
||||
|
||||
nsStr temp;
|
||||
nsStr::Initialize(temp,eTwoByte);
|
||||
temp.mUStr=buf;
|
||||
temp.mLength=1;
|
||||
StrAppend(*this,temp,0,1);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copies n characters from this left of this string to given string,
|
||||
*
|
||||
@@ -1283,7 +1304,7 @@ PRUint32 nsString::Left(nsString& aDest,PRInt32 aCount) const{
|
||||
if(aCount<0)
|
||||
aCount=mLength;
|
||||
else aCount=MinInt(aCount,mLength);
|
||||
nsStr::Assign(aDest,*this,0,aCount);
|
||||
nsStr::StrAssign(aDest,*this,0,aCount);
|
||||
|
||||
return aDest.mLength;
|
||||
}
|
||||
@@ -1301,7 +1322,7 @@ PRUint32 nsString::Mid(nsString& aDest,PRUint32 anOffset,PRInt32 aCount) const{
|
||||
if(aCount<0)
|
||||
aCount=mLength;
|
||||
else aCount=MinInt(aCount,mLength);
|
||||
nsStr::Assign(aDest,*this,anOffset,aCount);
|
||||
nsStr::StrAssign(aDest,*this,anOffset,aCount);
|
||||
|
||||
return aDest.mLength;
|
||||
}
|
||||
@@ -1320,20 +1341,6 @@ PRUint32 nsString::Right(nsString& aDest,PRInt32 aCount) const{
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This method inserts n chars from given string into this
|
||||
* string at str[anOffset].
|
||||
*
|
||||
* @update gess 4/1/98
|
||||
* @param aString -- source String to be inserted into this
|
||||
* @param anOffset -- insertion position within this str
|
||||
* @param aCount -- number of chars to be copied from aCopy
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Insert(const nsString& aCopy,PRUint32 anOffset,PRInt32 aCount) {
|
||||
nsStr::Insert(*this,anOffset,aCopy,0,aCount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a char* into this string at a specified offset.
|
||||
@@ -1346,7 +1353,7 @@ nsString& nsString::Insert(const nsString& aCopy,PRUint32 anOffset,PRInt32 aCoun
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Insert(const char* aCString,PRUint32 anOffset,PRInt32 aCount){
|
||||
void nsString::InsertWithConversion(const char* aCString,PRUint32 anOffset,PRInt32 aCount){
|
||||
if(aCString && aCount){
|
||||
nsStr temp;
|
||||
nsStr::Initialize(temp,eOneByte);
|
||||
@@ -1368,10 +1375,25 @@ nsString& nsString::Insert(const char* aCString,PRUint32 anOffset,PRInt32 aCount
|
||||
else aCount=temp.mLength=nsCRT::strlen(aCString);
|
||||
|
||||
if(0<aCount){
|
||||
nsStr::Insert(*this,anOffset,temp,0,aCount);
|
||||
StrInsert(*this,anOffset,temp,0,aCount);
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/*
|
||||
* This method inserts n chars from given string into this
|
||||
* string at str[anOffset].
|
||||
*
|
||||
* @update gess 4/1/98
|
||||
* @param aString -- source String to be inserted into this
|
||||
* @param anOffset -- insertion position within this str
|
||||
* @param aCount -- number of chars to be copied from aCopy
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Insert(const nsString& aCopy,PRUint32 anOffset,PRInt32 aCount) {
|
||||
StrInsert(*this,anOffset,aCopy,0,aCount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@@ -1408,7 +1430,7 @@ nsString& nsString::Insert(const PRUnichar* aString,PRUint32 anOffset,PRInt32 aC
|
||||
else aCount=temp.mLength=nsCRT::strlen(aString);
|
||||
|
||||
if(0<aCount){
|
||||
nsStr::Insert(*this,anOffset,temp,0,aCount);
|
||||
StrInsert(*this,anOffset,temp,0,aCount);
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
@@ -1431,9 +1453,10 @@ nsString& nsString::Insert(PRUnichar aChar,PRUint32 anOffset){
|
||||
nsStr::Initialize(temp,eTwoByte);
|
||||
temp.mUStr=theBuffer;
|
||||
temp.mLength=1;
|
||||
nsStr::Insert(*this,anOffset,temp,0,1);
|
||||
StrInsert(*this,anOffset,temp,0,1);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This method is used to cut characters in this string
|
||||
@@ -2224,7 +2247,7 @@ void nsString::DebugDump(void) const {
|
||||
nsCAutoString temp;
|
||||
|
||||
if(eTwoByte==mCharSize) {
|
||||
nsStr::Assign(temp, *this, 0, mLength);
|
||||
nsStr::StrAssign(temp, *this, 0, mLength);
|
||||
theBuffer=temp.GetBuffer();
|
||||
}
|
||||
|
||||
@@ -2245,28 +2268,17 @@ void nsString::DebugDump(void) const {
|
||||
*
|
||||
*/
|
||||
nsAutoString::nsAutoString() : nsString() {
|
||||
nsStr::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy construct from ascii c-string
|
||||
* @param aCString is a ptr to a 1-byte cstr
|
||||
* @param aLength tells us how many chars to copy from aCString
|
||||
*/
|
||||
nsAutoString::nsAutoString(const char* aCString,PRInt32 aLength) : nsString() {
|
||||
nsStr::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aCString,aLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy construct from uni-string
|
||||
* @param aString is a ptr to a unistr
|
||||
* @param aLength tells us how many chars to copy from aString
|
||||
*/
|
||||
nsAutoString::nsAutoString(const PRUnichar* aString,PRInt32 aLength) : nsString() {
|
||||
nsStr::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aString,aLength);
|
||||
}
|
||||
@@ -2277,31 +2289,44 @@ nsAutoString::nsAutoString(const PRUnichar* aString,PRInt32 aLength) : nsString(
|
||||
*/
|
||||
nsAutoString::nsAutoString(const CBufDescriptor& aBuffer) : nsString() {
|
||||
if(!aBuffer.mBuffer) {
|
||||
nsStr::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
}
|
||||
else {
|
||||
nsStr::Initialize(*this,aBuffer.mBuffer,aBuffer.mCapacity,aBuffer.mLength,aBuffer.mCharSize,!aBuffer.mStackBased);
|
||||
Initialize(*this,aBuffer.mBuffer,aBuffer.mCapacity,aBuffer.mLength,aBuffer.mCharSize,!aBuffer.mStackBased);
|
||||
}
|
||||
if(!aBuffer.mIsConst)
|
||||
AddNullTerminator(*this);
|
||||
}
|
||||
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/**
|
||||
* Copy construct from ascii c-string
|
||||
* @param aCString is a ptr to a 1-byte cstr
|
||||
* @param aLength tells us how many chars to copy from aCString
|
||||
*/
|
||||
nsAutoString::nsAutoString(const char* aCString,PRInt32 aLength) : nsString() {
|
||||
Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aCString,aLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy construct from an nsStr
|
||||
* @param
|
||||
*/
|
||||
nsAutoString::nsAutoString(const nsStr& aString) : nsString() {
|
||||
nsStr::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aString);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Default copy constructor
|
||||
*/
|
||||
nsAutoString::nsAutoString(const nsAutoString& aString) : nsString() {
|
||||
nsStr::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aString);
|
||||
}
|
||||
@@ -2312,7 +2337,7 @@ nsAutoString::nsAutoString(const nsAutoString& aString) : nsString() {
|
||||
* @param
|
||||
*/
|
||||
nsAutoString::nsAutoString(PRUnichar aChar) : nsString(){
|
||||
nsStr::Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aChar);
|
||||
}
|
||||
|
||||
@@ -65,38 +65,36 @@ class NS_COM nsString :
|
||||
#endif
|
||||
public nsStr {
|
||||
|
||||
#ifdef NEW_STRING_APIS
|
||||
protected:
|
||||
#ifdef NEW_STRING_APIS
|
||||
virtual const PRUnichar* GetReadableFragment( nsReadableFragment<PRUnichar>&, nsFragmentRequest, PRUint32 ) const;
|
||||
virtual PRUnichar* GetWritableFragment( nsWritableFragment<PRUnichar>&, nsFragmentRequest, PRUint32 );
|
||||
|
||||
public:
|
||||
nsString( const nsAReadableString& );
|
||||
|
||||
#ifdef HAVE_AMBIGUITY_RESOLVING_CPP_USING
|
||||
using nsAWritableString::Append;
|
||||
using nsAWritableString::Insert;
|
||||
#else
|
||||
virtual void Append( const nsAReadableString& aReadable ) {
|
||||
nsAWritableString::Append(aReadable);
|
||||
}
|
||||
|
||||
virtual void Insert( const nsAReadableString& aReadable, PRUint32 atPosition ) {
|
||||
nsAWritableString::Insert(aReadable, atPosition);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
public:
|
||||
void AppendChar( PRUnichar );
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
nsString();
|
||||
|
||||
/**
|
||||
* This is our copy constructor
|
||||
* @param reference to another nsString
|
||||
*/
|
||||
nsString(const nsString& aString);
|
||||
|
||||
#ifdef NEW_STRING_APIS
|
||||
nsString(const nsAReadableString&);
|
||||
|
||||
nsString(const PRUnichar*);
|
||||
nsString(const PRUnichar*, PRInt32);
|
||||
#else
|
||||
/**
|
||||
* This constructor accepts a unichar string
|
||||
* @param aCString is a ptr to a 2-byte cstr
|
||||
*/
|
||||
nsString(const PRUnichar* aString,PRInt32 aCount=-1);
|
||||
|
||||
/**
|
||||
* This constructor accepts an isolatin string
|
||||
@@ -104,23 +102,13 @@ public:
|
||||
*/
|
||||
nsString(const char* aCString,PRInt32 aCount=-1);
|
||||
|
||||
/**
|
||||
* This constructor accepts a unichar string
|
||||
* @param aCString is a ptr to a 2-byte cstr
|
||||
*/
|
||||
nsString(const PRUnichar* aString,PRInt32 aCount=-1);
|
||||
|
||||
/**
|
||||
* This is a copy constructor that accepts an nsStr
|
||||
* @param reference to another nsString
|
||||
*/
|
||||
nsString(const nsStr&);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This is our copy constructor
|
||||
* @param reference to another nsString
|
||||
*/
|
||||
nsString(const nsString& aString);
|
||||
|
||||
/**
|
||||
* This constructor takes a subsumestr
|
||||
@@ -440,94 +428,52 @@ public:
|
||||
|
||||
* @return this
|
||||
*/
|
||||
|
||||
void AssignWithConversion(char);
|
||||
#ifdef NEW_STRING_APIS
|
||||
#ifdef HAVE_AMBIGUITY_RESOLVING_CPP_USING
|
||||
using nsAWritableString::Assign;
|
||||
void AssignWithConversion(const char*);
|
||||
void AssignWithConversion(const char*, PRInt32);
|
||||
#else
|
||||
virtual void Assign( const nsAReadableString& aReadable ) {
|
||||
nsAWritableString::Assign(aReadable);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
void AssignWithConversion(const char*, PRInt32=-1);
|
||||
|
||||
nsString& Assign(const PRUnichar* aString,PRInt32 aCount=-1);
|
||||
nsString& Assign(PRUnichar aChar);
|
||||
|
||||
void AssignWithConversion(const char*, PRInt32=-1);
|
||||
void AssignWithConversion(char);
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsString& Assign(const nsStr& aString,PRInt32 aCount=-1);
|
||||
nsString& Assign(const char* aString,PRInt32 aCount=-1) { AssignWithConversion(aString, aCount); return *this; }
|
||||
nsString& Assign(char aChar) { AssignWithConversion(aChar); return *this; }
|
||||
#endif
|
||||
|
||||
nsString& Assign(const char* aString,PRInt32 aCount=-1) { AssignWithConversion(aString, aCount); return *this; }
|
||||
nsString& Assign(char aChar) { AssignWithConversion(aChar); return *this; }
|
||||
|
||||
/**
|
||||
* Functionally equivalent to assign or operator=
|
||||
*
|
||||
*/
|
||||
nsString& SetString(const char* aString,PRInt32 aLength=-1) {AssignWithConversion(aString, aLength); return *this;}
|
||||
#ifdef NEW_STRING_APIS
|
||||
nsString& SetString(const nsString& aString,PRInt32 aLength=-1) {Assign(aString); return *this;}
|
||||
nsString& SetString(const PRUnichar* aString,PRInt32 aLength=-1) {Assign(aString); return *this;}
|
||||
#else
|
||||
nsString& SetString(const nsString& aString,PRInt32 aLength=-1) {return Assign(aString, aLength);}
|
||||
nsString& SetString(const PRUnichar* aString,PRInt32 aLength=-1) {return Assign(aString, aLength);}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* here come a bunch of assignment operators...
|
||||
* @param aString: string to be added to this
|
||||
* @return this
|
||||
*/
|
||||
#ifdef NEW_STRING_APIS
|
||||
#ifdef HAVE_AMBIGUITY_RESOLVING_CPP_USING
|
||||
using nsAWritableString::operator=;
|
||||
#else
|
||||
nsString& operator=( const nsAReadableString& aReadable ) { nsAWritableString::operator=(aReadable); return *this; }
|
||||
#endif
|
||||
#endif
|
||||
nsString& operator=(PRUnichar aChar) {return Assign(aChar);}
|
||||
nsString& operator=(char aChar) {AssignWithConversion(aChar); return *this;}
|
||||
nsString& operator=(const char* aCString) {AssignWithConversion(aCString); return *this;}
|
||||
nsString& operator=(PRUnichar aChar) {Assign(aChar); return *this;}
|
||||
nsString& operator=(char aChar) {AssignWithConversion(aChar); return *this;}
|
||||
nsString& operator=(const char* aCString) {AssignWithConversion(aCString); return *this;}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsString& operator=(const nsString& aString) {return Assign(aString);}
|
||||
nsString& operator=(const nsStr& aString) {return Assign(aString);}
|
||||
nsString& operator=(const nsString& aString) {return Assign(aString);}
|
||||
nsString& operator=(const nsStr& aString) {return Assign(aString);}
|
||||
nsString& operator=(const PRUnichar* aString) {return Assign(aString);}
|
||||
#endif
|
||||
|
||||
// Yes, I know this makes assignment from a |nsSubsumeString| not do the special thing
|
||||
// |nsSubsumeString| needs to go away
|
||||
#ifdef AIX
|
||||
nsString& operator=(const nsSubsumeStr& aSubsumeString); // AIX requires a const here
|
||||
#else
|
||||
nsString& operator=(nsSubsumeStr& aSubsumeString);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Here's a bunch of methods that append varying types...
|
||||
* @param various...
|
||||
* @return this
|
||||
*/
|
||||
#ifdef NEW_STRING_APIS
|
||||
#ifdef HAVE_AMBIGUITY_RESOLVING_CPP_USING
|
||||
using nsAWritableString::operator+=;
|
||||
#else
|
||||
nsString& operator+=( const nsAReadableString& aReadable ) { nsAWritableString::operator+=(aReadable); return *this; }
|
||||
#endif
|
||||
#endif
|
||||
nsString& operator+=(const char* aCString) {return Append(aCString);}
|
||||
nsString& operator+=(const char aChar) {
|
||||
return Append((PRUnichar) (unsigned char)aChar);
|
||||
}
|
||||
nsString& operator+=(const PRUnichar aChar){return Append(aChar);}
|
||||
nsString& operator+=(const int anInt){return Append(anInt,10);}
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsString& operator+=(const nsStr& aString){return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsString& operator+=(const nsString& aString){return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsString& operator+=(const PRUnichar* aUCString) {return Append(aUCString);}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Appends n characters from given string to this,
|
||||
* This version computes the length of your given string
|
||||
@@ -535,9 +481,16 @@ public:
|
||||
* @param aString is the source to be appended to this
|
||||
* @return number of chars copied
|
||||
*/
|
||||
nsString& Append(const nsStr& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsString& Append(const nsString& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
|
||||
|
||||
void AppendWithConversion(PRInt32, PRInt32=10); //radix=8,10 or 16
|
||||
void AppendWithConversion(float);
|
||||
void AppendWithConversion(char);
|
||||
|
||||
#ifdef NEW_STRING_APIS
|
||||
void AppendWithConversion(const char*);
|
||||
void AppendWithConversion(const char*, PRInt32);
|
||||
#else
|
||||
void AppendWithConversion(const char*, PRInt32=-1);
|
||||
|
||||
/*
|
||||
* Appends n characters from given string to this,
|
||||
@@ -548,13 +501,32 @@ public:
|
||||
* @return number of chars copied
|
||||
*/
|
||||
nsString& Append(const nsStr& aString,PRInt32 aCount);
|
||||
nsString& Append(const nsStr& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsString& Append(const nsString& aString,PRInt32 aCount);
|
||||
nsString& Append(const char* aString,PRInt32 aCount=-1);
|
||||
nsString& Append(const nsString& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
|
||||
nsString& Append(const PRUnichar* aString,PRInt32 aCount=-1);
|
||||
nsString& Append(char aChar);
|
||||
nsString& Append(PRUnichar aChar);
|
||||
nsString& Append(PRInt32 aInteger,PRInt32 aRadix=10); //radix=8,10 or 16
|
||||
nsString& Append(float aFloat);
|
||||
|
||||
nsString& Append(const char* aString,PRInt32 aCount=-1) {AppendWithConversion(aString,aCount); return *this;}
|
||||
nsString& Append(char aChar) {AppendWithConversion(aChar); return *this;}
|
||||
nsString& Append(PRInt32 aInteger,PRInt32 aRadix=10) {AppendWithConversion(aInteger,aRadix); return *this;}
|
||||
nsString& Append(float aFloat) {AppendWithConversion(aFloat); return *this;}
|
||||
|
||||
/**
|
||||
* Here's a bunch of methods that append varying types...
|
||||
* @param various...
|
||||
* @return this
|
||||
*/
|
||||
nsString& operator+=(const char* aCString) {return Append(aCString);}
|
||||
nsString& operator+=(const char aChar) {return Append((PRUnichar) (unsigned char)aChar);}
|
||||
nsString& operator+=(const PRUnichar aChar) {return Append(aChar);}
|
||||
nsString& operator+=(const int anInt) {return Append(anInt,10);}
|
||||
|
||||
nsString& operator+=(const nsStr& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsString& operator+=(const nsString& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsString& operator+=(const PRUnichar* aUCString) {return Append(aUCString);}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copies n characters from this string to given string,
|
||||
@@ -590,6 +562,10 @@ public:
|
||||
*/
|
||||
PRUint32 Right(nsString& aCopy,PRInt32 aCount) const;
|
||||
|
||||
|
||||
//void InsertWithConversion(char);
|
||||
void InsertWithConversion(const char*, PRUint32, PRInt32=-1);
|
||||
#ifndef NEW_STRING_APIS
|
||||
/*
|
||||
* This method inserts n chars from given string into this
|
||||
* string at str[anOffset].
|
||||
@@ -611,7 +587,7 @@ public:
|
||||
* @param anOffset is insert pos in str
|
||||
* @return the number of chars inserted into this string
|
||||
*/
|
||||
nsString& Insert(const char* aChar,PRUint32 anOffset,PRInt32 aCount=-1);
|
||||
nsString& Insert(const char* aChar,PRUint32 anOffset,PRInt32 aCount=-1) {InsertWithConversion(aChar, anOffset, aCount); return *this;}
|
||||
nsString& Insert(const PRUnichar* aChar,PRUint32 anOffset,PRInt32 aCount=-1);
|
||||
|
||||
/**
|
||||
@@ -622,9 +598,12 @@ public:
|
||||
* @param anOffset is insert pos in str
|
||||
* @return the number of chars inserted into this string
|
||||
*/
|
||||
//nsString& Insert(char aChar,PRUint32 anOffset);
|
||||
//nsString& Insert(char aChar,PRUint32 anOffset) {InsertWithConversion(aChar,anOffset); return *this;}
|
||||
nsString& Insert(PRUnichar aChar,PRUint32 anOffset);
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
/*
|
||||
* This method is used to cut characters in this string
|
||||
* starting at anOffset, continuing for aCount chars.
|
||||
@@ -633,7 +612,6 @@ public:
|
||||
* @param aCount -- number of chars to be cut
|
||||
* @return *this
|
||||
*/
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsString& Cut(PRUint32 anOffset,PRInt32 aCount);
|
||||
#endif
|
||||
|
||||
@@ -797,6 +775,7 @@ public:
|
||||
PRBool operator>=(const char* aString) const;
|
||||
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.
|
||||
@@ -876,13 +855,17 @@ extern NS_COM int fputs(const nsString& aString, FILE* out);
|
||||
class NS_COM nsAutoString : public nsString {
|
||||
public:
|
||||
|
||||
virtual ~nsAutoString();
|
||||
nsAutoString();
|
||||
nsAutoString(const char* aCString,PRInt32 aLength=-1);
|
||||
nsAutoString(const PRUnichar* aString,PRInt32 aLength=-1);
|
||||
|
||||
nsAutoString(const CBufDescriptor& aBuffer);
|
||||
nsAutoString(const nsStr& aString);
|
||||
nsAutoString(const nsAutoString& aString);
|
||||
nsAutoString(const PRUnichar* aString,PRInt32 aLength=-1);
|
||||
nsAutoString(PRUnichar aChar);
|
||||
nsAutoString(const CBufDescriptor& aBuffer);
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsAutoString(const char* aCString,PRInt32 aLength=-1);
|
||||
nsAutoString(const nsStr& aString);
|
||||
#endif
|
||||
|
||||
#ifdef AIX
|
||||
nsAutoString(const nsSubsumeStr& aSubsumeStr); // AIX requires a const
|
||||
@@ -890,8 +873,6 @@ public:
|
||||
nsAutoString(nsSubsumeStr& aSubsumeStr);
|
||||
#endif // AIX
|
||||
|
||||
nsAutoString(PRUnichar aChar);
|
||||
virtual ~nsAutoString();
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
nsAutoString& operator=(const nsStr& aString) {nsString::Assign(aString); return *this;}
|
||||
|
||||
Reference in New Issue
Block a user