still not part of the build; more work adding the new functions. More to come

This commit is contained in:
scc%mozilla.org 2000-08-05 01:15:45 +00:00
parent 5aba41c891
commit 1d41a0a81b
3 changed files with 60 additions and 6 deletions

View File

@ -25,18 +25,34 @@
#include "nsReadableUtils.h"
char*
ToNewCString( const nsAReadableString& aSourceString )
template <class CharT>
inline
CharT*
CopyStringToNewZeroTerminatedBuffer( const basic_nsAReadableString<CharT>& aSourceString )
{
// no conversion needed, just allocate a buffer of the correct length and copy into it
CharT* result = NS_STATIC_CAST(CharT*, nsMemory::Alloc( (aSourceString.Length()+1) * sizeof(CharT) ));
*copy_string(aSourceString.BeginReading(), aSourceString.EndReading(), result) = CharT(0);
return result;
}
char*
ToNewCString( const nsAReadableCString& aSourceCString )
{
return CopyStringToNewZeroTerminatedBuffer(aSourceCString);
}
PRUnichar*
ToNewUnicode( const nsAReadableString& aSourceString )
{
return CopyStringToNewZeroTerminatedBuffer(aSourceString);
}
char*
ToNewCString( const nsAReadableString& aSourceString )
{
}
@ -45,6 +61,8 @@ ToNewUnicode( const nsAReadableCString& aSourceCString )
{
}
PRBool
IsASCII( const nsAReadableString& aSourceString )
{

View File

@ -25,18 +25,34 @@
#include "nsReadableUtils.h"
char*
ToNewCString( const nsAReadableString& aSourceString )
template <class CharT>
inline
CharT*
CopyStringToNewZeroTerminatedBuffer( const basic_nsAReadableString<CharT>& aSourceString )
{
// no conversion needed, just allocate a buffer of the correct length and copy into it
CharT* result = NS_STATIC_CAST(CharT*, nsMemory::Alloc( (aSourceString.Length()+1) * sizeof(CharT) ));
*copy_string(aSourceString.BeginReading(), aSourceString.EndReading(), result) = CharT(0);
return result;
}
char*
ToNewCString( const nsAReadableCString& aSourceCString )
{
return CopyStringToNewZeroTerminatedBuffer(aSourceCString);
}
PRUnichar*
ToNewUnicode( const nsAReadableString& aSourceString )
{
return CopyStringToNewZeroTerminatedBuffer(aSourceString);
}
char*
ToNewCString( const nsAReadableString& aSourceString )
{
}
@ -45,6 +61,8 @@ ToNewUnicode( const nsAReadableCString& aSourceCString )
{
}
PRBool
IsASCII( const nsAReadableString& aSourceString )
{

View File

@ -25,18 +25,34 @@
#include "nsReadableUtils.h"
char*
ToNewCString( const nsAReadableString& aSourceString )
template <class CharT>
inline
CharT*
CopyStringToNewZeroTerminatedBuffer( const basic_nsAReadableString<CharT>& aSourceString )
{
// no conversion needed, just allocate a buffer of the correct length and copy into it
CharT* result = NS_STATIC_CAST(CharT*, nsMemory::Alloc( (aSourceString.Length()+1) * sizeof(CharT) ));
*copy_string(aSourceString.BeginReading(), aSourceString.EndReading(), result) = CharT(0);
return result;
}
char*
ToNewCString( const nsAReadableCString& aSourceCString )
{
return CopyStringToNewZeroTerminatedBuffer(aSourceCString);
}
PRUnichar*
ToNewUnicode( const nsAReadableString& aSourceString )
{
return CopyStringToNewZeroTerminatedBuffer(aSourceString);
}
char*
ToNewCString( const nsAReadableString& aSourceString )
{
}
@ -45,6 +61,8 @@ ToNewUnicode( const nsAReadableCString& aSourceCString )
{
}
PRBool
IsASCII( const nsAReadableString& aSourceString )
{