Kaydet (Commit) 9db31fc5 authored tarafından Luboš Luňák's avatar Luboš Luňák

rtl_uString_newFromAscii_WithLength() and use it in OUString

üst 282e96fb
......@@ -1243,6 +1243,16 @@ SAL_DLLPUBLIC void SAL_CALL rtl_uString_newFromStr_WithLength(
SAL_DLLPUBLIC void SAL_CALL rtl_uString_newFromAscii(
rtl_uString ** newStr, const sal_Char * value ) SAL_THROW_EXTERN_C();
/** Allocate a new string that contains a copy of a character array.
This is equivalent to rtl_uString_newFromAscii(), except that
length of the character array is explicitly passed to the function.
@since 3.6
*/
SAL_DLLPUBLIC void SAL_CALL rtl_uString_newFromAscii_WithLength(
rtl_uString ** newStr, const sal_Char * value, sal_Int32 len ) SAL_THROW_EXTERN_C();
/** Allocate a new string from an array of Unicode code points.
@param newString
......
......@@ -184,7 +184,7 @@ public:
OUString( const char (&literal)[ N ] )
{
pData = 0;
rtl_string2UString( &pData, literal, N - 1, RTL_TEXTENCODING_ASCII_US, 0 );
rtl_uString_newFromAscii_WithLength( &pData, literal, N - 1 );
if (pData == 0) {
#if defined EXCEPTIONS_OFF
SAL_WARN("sal", "std::bad_alloc but EXCEPTIONS_OFF");
......@@ -338,7 +338,7 @@ public:
template< int N >
OUString& operator=( const char (&literal)[ N ] )
{
rtl_string2UString( &pData, literal, N - 1, RTL_TEXTENCODING_ASCII_US, 0 );
rtl_uString_newFromAscii_WithLength( &pData, literal, N - 1 );
if (pData == 0) {
#if defined EXCEPTIONS_OFF
SAL_WARN("sal", "std::bad_alloc but EXCEPTIONS_OFF");
......
......@@ -471,6 +471,14 @@ void SAL_CALL rtl_uString_newFromAscii( rtl_uString** ppThis,
else
nLen = 0;
rtl_uString_newFromAscii_WithLength( ppThis, pCharStr, nLen );
}
void SAL_CALL rtl_uString_newFromAscii_WithLength( rtl_uString** ppThis,
const sal_Char* pCharStr,
sal_Int32 nLen )
SAL_THROW_EXTERN_C()
{
if ( !nLen )
{
IMPL_RTL_STRINGNAME( new )( ppThis );
......@@ -489,7 +497,7 @@ void SAL_CALL rtl_uString_newFromAscii( rtl_uString** ppThis,
{
/* Check ASCII range */
SAL_WARN_IF( ((unsigned char)*pCharStr) > 127, "rtl.string",
"rtl_uString_newFromAscii - Found char > 127" );
"rtl_uString_newFromAscii_WithLength - Found char > 127" );
*pBuffer = *pCharStr;
pBuffer++;
......
......@@ -305,6 +305,7 @@ UDK_3_0_0 {
rtl_uString_newFromStr;
rtl_uString_newFromStr_WithLength;
rtl_uString_newFromAscii;
rtl_uString_newFromAscii_WithLength;
rtl_uString_newFromString;
rtl_uString_newReplace;
rtl_uString_newReplaceStrAt;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment