mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-04 13:07:52 +00:00
new ideas about string conversion
This commit is contained in:
parent
3485166c98
commit
ab3abd034b
@ -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
|
||||
|
@ -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<char>&, nsFragmentRequest, PRUint32 ) const;
|
||||
virtual char* GetWritableFragment( nsWritableFragment<char>&, 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
|
||||
|
@ -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
|
||||
/**
|
||||
|
@ -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<PRUnichar>&, nsFragmentRequest, PRUint32 ) const;
|
||||
virtual PRUnichar* GetWritableFragment( nsWritableFragment<PRUnichar>&, 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<<eTwoByte];
|
||||
};
|
||||
|
||||
|
||||
class NS_COM NS_ConvertASCIItoUCS2
|
||||
: public nsAutoString
|
||||
/*
|
||||
...
|
||||
*/
|
||||
{
|
||||
public:
|
||||
NS_ConvertASCIItoUCS2( const char* );
|
||||
NS_ConvertASCIItoUCS2( const char*, PRUint32 );
|
||||
#if 0
|
||||
#ifdef NEW_STRING_APIS
|
||||
NS_ConvertASCIItoUCS2( const nsAReadableCString& );
|
||||
#else
|
||||
class nsCString;
|
||||
NS_ConvertASCIItoUCS2( const nsCString& );
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
#define NS_ConvertToString NS_ConvertASCIItoUCS2
|
||||
|
||||
#if 0
|
||||
inline
|
||||
nsAutoString
|
||||
NS_ConvertToString( const char* aCString )
|
||||
@ -933,6 +965,7 @@ NS_ConvertToString( const char* aCString, PRUint32 aLength )
|
||||
result.AssignWithConversion(aCString, aLength);
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
/***************************************************************
|
||||
The subsumestr class is very unusual.
|
||||
|
@ -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
|
||||
|
@ -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<char>&, nsFragmentRequest, PRUint32 ) const;
|
||||
virtual char* GetWritableFragment( nsWritableFragment<char>&, 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
|
||||
|
@ -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
|
||||
/**
|
||||
|
@ -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<PRUnichar>&, nsFragmentRequest, PRUint32 ) const;
|
||||
virtual PRUnichar* GetWritableFragment( nsWritableFragment<PRUnichar>&, 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<<eTwoByte];
|
||||
};
|
||||
|
||||
|
||||
class NS_COM NS_ConvertASCIItoUCS2
|
||||
: public nsAutoString
|
||||
/*
|
||||
...
|
||||
*/
|
||||
{
|
||||
public:
|
||||
NS_ConvertASCIItoUCS2( const char* );
|
||||
NS_ConvertASCIItoUCS2( const char*, PRUint32 );
|
||||
#if 0
|
||||
#ifdef NEW_STRING_APIS
|
||||
NS_ConvertASCIItoUCS2( const nsAReadableCString& );
|
||||
#else
|
||||
class nsCString;
|
||||
NS_ConvertASCIItoUCS2( const nsCString& );
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
#define NS_ConvertToString NS_ConvertASCIItoUCS2
|
||||
|
||||
#if 0
|
||||
inline
|
||||
nsAutoString
|
||||
NS_ConvertToString( const char* aCString )
|
||||
@ -933,6 +965,7 @@ NS_ConvertToString( const char* aCString, PRUint32 aLength )
|
||||
result.AssignWithConversion(aCString, aLength);
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
/***************************************************************
|
||||
The subsumestr class is very unusual.
|
||||
|
@ -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
|
||||
|
@ -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<char>&, nsFragmentRequest, PRUint32 ) const;
|
||||
virtual char* GetWritableFragment( nsWritableFragment<char>&, 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
|
||||
|
@ -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
|
||||
/**
|
||||
|
@ -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<PRUnichar>&, nsFragmentRequest, PRUint32 ) const;
|
||||
virtual PRUnichar* GetWritableFragment( nsWritableFragment<PRUnichar>&, 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<<eTwoByte];
|
||||
};
|
||||
|
||||
|
||||
class NS_COM NS_ConvertASCIItoUCS2
|
||||
: public nsAutoString
|
||||
/*
|
||||
...
|
||||
*/
|
||||
{
|
||||
public:
|
||||
NS_ConvertASCIItoUCS2( const char* );
|
||||
NS_ConvertASCIItoUCS2( const char*, PRUint32 );
|
||||
#if 0
|
||||
#ifdef NEW_STRING_APIS
|
||||
NS_ConvertASCIItoUCS2( const nsAReadableCString& );
|
||||
#else
|
||||
class nsCString;
|
||||
NS_ConvertASCIItoUCS2( const nsCString& );
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
#define NS_ConvertToString NS_ConvertASCIItoUCS2
|
||||
|
||||
#if 0
|
||||
inline
|
||||
nsAutoString
|
||||
NS_ConvertToString( const char* aCString )
|
||||
@ -933,6 +965,7 @@ NS_ConvertToString( const char* aCString, PRUint32 aLength )
|
||||
result.AssignWithConversion(aCString, aLength);
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
/***************************************************************
|
||||
The subsumestr class is very unusual.
|
||||
|
Loading…
x
Reference in New Issue
Block a user