still not part of the build; I think everything's there, though. Some further testing and I'll add it to the build

This commit is contained in:
scc%mozilla.org 2000-08-05 02:13:59 +00:00
Родитель 8ad74fbb50
Коммит f7a6b498a9
3 изменённых файлов: 93 добавлений и 3 удалений

Просмотреть файл

@ -50,15 +50,44 @@ ToNewUnicode( const nsAReadableString& aSourceString )
}
template <class FromT, class ToT>
class LossyConversionSink
{
public:
typedef FromT input_type;
typedef ToT output_type;
public:
LossyConversionSink( output_type* aDestination ) : mDestination(aDestination) { }
PRUint32
write( const input_type* aSource, PRUint32 aSourceLength )
{
const input_type* done_writing = aSource + aSourceLength;
while ( aSource < done_writing )
*mDestination++ = NS_STATIC_CAST(output_type, *aSource++);
}
private:
OutputCharT* mDestination;
};
char*
ToNewCString( const nsAReadableString& aSourceString )
{
char* result = NS_STATIC_CAST(char*, nsMemory::Alloc(aSourceString.Length()+1));
*copy_string(aSourceString.BeginReading(), aSourceString.EndReading(), LossyConversionSink<PRUnichar, char>(result)) = char(0);
return result;
}
PRUnichar*
ToNewUnicode( const nsAReadableCString& aSourceCString )
{
PRUnichar* result = NS_STATIC_CAST(char*, nsMemory::Alloc( (aSourceString.Length()+1) * sizeof(PRUnichar) ));
*copy_string(aSourceCString.BeginReading(), aSourceCString.EndReading(), LossyConversionSink<char, PRUnichar>(result)) = PRUnichar(0);
return result;
}
@ -90,4 +119,5 @@ IsASCII( const nsAReadableString& aSourceString )
}
return PR_TRUE;
}
}

Просмотреть файл

@ -50,15 +50,44 @@ ToNewUnicode( const nsAReadableString& aSourceString )
}
template <class FromT, class ToT>
class LossyConversionSink
{
public:
typedef FromT input_type;
typedef ToT output_type;
public:
LossyConversionSink( output_type* aDestination ) : mDestination(aDestination) { }
PRUint32
write( const input_type* aSource, PRUint32 aSourceLength )
{
const input_type* done_writing = aSource + aSourceLength;
while ( aSource < done_writing )
*mDestination++ = NS_STATIC_CAST(output_type, *aSource++);
}
private:
OutputCharT* mDestination;
};
char*
ToNewCString( const nsAReadableString& aSourceString )
{
char* result = NS_STATIC_CAST(char*, nsMemory::Alloc(aSourceString.Length()+1));
*copy_string(aSourceString.BeginReading(), aSourceString.EndReading(), LossyConversionSink<PRUnichar, char>(result)) = char(0);
return result;
}
PRUnichar*
ToNewUnicode( const nsAReadableCString& aSourceCString )
{
PRUnichar* result = NS_STATIC_CAST(char*, nsMemory::Alloc( (aSourceString.Length()+1) * sizeof(PRUnichar) ));
*copy_string(aSourceCString.BeginReading(), aSourceCString.EndReading(), LossyConversionSink<char, PRUnichar>(result)) = PRUnichar(0);
return result;
}
@ -90,4 +119,5 @@ IsASCII( const nsAReadableString& aSourceString )
}
return PR_TRUE;
}
}

Просмотреть файл

@ -50,15 +50,44 @@ ToNewUnicode( const nsAReadableString& aSourceString )
}
template <class FromT, class ToT>
class LossyConversionSink
{
public:
typedef FromT input_type;
typedef ToT output_type;
public:
LossyConversionSink( output_type* aDestination ) : mDestination(aDestination) { }
PRUint32
write( const input_type* aSource, PRUint32 aSourceLength )
{
const input_type* done_writing = aSource + aSourceLength;
while ( aSource < done_writing )
*mDestination++ = NS_STATIC_CAST(output_type, *aSource++);
}
private:
OutputCharT* mDestination;
};
char*
ToNewCString( const nsAReadableString& aSourceString )
{
char* result = NS_STATIC_CAST(char*, nsMemory::Alloc(aSourceString.Length()+1));
*copy_string(aSourceString.BeginReading(), aSourceString.EndReading(), LossyConversionSink<PRUnichar, char>(result)) = char(0);
return result;
}
PRUnichar*
ToNewUnicode( const nsAReadableCString& aSourceCString )
{
PRUnichar* result = NS_STATIC_CAST(char*, nsMemory::Alloc( (aSourceString.Length()+1) * sizeof(PRUnichar) ));
*copy_string(aSourceCString.BeginReading(), aSourceCString.EndReading(), LossyConversionSink<char, PRUnichar>(result)) = PRUnichar(0);
return result;
}
@ -90,4 +119,5 @@ IsASCII( const nsAReadableString& aSourceString )
}
return PR_TRUE;
}
}