landing string branch; see bug #73786

git-svn-id: svn://10.0.0.236/trunk@91049 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
scc%mozilla.org
2001-04-02 19:40:52 +00:00
parent e12df9c36a
commit 7b06841b03
143 changed files with 11372 additions and 5238 deletions

View File

@@ -26,6 +26,9 @@
#include "nsString.h"
#include "nsCRT.h"
#ifndef nsStringTraits_h___
#include "nsStringTraits.h"
#endif
/**
* this allocator definition, and the global functions to access it need to move
@@ -142,7 +145,7 @@ class LossyConvertEncoding
NS_COM
void
CopyUCS2toASCII( const nsAReadableString& aSource, nsAWritableCString& aDest )
CopyUCS2toASCII( const nsAString& aSource, nsACString& aDest )
{
// right now, this won't work on multi-fragment destinations
aDest.SetLength(aSource.Length());
@@ -157,7 +160,7 @@ CopyUCS2toASCII( const nsAReadableString& aSource, nsAWritableCString& aDest )
NS_COM
void
CopyASCIItoUCS2( const nsAReadableCString& aSource, nsAWritableString& aDest )
CopyASCIItoUCS2( const nsACString& aSource, nsAString& aDest )
{
// right now, this won't work on multi-fragment destinations
aDest.SetLength(aSource.Length());
@@ -178,10 +181,10 @@ CopyASCIItoUCS2( const nsAReadableCString& aSource, nsAWritableString& aDest )
* @return a new buffer (of the type specified by the second parameter) which you must free with |nsMemory::Free|.
*
*/
template <class FromCharT, class ToCharT>
template <class FromStringT, class ToCharT>
inline
ToCharT*
AllocateStringCopy( const basic_nsAReadableString<FromCharT>& aSource, ToCharT* )
AllocateStringCopy( const FromStringT& aSource, ToCharT* )
{
return NS_STATIC_CAST(ToCharT*, nsMemory::Alloc((aSource.Length()+1) * sizeof(ToCharT)));
}
@@ -189,7 +192,7 @@ AllocateStringCopy( const basic_nsAReadableString<FromCharT>& aSource, ToCharT*
NS_COM
char*
ToNewCString( const nsAReadableString& aSource )
ToNewCString( const nsAString& aSource )
{
char* result = AllocateStringCopy(aSource, (char*)0);
@@ -201,7 +204,7 @@ ToNewCString( const nsAReadableString& aSource )
NS_COM
char*
ToNewUTF8String( const nsAReadableString& aSource )
ToNewUTF8String( const nsAString& aSource )
{
NS_ConvertUCS2toUTF8 temp(aSource);
@@ -225,7 +228,7 @@ ToNewUTF8String( const nsAReadableString& aSource )
NS_COM
char*
ToNewCString( const nsAReadableCString& aSource )
ToNewCString( const nsACString& aSource )
{
// no conversion needed, just allocate a buffer of the correct length and copy into it
@@ -239,7 +242,7 @@ ToNewCString( const nsAReadableCString& aSource )
NS_COM
PRUnichar*
ToNewUnicode( const nsAReadableString& aSource )
ToNewUnicode( const nsAString& aSource )
{
// no conversion needed, just allocate a buffer of the correct length and copy into it
@@ -253,7 +256,7 @@ ToNewUnicode( const nsAReadableString& aSource )
NS_COM
PRUnichar*
ToNewUnicode( const nsAReadableCString& aSource )
ToNewUnicode( const nsACString& aSource )
{
PRUnichar* result = AllocateStringCopy(aSource, (PRUnichar*)0);
@@ -265,7 +268,7 @@ ToNewUnicode( const nsAReadableCString& aSource )
NS_COM
PRUnichar*
CopyUnicodeTo( const nsAReadableString& aSource, PRUint32 aSrcOffset, PRUnichar* aDest, PRUint32 aLength )
CopyUnicodeTo( const nsAString& aSource, PRUint32 aSrcOffset, PRUnichar* aDest, PRUint32 aLength )
{
nsReadingIterator<PRUnichar> fromBegin, fromEnd;
PRUnichar* toBegin = aDest;
@@ -277,7 +280,7 @@ NS_COM
void
CopyUnicodeTo( const nsReadingIterator<PRUnichar>& aSrcStart,
const nsReadingIterator<PRUnichar>& aSrcEnd,
nsAWritableString& aDest )
nsAString& aDest )
{
nsWritingIterator<PRUnichar> writer;
aDest.SetLength(Distance(aSrcStart, aSrcEnd));
@@ -291,7 +294,7 @@ NS_COM
void
AppendUnicodeTo( const nsReadingIterator<PRUnichar>& aSrcStart,
const nsReadingIterator<PRUnichar>& aSrcEnd,
nsAWritableString& aDest )
nsAString& aDest )
{
nsWritingIterator<PRUnichar> writer;
PRUint32 oldLength = aDest.Length();
@@ -304,7 +307,7 @@ AppendUnicodeTo( const nsReadingIterator<PRUnichar>& aSrcStart,
NS_COM
PRBool
IsASCII( const nsAReadableString& aString )
IsASCII( const nsAString& aString )
{
static const PRUnichar NOT_ASCII = PRUnichar(~0x007F);
@@ -354,18 +357,18 @@ class ConvertToUpperCase
NS_COM
void
ToUpperCase( nsAWritableString& aString )
ToUpperCase( nsAString& aString )
{
nsAWritableString::iterator fromBegin, fromEnd;
nsAString::iterator fromBegin, fromEnd;
ConvertToUpperCase<PRUnichar> converter;
copy_string(aString.BeginWriting(fromBegin), aString.EndWriting(fromEnd), converter);
}
NS_COM
void
ToUpperCase( nsAWritableCString& aCString )
ToUpperCase( nsACString& aCString )
{
nsAWritableCString::iterator fromBegin, fromEnd;
nsACString::iterator fromBegin, fromEnd;
ConvertToUpperCase<char> converter;
copy_string(aCString.BeginWriting(fromBegin), aCString.EndWriting(fromEnd), converter);
}
@@ -391,18 +394,18 @@ class ConvertToLowerCase
NS_COM
void
ToLowerCase( nsAWritableString& aString )
ToLowerCase( nsAString& aString )
{
nsAWritableString::iterator fromBegin, fromEnd;
nsAString::iterator fromBegin, fromEnd;
ConvertToLowerCase<PRUnichar> converter;
copy_string(aString.BeginWriting(fromBegin), aString.EndWriting(fromEnd), converter);
}
NS_COM
void
ToLowerCase( nsAWritableCString& aCString )
ToLowerCase( nsACString& aCString )
{
nsAWritableCString::iterator fromBegin, fromEnd;
nsACString::iterator fromBegin, fromEnd;
ConvertToLowerCase<char> converter;
copy_string(aCString.BeginWriting(fromBegin), aCString.EndWriting(fromEnd), converter);
}
@@ -411,7 +414,7 @@ ToLowerCase( nsAWritableCString& aCString )
template <class CharT>
inline // probably wishful thinking
PRBool
FindInReadable_Impl( const basic_nsAReadableString<CharT>& aPattern,
FindInReadable_Impl( const typename nsStringTraits<CharT>::abstract_string_type& aPattern,
nsReadingIterator<CharT>& aSearchStart,
nsReadingIterator<CharT>& aSearchEnd )
{
@@ -479,14 +482,14 @@ FindInReadable_Impl( const basic_nsAReadableString<CharT>& aPattern,
NS_COM
PRBool
FindInReadable( const nsAReadableString& aPattern, nsReadingIterator<PRUnichar>& aSearchStart, nsReadingIterator<PRUnichar>& aSearchEnd )
FindInReadable( const nsAString& aPattern, nsReadingIterator<PRUnichar>& aSearchStart, nsReadingIterator<PRUnichar>& aSearchEnd )
{
return FindInReadable_Impl(aPattern, aSearchStart, aSearchEnd);
}
NS_COM
PRBool
FindInReadable( const nsAReadableCString& aPattern, nsReadingIterator<char>& aSearchStart, nsReadingIterator<char>& aSearchEnd )
FindInReadable( const nsACString& aPattern, nsReadingIterator<char>& aSearchStart, nsReadingIterator<char>& aSearchEnd )
{
return FindInReadable_Impl(aPattern, aSearchStart, aSearchEnd);
}
@@ -499,7 +502,7 @@ FindInReadable( const nsAReadableCString& aPattern, nsReadingIterator<char>& aSe
template <class CharT>
inline // probably wishful thinking
PRBool
RFindInReadable_Impl( const basic_nsAReadableString<CharT>& aPattern,
RFindInReadable_Impl( const typename nsStringTraits<CharT>::abstract_string_type& aPattern,
nsReadingIterator<CharT>& aSearchStart,
nsReadingIterator<CharT>& aSearchEnd )
{
@@ -535,14 +538,14 @@ RFindInReadable_Impl( const basic_nsAReadableString<CharT>& aPattern,
NS_COM
PRBool
RFindInReadable( const nsAReadableString& aPattern, nsReadingIterator<PRUnichar>& aSearchStart, nsReadingIterator<PRUnichar>& aSearchEnd )
RFindInReadable( const nsAString& aPattern, nsReadingIterator<PRUnichar>& aSearchStart, nsReadingIterator<PRUnichar>& aSearchEnd )
{
return RFindInReadable_Impl(aPattern, aSearchStart, aSearchEnd);
}
NS_COM
PRBool
RFindInReadable( const nsAReadableCString& aPattern, nsReadingIterator<char>& aSearchStart, nsReadingIterator<char>& aSearchEnd )
RFindInReadable( const nsACString& aPattern, nsReadingIterator<char>& aSearchStart, nsReadingIterator<char>& aSearchEnd )
{
return RFindInReadable_Impl(aPattern, aSearchStart, aSearchEnd);
}
@@ -593,7 +596,7 @@ FindCharInReadable( char aChar, nsReadingIterator<char>& aSearchStart, const nsR
template <class CharT>
PRUint32
CountCharInReadable_Impl( const basic_nsAReadableString<CharT>& aStr,
CountCharInReadable_Impl( const typename nsStringTraits<CharT>::abstract_string_type& aStr,
CharT aChar )
{
PRUint32 count = 0;
@@ -614,7 +617,7 @@ CountCharInReadable_Impl( const basic_nsAReadableString<CharT>& aStr,
NS_COM
PRUint32
CountCharInReadable( const nsAReadableString& aStr,
CountCharInReadable( const nsAString& aStr,
PRUnichar aChar )
{
return CountCharInReadable_Impl(aStr, aChar);
@@ -622,7 +625,7 @@ CountCharInReadable( const nsAReadableString& aStr,
NS_COM
PRUint32
CountCharInReadable( const nsAReadableCString& aStr,
CountCharInReadable( const nsACString& aStr,
char aChar )
{
return CountCharInReadable_Impl(aStr, aChar);