From d14516727be48a1fb4730a8644a5fafeeb4dcf41 Mon Sep 17 00:00:00 2001 From: "scc%netscape.com" Date: Sat, 15 Apr 2000 00:05:17 +0000 Subject: [PATCH] new ideas about string conversion git-svn-id: svn://10.0.0.236/trunk@66042 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/string/obsolete/nsString.cpp | 30 ++++++++++--- mozilla/string/obsolete/nsString.h | 20 +++++++-- mozilla/string/obsolete/nsString2.cpp | 29 ++++++++++++- mozilla/string/obsolete/nsString2.h | 47 ++++++++++++++++++--- mozilla/xpcom/ds/nsString.cpp | 30 ++++++++++--- mozilla/xpcom/ds/nsString.h | 20 +++++++-- mozilla/xpcom/ds/nsString2.cpp | 29 ++++++++++++- mozilla/xpcom/ds/nsString2.h | 47 ++++++++++++++++++--- mozilla/xpcom/string/obsolete/nsString.cpp | 30 ++++++++++--- mozilla/xpcom/string/obsolete/nsString.h | 20 +++++++-- mozilla/xpcom/string/obsolete/nsString2.cpp | 29 ++++++++++++- mozilla/xpcom/string/obsolete/nsString2.h | 47 ++++++++++++++++++--- 12 files changed, 324 insertions(+), 54 deletions(-) diff --git a/mozilla/string/obsolete/nsString.cpp b/mozilla/string/obsolete/nsString.cpp index 6d7466c2e8f..0f6aac52222 100644 --- a/mozilla/string/obsolete/nsString.cpp +++ b/mozilla/string/obsolete/nsString.cpp @@ -587,8 +587,8 @@ nsCString& nsCString::Trim(const char* aTrimSet, PRBool aEliminateLeading,PRBool nsStr::Trim(*this,aTrimSet,aEliminateLeading,aEliminateTrailing); if(aIgnoreQuotes && theQuotesAreNeeded) { - Insert(theFirstChar,0); - Append(theLastChar); + InsertWithConversion(theFirstChar,0); + AppendWithConversion(theLastChar); } } @@ -946,9 +946,19 @@ void nsCString::AssignWithConversion(const PRUnichar* aString,PRInt32 aCount) { */ void nsCString::AssignWithConversion(PRUnichar aChar) { nsStr::Truncate(*this,0); - Append(aChar); + AppendWithConversion(aChar); } +#ifdef NEW_STRING_APIS +void nsCString::do_AppendFromReadable( const nsAReadableCString& aReadable ) + { + if ( SameImplementation(*this, aReadable) ) + StrAppend(*this, NS_STATIC_CAST(const nsCString&, aReadable), 0, aReadable.Length()); + else + nsAWritableCString::do_AppendFromReadable(aReadable); + } +#endif + #ifndef NEW_STRING_APIS /** * append given string to this string @@ -1051,7 +1061,7 @@ void nsCString::AppendWithConversion(PRUnichar aChar) { * @param aRadix: * @return */ -void nsCString::AppendWithConversion(PRInt32 anInteger,PRInt32 aRadix) { +void nsCString::AppendInt(PRInt32 anInteger,PRInt32 aRadix) { PRUint32 theInt=(PRUint32)anInteger; @@ -1089,7 +1099,7 @@ void nsCString::AppendWithConversion(PRInt32 anInteger,PRInt32 aRadix) { * @param aFloat: * @return */ -void nsCString::AppendWithConversion(float aFloat){ +void nsCString::AppendFloat( double aFloat ){ char buf[40]; // *** XX UNCOMMENT THIS LINE //PR_snprintf(buf, sizeof(buf), "%g", aFloat); @@ -1179,6 +1189,16 @@ void nsCString::InsertWithConversion(PRUnichar aChar,PRUint32 anOffset){ StrInsert(*this,anOffset,temp,0,1); } +#ifdef NEW_STRING_APIS +void nsCString::do_InsertFromReadable( const nsAReadableCString& aReadable, PRUint32 atPosition ) + { + if ( SameImplementation(*this, aReadable) ) + StrInsert(*this, atPosition, NS_STATIC_CAST(const nsCString&, aReadable), 0, aReadable.Length()); + else + nsAWritableCString::do_InsertFromReadable(aReadable, atPosition); + } +#endif + #ifndef NEW_STRING_APIS /* * This method inserts n chars from given string into this diff --git a/mozilla/string/obsolete/nsString.h b/mozilla/string/obsolete/nsString.h index e94f55cb6dd..da04e6d358a 100644 --- a/mozilla/string/obsolete/nsString.h +++ b/mozilla/string/obsolete/nsString.h @@ -77,6 +77,7 @@ class NS_COM nsCString : #ifdef NEW_STRING_APIS protected: + virtual const void* Implementation() const { return "nsCString"; } virtual const char* GetReadableFragment( nsReadableFragment&, nsFragmentRequest, PRUint32 ) const; virtual char* GetWritableFragment( nsWritableFragment&, nsFragmentRequest, PRUint32 ); #endif @@ -453,10 +454,14 @@ public: */ void AppendWithConversion(const nsString&, PRInt32=-1); - 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*)|? + void AppendInt(PRInt32 aInteger,PRInt32 aRadix=10); //radix=8,10 or 16 + void AppendFloat( double aFloat ); + +#ifdef NEW_STRING_APIS + virtual void do_AppendFromReadable( const nsAReadableCString& ); +#endif #ifndef NEW_STRING_APIS nsCString& Append(const nsStr& aString,PRInt32 aCount=-1); @@ -466,8 +471,11 @@ public: nsCString& Append(char aChar); 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;} + nsCString& Append(PRInt32 aInteger,PRInt32 aRadix=10) {AppendInt(aInteger,aRadix); return *this;} + nsCString& Append(float aFloat) {AppendFloat(aFloat); return *this;} + + void AppendWithConversion(PRInt32 aInteger, PRInt32 aRadix=10) {AppendInt(aInteger,aRadix);} + void AppendWithConversion(float aFloat) {AppendFloat(aFloat);} /** * Here's a bunch of methods that append varying types... @@ -519,6 +527,10 @@ public: void InsertWithConversion(PRUnichar aChar,PRUint32 anOffset); // Why no |InsertWithConversion(PRUnichar*)|? +#ifdef NEW_STRING_APIS + virtual void do_InsertFromReadable( const nsAReadableCString&, PRUint32 ); +#endif + #ifndef NEW_STRING_APIS /* * This method inserts n chars from given string into this diff --git a/mozilla/string/obsolete/nsString2.cpp b/mozilla/string/obsolete/nsString2.cpp index 10e591fa87c..01c51464d29 100644 --- a/mozilla/string/obsolete/nsString2.cpp +++ b/mozilla/string/obsolete/nsString2.cpp @@ -1155,7 +1155,7 @@ void nsString::AppendWithConversion(char aChar) { * @param aRadix: * @return */ -void nsString::AppendWithConversion(PRInt32 anInteger,PRInt32 aRadix) { +void nsString::AppendInt(PRInt32 anInteger,PRInt32 aRadix) { PRUint32 theInt=(PRUint32)anInteger; @@ -1193,7 +1193,7 @@ void nsString::AppendWithConversion(PRInt32 anInteger,PRInt32 aRadix) { * @param aFloat: * @return */ -void nsString::AppendWithConversion(float aFloat){ +void nsString::AppendFloat(double aFloat){ char buf[40]; // *** XX UNCOMMENT THIS LINE //PR_snprintf(buf, sizeof(buf), "%g", aFloat); @@ -2303,6 +2303,31 @@ nsAutoString::nsAutoString(const CBufDescriptor& aBuffer) : nsString() { AddNullTerminator(*this); } +NS_ConvertASCIItoUCS2::NS_ConvertASCIItoUCS2( const char* aCString, PRUint32 aLength ) + { + Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE); + AddNullTerminator(*this); + AppendWithConversion(aCString,aLength); + } + +NS_ConvertASCIItoUCS2::NS_ConvertASCIItoUCS2( const char* aCString ) + { + Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE); + AddNullTerminator(*this); + AppendWithConversion(aCString); + } + +#if 0 +#ifdef NEW_STRING_APIS +NS_ConvertASCIItoUCS2::NS_ConvertASCIItoUCS2( const nsAReadableCString& ) + { + } +#else +NS_ConvertASCIItoUCS2::NS_ConvertASCIItoUCS2( const nsCString& ) + { + } +#endif +#endif #ifndef NEW_STRING_APIS /** diff --git a/mozilla/string/obsolete/nsString2.h b/mozilla/string/obsolete/nsString2.h index 832c16fcc56..ebb9a4786c5 100644 --- a/mozilla/string/obsolete/nsString2.h +++ b/mozilla/string/obsolete/nsString2.h @@ -51,6 +51,11 @@ #include "nsAWritableString.h" #endif +#ifdef STANDALONE_MI_STRING_TESTS + class nsAReadableString { public: virtual ~nsAReadableString() { } }; + class nsAWritableString : public nsAReadableString { public: virtual ~nsAWritableString() { } }; +#endif + class nsISizeOfHandler; @@ -60,13 +65,14 @@ class nsISizeOfHandler; class NS_COM nsSubsumeStr; class NS_COM nsString : -#ifdef NEW_STRING_APIS +#if defined(NEW_STRING_APIS) || defined(STANDALONE_MI_STRING_TESTS) public nsAWritableString, #endif public nsStr { protected: #ifdef NEW_STRING_APIS + virtual const void* Implementation() const { return "nsString"; } virtual const PRUnichar* GetReadableFragment( nsReadableFragment&, nsFragmentRequest, PRUint32 ) const; virtual PRUnichar* GetWritableFragment( nsWritableFragment&, nsFragmentRequest, PRUint32 ); #endif @@ -482,9 +488,9 @@ public: * @return number of chars copied */ + void AppendInt(PRInt32, PRInt32=10); //radix=8,10 or 16 + void AppendFloat(double); void AppendWithConversion(const char*, PRInt32=-1); - void AppendWithConversion(PRInt32, PRInt32=10); //radix=8,10 or 16 - void AppendWithConversion(float); void AppendWithConversion(char); #ifndef NEW_STRING_APIS @@ -504,10 +510,13 @@ public: nsString& Append(const PRUnichar* aString,PRInt32 aCount=-1); nsString& Append(PRUnichar aChar); - 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;} + void AppendWithConversion( PRInt32 i, PRInt32 radix=10 ) { AppendInt(i, radix); } + void AppendWithConversion( float f ) { AppendFloat(f); } + + 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) { AppendInt(aInteger,aRadix); return *this; } + nsString& Append(float aFloat) { AppendFloat(aFloat); return *this; } /** * Here's a bunch of methods that append varying types... @@ -916,6 +925,29 @@ public: char mBuffer[kDefaultStringSize<&, nsFragmentRequest, PRUint32 ) const; virtual char* GetWritableFragment( nsWritableFragment&, nsFragmentRequest, PRUint32 ); #endif @@ -453,10 +454,14 @@ public: */ void AppendWithConversion(const nsString&, PRInt32=-1); - 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*)|? + void AppendInt(PRInt32 aInteger,PRInt32 aRadix=10); //radix=8,10 or 16 + void AppendFloat( double aFloat ); + +#ifdef NEW_STRING_APIS + virtual void do_AppendFromReadable( const nsAReadableCString& ); +#endif #ifndef NEW_STRING_APIS nsCString& Append(const nsStr& aString,PRInt32 aCount=-1); @@ -466,8 +471,11 @@ public: nsCString& Append(char aChar); 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;} + nsCString& Append(PRInt32 aInteger,PRInt32 aRadix=10) {AppendInt(aInteger,aRadix); return *this;} + nsCString& Append(float aFloat) {AppendFloat(aFloat); return *this;} + + void AppendWithConversion(PRInt32 aInteger, PRInt32 aRadix=10) {AppendInt(aInteger,aRadix);} + void AppendWithConversion(float aFloat) {AppendFloat(aFloat);} /** * Here's a bunch of methods that append varying types... @@ -519,6 +527,10 @@ public: void InsertWithConversion(PRUnichar aChar,PRUint32 anOffset); // Why no |InsertWithConversion(PRUnichar*)|? +#ifdef NEW_STRING_APIS + virtual void do_InsertFromReadable( const nsAReadableCString&, PRUint32 ); +#endif + #ifndef NEW_STRING_APIS /* * This method inserts n chars from given string into this diff --git a/mozilla/xpcom/ds/nsString2.cpp b/mozilla/xpcom/ds/nsString2.cpp index 10e591fa87c..01c51464d29 100644 --- a/mozilla/xpcom/ds/nsString2.cpp +++ b/mozilla/xpcom/ds/nsString2.cpp @@ -1155,7 +1155,7 @@ void nsString::AppendWithConversion(char aChar) { * @param aRadix: * @return */ -void nsString::AppendWithConversion(PRInt32 anInteger,PRInt32 aRadix) { +void nsString::AppendInt(PRInt32 anInteger,PRInt32 aRadix) { PRUint32 theInt=(PRUint32)anInteger; @@ -1193,7 +1193,7 @@ void nsString::AppendWithConversion(PRInt32 anInteger,PRInt32 aRadix) { * @param aFloat: * @return */ -void nsString::AppendWithConversion(float aFloat){ +void nsString::AppendFloat(double aFloat){ char buf[40]; // *** XX UNCOMMENT THIS LINE //PR_snprintf(buf, sizeof(buf), "%g", aFloat); @@ -2303,6 +2303,31 @@ nsAutoString::nsAutoString(const CBufDescriptor& aBuffer) : nsString() { AddNullTerminator(*this); } +NS_ConvertASCIItoUCS2::NS_ConvertASCIItoUCS2( const char* aCString, PRUint32 aLength ) + { + Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE); + AddNullTerminator(*this); + AppendWithConversion(aCString,aLength); + } + +NS_ConvertASCIItoUCS2::NS_ConvertASCIItoUCS2( const char* aCString ) + { + Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE); + AddNullTerminator(*this); + AppendWithConversion(aCString); + } + +#if 0 +#ifdef NEW_STRING_APIS +NS_ConvertASCIItoUCS2::NS_ConvertASCIItoUCS2( const nsAReadableCString& ) + { + } +#else +NS_ConvertASCIItoUCS2::NS_ConvertASCIItoUCS2( const nsCString& ) + { + } +#endif +#endif #ifndef NEW_STRING_APIS /** diff --git a/mozilla/xpcom/ds/nsString2.h b/mozilla/xpcom/ds/nsString2.h index 832c16fcc56..ebb9a4786c5 100644 --- a/mozilla/xpcom/ds/nsString2.h +++ b/mozilla/xpcom/ds/nsString2.h @@ -51,6 +51,11 @@ #include "nsAWritableString.h" #endif +#ifdef STANDALONE_MI_STRING_TESTS + class nsAReadableString { public: virtual ~nsAReadableString() { } }; + class nsAWritableString : public nsAReadableString { public: virtual ~nsAWritableString() { } }; +#endif + class nsISizeOfHandler; @@ -60,13 +65,14 @@ class nsISizeOfHandler; class NS_COM nsSubsumeStr; class NS_COM nsString : -#ifdef NEW_STRING_APIS +#if defined(NEW_STRING_APIS) || defined(STANDALONE_MI_STRING_TESTS) public nsAWritableString, #endif public nsStr { protected: #ifdef NEW_STRING_APIS + virtual const void* Implementation() const { return "nsString"; } virtual const PRUnichar* GetReadableFragment( nsReadableFragment&, nsFragmentRequest, PRUint32 ) const; virtual PRUnichar* GetWritableFragment( nsWritableFragment&, nsFragmentRequest, PRUint32 ); #endif @@ -482,9 +488,9 @@ public: * @return number of chars copied */ + void AppendInt(PRInt32, PRInt32=10); //radix=8,10 or 16 + void AppendFloat(double); void AppendWithConversion(const char*, PRInt32=-1); - void AppendWithConversion(PRInt32, PRInt32=10); //radix=8,10 or 16 - void AppendWithConversion(float); void AppendWithConversion(char); #ifndef NEW_STRING_APIS @@ -504,10 +510,13 @@ public: nsString& Append(const PRUnichar* aString,PRInt32 aCount=-1); nsString& Append(PRUnichar aChar); - 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;} + void AppendWithConversion( PRInt32 i, PRInt32 radix=10 ) { AppendInt(i, radix); } + void AppendWithConversion( float f ) { AppendFloat(f); } + + 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) { AppendInt(aInteger,aRadix); return *this; } + nsString& Append(float aFloat) { AppendFloat(aFloat); return *this; } /** * Here's a bunch of methods that append varying types... @@ -916,6 +925,29 @@ public: char mBuffer[kDefaultStringSize<&, nsFragmentRequest, PRUint32 ) const; virtual char* GetWritableFragment( nsWritableFragment&, nsFragmentRequest, PRUint32 ); #endif @@ -453,10 +454,14 @@ public: */ void AppendWithConversion(const nsString&, PRInt32=-1); - 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*)|? + void AppendInt(PRInt32 aInteger,PRInt32 aRadix=10); //radix=8,10 or 16 + void AppendFloat( double aFloat ); + +#ifdef NEW_STRING_APIS + virtual void do_AppendFromReadable( const nsAReadableCString& ); +#endif #ifndef NEW_STRING_APIS nsCString& Append(const nsStr& aString,PRInt32 aCount=-1); @@ -466,8 +471,11 @@ public: nsCString& Append(char aChar); 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;} + nsCString& Append(PRInt32 aInteger,PRInt32 aRadix=10) {AppendInt(aInteger,aRadix); return *this;} + nsCString& Append(float aFloat) {AppendFloat(aFloat); return *this;} + + void AppendWithConversion(PRInt32 aInteger, PRInt32 aRadix=10) {AppendInt(aInteger,aRadix);} + void AppendWithConversion(float aFloat) {AppendFloat(aFloat);} /** * Here's a bunch of methods that append varying types... @@ -519,6 +527,10 @@ public: void InsertWithConversion(PRUnichar aChar,PRUint32 anOffset); // Why no |InsertWithConversion(PRUnichar*)|? +#ifdef NEW_STRING_APIS + virtual void do_InsertFromReadable( const nsAReadableCString&, PRUint32 ); +#endif + #ifndef NEW_STRING_APIS /* * This method inserts n chars from given string into this diff --git a/mozilla/xpcom/string/obsolete/nsString2.cpp b/mozilla/xpcom/string/obsolete/nsString2.cpp index 10e591fa87c..01c51464d29 100644 --- a/mozilla/xpcom/string/obsolete/nsString2.cpp +++ b/mozilla/xpcom/string/obsolete/nsString2.cpp @@ -1155,7 +1155,7 @@ void nsString::AppendWithConversion(char aChar) { * @param aRadix: * @return */ -void nsString::AppendWithConversion(PRInt32 anInteger,PRInt32 aRadix) { +void nsString::AppendInt(PRInt32 anInteger,PRInt32 aRadix) { PRUint32 theInt=(PRUint32)anInteger; @@ -1193,7 +1193,7 @@ void nsString::AppendWithConversion(PRInt32 anInteger,PRInt32 aRadix) { * @param aFloat: * @return */ -void nsString::AppendWithConversion(float aFloat){ +void nsString::AppendFloat(double aFloat){ char buf[40]; // *** XX UNCOMMENT THIS LINE //PR_snprintf(buf, sizeof(buf), "%g", aFloat); @@ -2303,6 +2303,31 @@ nsAutoString::nsAutoString(const CBufDescriptor& aBuffer) : nsString() { AddNullTerminator(*this); } +NS_ConvertASCIItoUCS2::NS_ConvertASCIItoUCS2( const char* aCString, PRUint32 aLength ) + { + Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE); + AddNullTerminator(*this); + AppendWithConversion(aCString,aLength); + } + +NS_ConvertASCIItoUCS2::NS_ConvertASCIItoUCS2( const char* aCString ) + { + Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE); + AddNullTerminator(*this); + AppendWithConversion(aCString); + } + +#if 0 +#ifdef NEW_STRING_APIS +NS_ConvertASCIItoUCS2::NS_ConvertASCIItoUCS2( const nsAReadableCString& ) + { + } +#else +NS_ConvertASCIItoUCS2::NS_ConvertASCIItoUCS2( const nsCString& ) + { + } +#endif +#endif #ifndef NEW_STRING_APIS /** diff --git a/mozilla/xpcom/string/obsolete/nsString2.h b/mozilla/xpcom/string/obsolete/nsString2.h index 832c16fcc56..ebb9a4786c5 100644 --- a/mozilla/xpcom/string/obsolete/nsString2.h +++ b/mozilla/xpcom/string/obsolete/nsString2.h @@ -51,6 +51,11 @@ #include "nsAWritableString.h" #endif +#ifdef STANDALONE_MI_STRING_TESTS + class nsAReadableString { public: virtual ~nsAReadableString() { } }; + class nsAWritableString : public nsAReadableString { public: virtual ~nsAWritableString() { } }; +#endif + class nsISizeOfHandler; @@ -60,13 +65,14 @@ class nsISizeOfHandler; class NS_COM nsSubsumeStr; class NS_COM nsString : -#ifdef NEW_STRING_APIS +#if defined(NEW_STRING_APIS) || defined(STANDALONE_MI_STRING_TESTS) public nsAWritableString, #endif public nsStr { protected: #ifdef NEW_STRING_APIS + virtual const void* Implementation() const { return "nsString"; } virtual const PRUnichar* GetReadableFragment( nsReadableFragment&, nsFragmentRequest, PRUint32 ) const; virtual PRUnichar* GetWritableFragment( nsWritableFragment&, nsFragmentRequest, PRUint32 ); #endif @@ -482,9 +488,9 @@ public: * @return number of chars copied */ + void AppendInt(PRInt32, PRInt32=10); //radix=8,10 or 16 + void AppendFloat(double); void AppendWithConversion(const char*, PRInt32=-1); - void AppendWithConversion(PRInt32, PRInt32=10); //radix=8,10 or 16 - void AppendWithConversion(float); void AppendWithConversion(char); #ifndef NEW_STRING_APIS @@ -504,10 +510,13 @@ public: nsString& Append(const PRUnichar* aString,PRInt32 aCount=-1); nsString& Append(PRUnichar aChar); - 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;} + void AppendWithConversion( PRInt32 i, PRInt32 radix=10 ) { AppendInt(i, radix); } + void AppendWithConversion( float f ) { AppendFloat(f); } + + 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) { AppendInt(aInteger,aRadix); return *this; } + nsString& Append(float aFloat) { AppendFloat(aFloat); return *this; } /** * Here's a bunch of methods that append varying types... @@ -916,6 +925,29 @@ public: char mBuffer[kDefaultStringSize<