scc string fixes
git-svn-id: svn://10.0.0.236/trunk@67148 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -34,6 +34,9 @@
|
||||
4. Subsumable strings
|
||||
***********************************************************************/
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
//#define NEW_STRING_APIS 1
|
||||
#endif //NEW_STRING_APIS
|
||||
|
||||
#ifndef _nsCString_
|
||||
#define _nsCString_
|
||||
|
||||
@@ -2286,6 +2286,15 @@ nsAutoString::nsAutoString(const PRUnichar* aString,PRInt32 aLength) : nsString(
|
||||
Append(aString,aLength);
|
||||
}
|
||||
|
||||
nsAutoString::nsAutoString( const nsString& aString )
|
||||
: nsString()
|
||||
{
|
||||
Initialize(*this, mBuffer, (sizeof(mBuffer)>>eTwoByte)-1, 0, eTwoByte, PR_FALSE);
|
||||
AddNullTerminator(*this);
|
||||
Append(aString);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* constructor that uses external buffer
|
||||
* @param aBuffer describes the external buffer
|
||||
|
||||
@@ -35,6 +35,10 @@
|
||||
4. Subsumable strings
|
||||
***********************************************************************/
|
||||
|
||||
#ifndef NEW_STRING_APIS
|
||||
//#define NEW_STRING_APIS 1
|
||||
#endif //NEW_STRING_APIS
|
||||
|
||||
|
||||
#ifndef _nsString_
|
||||
#define _nsString_
|
||||
@@ -898,6 +902,7 @@ public:
|
||||
virtual ~nsAutoString();
|
||||
nsAutoString();
|
||||
nsAutoString(const nsAutoString& aString);
|
||||
nsAutoString(const nsString& aString);
|
||||
nsAutoString(const PRUnichar* aString,PRInt32 aLength=-1);
|
||||
nsAutoString(PRUnichar aChar);
|
||||
nsAutoString(const CBufDescriptor& aBuffer);
|
||||
|
||||
@@ -504,7 +504,7 @@ template <class CharT>
|
||||
PRUint32
|
||||
basic_nsAReadableString<CharT>::CountChar( CharT c ) const
|
||||
{
|
||||
#if 1
|
||||
#if 0
|
||||
return PRUint32(count(BeginReading(), EndReading(), c));
|
||||
#else
|
||||
PRUint32 result = 0;
|
||||
@@ -679,7 +679,7 @@ inline
|
||||
int
|
||||
basic_nsAReadableString<CharT>::Compare( const CharT* rhs ) const
|
||||
{
|
||||
return ::Compare(*this, NS_STATIC_CAST(basic_nsAReadableString<CharT>, basic_nsLiteralString<CharT>(rhs)));
|
||||
return ::Compare(*this, NS_STATIC_CAST(const basic_nsAReadableString<CharT>&, basic_nsLiteralString<CharT>(rhs)));
|
||||
}
|
||||
|
||||
template <class CharT>
|
||||
@@ -687,7 +687,7 @@ inline
|
||||
int
|
||||
basic_nsAReadableString<CharT>::Compare( const CharT* rhs, PRUint32 rhs_length ) const
|
||||
{
|
||||
return ::Compare(*this, NS_STATIC_CAST(basic_nsAReadableString<CharT>, basic_nsLiteralString<CharT>(rhs, rhs_length)));
|
||||
return ::Compare(*this, NS_STATIC_CAST(const basic_nsAReadableString<CharT>&, basic_nsLiteralString<CharT>(rhs, rhs_length)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -487,6 +487,8 @@ struct nsCharSourceTraits
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef HAVE_CPP_PARTIAL_SPECIALIZATION
|
||||
|
||||
template <class CharT>
|
||||
struct nsCharSourceTraits<CharT*>
|
||||
{
|
||||
@@ -513,6 +515,37 @@ struct nsCharSourceTraits<CharT*>
|
||||
}
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
NS_SPECIALIZE_TEMPLATE
|
||||
struct nsCharSourceTraits<const char*>
|
||||
{
|
||||
static
|
||||
PRUint32
|
||||
readable_size( const char* s )
|
||||
{
|
||||
return PRUint32(nsCharTraits<char>::length(s));
|
||||
// return numeric_limits<PRUint32>::max();
|
||||
}
|
||||
|
||||
static
|
||||
PRUint32
|
||||
readable_size( const char* first, const char* last )
|
||||
{
|
||||
return PRUint32(last-first);
|
||||
}
|
||||
|
||||
static
|
||||
const char*
|
||||
read( const char* s )
|
||||
{
|
||||
return s;
|
||||
}
|
||||
};
|
||||
|
||||
// Add specialization for |PRUnichar| only if it is needed
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
template <class OutputIterator>
|
||||
@@ -526,6 +559,8 @@ struct nsCharSinkTraits
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef HAVE_CPP_PARTIAL_SPECIALIZATION
|
||||
|
||||
template <class CharT>
|
||||
struct nsCharSinkTraits<CharT*>
|
||||
{
|
||||
@@ -539,5 +574,34 @@ struct nsCharSinkTraits<CharT*>
|
||||
}
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
NS_SPECIALIZE_TEMPLATE
|
||||
struct nsCharSinkTraits<char*>
|
||||
{
|
||||
static
|
||||
PRUint32
|
||||
write( char*& iter, const char* s, PRUint32 n )
|
||||
{
|
||||
nsCharTraits<char>::copy(iter, s, n);
|
||||
iter += n;
|
||||
return n;
|
||||
}
|
||||
};
|
||||
|
||||
NS_SPECIALIZE_TEMPLATE
|
||||
struct nsCharSinkTraits<PRUnichar*>
|
||||
{
|
||||
static
|
||||
PRUint32
|
||||
write( PRUnichar*& iter, const PRUnichar* s, PRUint32 n )
|
||||
{
|
||||
nsCharTraits<PRUnichar>::copy(iter, s, n);
|
||||
iter += n;
|
||||
return n;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // !defined(_nsCharTraits_h__)
|
||||
|
||||
Reference in New Issue
Block a user