mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
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:
parent
8ad74fbb50
commit
f7a6b498a9
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user