summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@suse.cz>2012-02-28 13:09:46 +0100
committerLuboš Luňák <l.lunak@suse.cz>2012-03-05 13:11:51 +0100
commit9db31fc5669abd1e1f8db5e9267c91423b36f223 (patch)
treed424ded1751283403f96d89e301d911f7eff5a15 /sal
parent282e96fb345761edb9015e8066189c3cbe5b8396 (diff)
rtl_uString_newFromAscii_WithLength() and use it in OUString
Diffstat (limited to 'sal')
-rw-r--r--sal/inc/rtl/ustring.h10
-rw-r--r--sal/inc/rtl/ustring.hxx4
-rw-r--r--sal/rtl/source/ustring.cxx10
-rw-r--r--sal/util/sal.map1
4 files changed, 22 insertions, 3 deletions
diff --git a/sal/inc/rtl/ustring.h b/sal/inc/rtl/ustring.h
index 03f145ba6ba4..80703f826423 100644
--- a/sal/inc/rtl/ustring.h
+++ b/sal/inc/rtl/ustring.h
@@ -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
diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx
index b74cd3782fa0..151e0a22c3ff 100644
--- a/sal/inc/rtl/ustring.hxx
+++ b/sal/inc/rtl/ustring.hxx
@@ -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");
diff --git a/sal/rtl/source/ustring.cxx b/sal/rtl/source/ustring.cxx
index 7c99758a9b6c..763d9c51e573 100644
--- a/sal/rtl/source/ustring.cxx
+++ b/sal/rtl/source/ustring.cxx
@@ -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++;
diff --git a/sal/util/sal.map b/sal/util/sal.map
index d6c3ab1fa842..5ee60b9b577d 100644
--- a/sal/util/sal.map
+++ b/sal/util/sal.map
@@ -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;