move to comphelper, and rename
This commit is contained in:
@@ -46,6 +46,72 @@ namespace rtl { class OUString; }
|
||||
// go into the stable URE API:
|
||||
namespace comphelper { namespace string {
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <typename T, typename U> T* string_alloc(sal_Int32 nLen)
|
||||
{
|
||||
//Clearly this is somewhat cosy with the sal implmentation
|
||||
|
||||
//rtl_[u]String contains U buffer[1], so an input of nLen
|
||||
//allocates a buffer of nLen + 1 and we'll ensure a null termination
|
||||
T *newStr = (T*)rtl_allocateMemory(sizeof(T) + sizeof(U) * nLen);
|
||||
newStr->refCount = 1;
|
||||
newStr->length = nLen;
|
||||
newStr->buffer[nLen]=0;
|
||||
return newStr;
|
||||
}
|
||||
}
|
||||
|
||||
/** Allocate a new string containing space for a given number of characters.
|
||||
|
||||
The reference count of the new string will be 1. The length of the string
|
||||
will be nLen. This function does not handle out-of-memory conditions.
|
||||
|
||||
The characters of the capacity are not cleared, and the length is set to
|
||||
nLen, unlike the similar method of rtl_uString_new_WithLength which
|
||||
zeros out the buffer, and sets the length to 0. So should be somewhat
|
||||
more efficient for allocating a new string.
|
||||
|
||||
call rtl_uString_release to release the string
|
||||
alternatively pass ownership to an OUString with
|
||||
rtl::OUString(newStr, SAL_NO_ACQUIRE);
|
||||
|
||||
@param newStr
|
||||
pointer to the new string.
|
||||
|
||||
@param len
|
||||
the number of characters.
|
||||
*/
|
||||
COMPHELPER_DLLPUBLIC inline rtl_uString * SAL_CALL rtl_uString_alloc(sal_Int32 nLen)
|
||||
{
|
||||
return detail::string_alloc<rtl_uString, sal_Unicode>(nLen);
|
||||
}
|
||||
|
||||
/** Allocate a new string containing space for a given number of characters.
|
||||
|
||||
The reference count of the new string will be 1. The length of the string
|
||||
will be nLen. This function does not handle out-of-memory conditions.
|
||||
|
||||
The characters of the capacity are not cleared, and the length is set to
|
||||
nLen, unlike the similar method of rtl_String_new_WithLength which
|
||||
zeros out the buffer, and sets the length to 0. So should be somewhat
|
||||
more efficient for allocating a new string.
|
||||
|
||||
call rtl_String_release to release the string
|
||||
alternatively pass ownership to an OUString with
|
||||
rtl::OUString(newStr, SAL_NO_ACQUIRE);
|
||||
|
||||
@param newStr
|
||||
pointer to the new string.
|
||||
|
||||
@param len
|
||||
the number of characters.
|
||||
*/
|
||||
COMPHELPER_DLLPUBLIC inline rtl_String * SAL_CALL rtl_string_alloc(sal_Int32 nLen)
|
||||
{
|
||||
return detail::string_alloc<rtl_String, sal_Char>(nLen);
|
||||
}
|
||||
|
||||
/**
|
||||
Replace the first occurrence of a substring with another string.
|
||||
|
||||
|
@@ -33,7 +33,6 @@
|
||||
#include <cppuhelper/implbase1.hxx>
|
||||
#include <rtl/ustrbuf.h>
|
||||
#include <rtl/ustring.hxx>
|
||||
#include <i18nutil/x_rtl_ustring.h>
|
||||
|
||||
namespace com { namespace sun { namespace star { namespace i18n {
|
||||
|
||||
|
@@ -34,7 +34,7 @@
|
||||
#include <com/sun/star/i18n/UnicodeType.hpp>
|
||||
#include <com/sun/star/i18n/KCharacterType.hpp>
|
||||
#include <unicode/uchar.h>
|
||||
#include <i18nutil/x_rtl_ustring.h>
|
||||
#include <comphelper/string.hxx>
|
||||
#include <breakiteratorImpl.hxx>
|
||||
|
||||
using namespace ::com::sun::star::uno;
|
||||
@@ -99,7 +99,7 @@ cclass_Unicode::toTitle( const OUString& Text, sal_Int32 nPos, sal_Int32 nCount,
|
||||
nCount = len - nPos;
|
||||
|
||||
trans->setMappingType(MappingTypeToTitle, rLocale);
|
||||
rtl_uString* pStr = x_rtl_uString_new_WithLength(nCount);
|
||||
rtl_uString* pStr = comphelper::string::rtl_uString_alloc(nCount);
|
||||
sal_Unicode* out = pStr->buffer;
|
||||
BreakIteratorImpl brk(xMSF);
|
||||
Boundary bdy = brk.getWordBoundary(Text, nPos, rLocale,
|
||||
|
@@ -34,7 +34,7 @@
|
||||
#include <nativenumbersupplier.hxx>
|
||||
#include <localedata.hxx>
|
||||
#include <data/numberchar.h>
|
||||
#include <i18nutil/x_rtl_ustring.h>
|
||||
#include <comphelper/string.hxx>
|
||||
|
||||
using namespace ::com::sun::star::uno;
|
||||
using namespace ::com::sun::star::lang;
|
||||
@@ -79,7 +79,7 @@ OUString SAL_CALL AsciiToNativeChar( const OUString& inStr, sal_Int32 startPos,
|
||||
Sequence< sal_Int32 >& offset, sal_Bool useOffset, sal_Int16 number ) throw(RuntimeException)
|
||||
{
|
||||
const sal_Unicode *src = inStr.getStr() + startPos;
|
||||
rtl_uString *newStr = x_rtl_uString_new_WithLength(nCount);
|
||||
rtl_uString *newStr = comphelper::string::rtl_uString_alloc(nCount);
|
||||
if (useOffset)
|
||||
offset.realloc(nCount);
|
||||
|
||||
|
@@ -35,7 +35,6 @@
|
||||
#include <com/sun/star/linguistic2/ConversionDirection.hpp>
|
||||
#include <com/sun/star/linguistic2/ConversionDictionaryType.hpp>
|
||||
#include <rtl/ustrbuf.hxx>
|
||||
#include <i18nutil/x_rtl_ustring.h>
|
||||
#include <unicode/uchar.h>
|
||||
|
||||
using namespace com::sun::star::lang;
|
||||
|
@@ -35,7 +35,7 @@
|
||||
#include <com/sun/star/i18n/TextConversionOption.hpp>
|
||||
#include <com/sun/star/linguistic2/ConversionDirection.hpp>
|
||||
#include <com/sun/star/linguistic2/ConversionDictionaryType.hpp>
|
||||
#include <i18nutil/x_rtl_ustring.h>
|
||||
#include <comphelper/string.hxx>
|
||||
|
||||
using namespace com::sun::star::lang;
|
||||
using namespace com::sun::star::i18n;
|
||||
@@ -86,7 +86,7 @@ TextConversion_zh::getCharConversion(const OUString& aText, sal_Int32 nStartPos,
|
||||
Index = ((const sal_uInt16* (*)())getFunctionBySymbol("getSTC_CharIndex_S2T"))();
|
||||
}
|
||||
|
||||
rtl_uString * newStr = x_rtl_uString_new_WithLength(nLength);
|
||||
rtl_uString * newStr = comphelper::string::rtl_uString_alloc(nLength);
|
||||
for (sal_Int32 i = 0; i < nLength; i++)
|
||||
newStr->buffer[i] =
|
||||
getOneCharConversion(aText[nStartPos+i], Data, Index);
|
||||
|
@@ -29,9 +29,8 @@
|
||||
// MARKER(update_precomp.py): autogen include statement, do not remove
|
||||
#include "precompiled_i18npool.hxx"
|
||||
|
||||
// prevent internal compiler error with MSVC6SP3
|
||||
#include <utility>
|
||||
|
||||
#include <comphelper/string.hxx>
|
||||
#include <i18nutil/oneToOneMapping.hxx>
|
||||
#define TRANSLITERATION_IandEfollowedByYa_ja_JP
|
||||
#include <transliteration_Ignore.hxx>
|
||||
@@ -88,7 +87,7 @@ ignoreIandEfollowedByYa_ja_JP::folding( const OUString& inStr, sal_Int32 startPo
|
||||
{
|
||||
// Create a string buffer which can hold nCount + 1 characters.
|
||||
// The reference count is 1 now.
|
||||
rtl_uString * newStr = x_rtl_uString_new_WithLength(nCount);
|
||||
rtl_uString * newStr = comphelper::string::rtl_uString_alloc(nCount);
|
||||
sal_Unicode * dst = newStr->buffer;
|
||||
const sal_Unicode * src = inStr.getStr() + startPos;
|
||||
|
||||
|
@@ -29,9 +29,8 @@
|
||||
// MARKER(update_precomp.py): autogen include statement, do not remove
|
||||
#include "precompiled_i18npool.hxx"
|
||||
|
||||
// prevent internal compiler error with MSVC6SP3
|
||||
#include <utility>
|
||||
|
||||
#include <comphelper/string.hxx>
|
||||
#include <i18nutil/oneToOneMapping.hxx>
|
||||
#define TRANSLITERATION_IterationMark_ja_JP
|
||||
#include <transliteration_Ignore.hxx>
|
||||
@@ -103,7 +102,7 @@ ignoreIterationMark_ja_JP::folding( const OUString& inStr, sal_Int32 startPos, s
|
||||
|
||||
// Create a string buffer which can hold nCount + 1 characters.
|
||||
// The reference count is 1 now.
|
||||
rtl_uString * newStr = x_rtl_uString_new_WithLength(nCount);
|
||||
rtl_uString * newStr = comphelper::string::rtl_uString_alloc(nCount);
|
||||
sal_Unicode * dst = newStr->buffer;
|
||||
const sal_Unicode * src = inStr.getStr() + startPos;
|
||||
|
||||
|
@@ -29,9 +29,8 @@
|
||||
// MARKER(update_precomp.py): autogen include statement, do not remove
|
||||
#include "precompiled_i18npool.hxx"
|
||||
|
||||
// prevent internal compiler error with MSVC6SP3
|
||||
#include <utility>
|
||||
|
||||
#include <comphelper/string.hxx>
|
||||
#define TRANSLITERATION_KiKuFollowedBySa_ja_JP
|
||||
#include <transliteration_Ignore.hxx>
|
||||
|
||||
@@ -48,7 +47,7 @@ ignoreKiKuFollowedBySa_ja_JP::folding( const OUString& inStr, sal_Int32 startPos
|
||||
{
|
||||
// Create a string buffer which can hold nCount + 1 characters.
|
||||
// The reference count is 1 now.
|
||||
rtl_uString * newStr = x_rtl_uString_new_WithLength(nCount);
|
||||
rtl_uString * newStr = comphelper::string::rtl_uString_alloc(nCount);
|
||||
sal_Unicode * dst = newStr->buffer;
|
||||
const sal_Unicode * src = inStr.getStr() + startPos;
|
||||
|
||||
|
@@ -29,9 +29,8 @@
|
||||
// MARKER(update_precomp.py): autogen include statement, do not remove
|
||||
#include "precompiled_i18npool.hxx"
|
||||
|
||||
// prevent internal compiler error with MSVC6SP3
|
||||
#include <utility>
|
||||
|
||||
#include <comphelper/string.hxx>
|
||||
#define TRANSLITERATION_ProlongedSoundMark_ja_JP
|
||||
#include <transliteration_Ignore.hxx>
|
||||
|
||||
@@ -310,7 +309,7 @@ ignoreProlongedSoundMark_ja_JP::folding( const OUString& inStr, sal_Int32 startP
|
||||
{
|
||||
// Create a string buffer which can hold nCount + 1 characters.
|
||||
// The reference count is 1 now.
|
||||
rtl_uString * newStr = x_rtl_uString_new_WithLength(nCount);
|
||||
rtl_uString * newStr = comphelper::string::rtl_uString_alloc(nCount);
|
||||
sal_Unicode * dst = newStr->buffer;
|
||||
const sal_Unicode * src = inStr.getStr() + startPos;
|
||||
|
||||
|
@@ -29,9 +29,8 @@
|
||||
// MARKER(update_precomp.py): autogen include statement, do not remove
|
||||
#include "precompiled_i18npool.hxx"
|
||||
|
||||
// prevent internal compiler error with MSVC6SP3
|
||||
#include <utility>
|
||||
|
||||
#include <comphelper/string.hxx>
|
||||
#include <transliteration_Ignore.hxx>
|
||||
|
||||
using namespace com::sun::star::uno;
|
||||
@@ -138,7 +137,7 @@ transliteration_Ignore::folding( const OUString& inStr, sal_Int32 startPos,
|
||||
{
|
||||
// Create a string buffer which can hold nCount + 1 characters.
|
||||
// The reference count is 1 now.
|
||||
rtl_uString * newStr = x_rtl_uString_new_WithLength(nCount);
|
||||
rtl_uString * newStr = comphelper::string::rtl_uString_alloc(nCount);
|
||||
sal_Unicode * dst = newStr->buffer;
|
||||
const sal_Unicode * src = inStr.getStr() + startPos;
|
||||
|
||||
|
@@ -32,6 +32,7 @@
|
||||
#include <transliteration_Numeric.hxx>
|
||||
#include <nativenumbersupplier.hxx>
|
||||
#include <defaultnumberingprovider.hxx>
|
||||
#include <comphelper/string.hxx>
|
||||
|
||||
using namespace com::sun::star::uno;
|
||||
|
||||
@@ -78,7 +79,7 @@ transliteration_Numeric::transliterateBullet( const OUString& inStr, sal_Int32 s
|
||||
if (endPos > inStr.getLength())
|
||||
endPos = inStr.getLength();
|
||||
|
||||
rtl_uString* pStr = x_rtl_uString_new_WithLength(nCount);
|
||||
rtl_uString* pStr = comphelper::string::rtl_uString_alloc(nCount);
|
||||
sal_Unicode* out = pStr->buffer;
|
||||
|
||||
if (useOffset)
|
||||
|
@@ -29,9 +29,8 @@
|
||||
// MARKER(update_precomp.py): autogen include statement, do not remove
|
||||
#include "precompiled_i18npool.hxx"
|
||||
|
||||
// prevent internal compiler error with MSVC6SP3
|
||||
#include <utility>
|
||||
|
||||
#include <comphelper/string.hxx>
|
||||
#include <transliteration_OneToOne.hxx>
|
||||
|
||||
using namespace com::sun::star::uno;
|
||||
@@ -75,7 +74,7 @@ transliteration_OneToOne::transliterate( const OUString& inStr, sal_Int32 startP
|
||||
{
|
||||
// Create a string buffer which can hold nCount + 1 characters.
|
||||
// The reference count is 1 now.
|
||||
rtl_uString * newStr = x_rtl_uString_new_WithLength(nCount);
|
||||
rtl_uString * newStr = comphelper::string::rtl_uString_alloc(nCount);
|
||||
sal_Unicode * dst = newStr->buffer;
|
||||
const sal_Unicode * src = inStr.getStr() + startPos;
|
||||
|
||||
|
@@ -34,6 +34,7 @@
|
||||
#include <i18nutil/unicode.hxx>
|
||||
|
||||
#include <comphelper/processfactory.hxx>
|
||||
#include <comphelper/string.hxx>
|
||||
#include <osl/diagnose.h>
|
||||
|
||||
#include <string.h>
|
||||
@@ -129,7 +130,7 @@ Transliteration_body::transliterate(
|
||||
const Mapping &map = casefolding::getValue( in, i, nCount, aLocale, nTmpMappingType );
|
||||
nOffCount += map.nmap;
|
||||
}
|
||||
rtl_uString* pStr = x_rtl_uString_new_WithLength(nOffCount);
|
||||
rtl_uString* pStr = comphelper::string::rtl_uString_alloc(nOffCount);
|
||||
sal_Unicode* out = pStr->buffer;
|
||||
|
||||
if ( nOffCount != offset.getLength() )
|
||||
@@ -199,7 +200,7 @@ OUString SAL_CALL
|
||||
Transliteration_body::transliterateChar2String( sal_Unicode inChar ) throw(RuntimeException)
|
||||
{
|
||||
const Mapping &map = casefolding::getValue(&inChar, 0, 1, aLocale, nMappingType);
|
||||
rtl_uString* pStr = x_rtl_uString_new_WithLength(map.nmap);
|
||||
rtl_uString* pStr = comphelper::string::rtl_uString_alloc(map.nmap);
|
||||
sal_Unicode* out = pStr->buffer;
|
||||
sal_Int32 i;
|
||||
|
||||
|
@@ -32,6 +32,5 @@ $(eval $(call gb_Package_add_file,i18nutil_inc,inc/i18nutil/casefolding.hxx,i18n
|
||||
$(eval $(call gb_Package_add_file,i18nutil_inc,inc/i18nutil/oneToOneMapping.hxx,i18nutil/oneToOneMapping.hxx))
|
||||
$(eval $(call gb_Package_add_file,i18nutil_inc,inc/i18nutil/unicode.hxx,i18nutil/unicode.hxx))
|
||||
$(eval $(call gb_Package_add_file,i18nutil_inc,inc/i18nutil/widthfolding.hxx,i18nutil/widthfolding.hxx))
|
||||
$(eval $(call gb_Package_add_file,i18nutil_inc,inc/i18nutil/x_rtl_ustring.h,i18nutil/x_rtl_ustring.h))
|
||||
|
||||
# vim: set noet sw=4:
|
||||
|
@@ -1,2 +1,2 @@
|
||||
inu i18nutil : sal cppu offapi NULL
|
||||
inu i18nutil : sal cppu comphelper offapi NULL
|
||||
inu i18nutil\prj nmake - all inu_prj NULL
|
||||
|
@@ -29,7 +29,7 @@
|
||||
// prevent internal compiler error with MSVC6SP3
|
||||
#include <utility>
|
||||
#include <i18nutil/widthfolding.hxx>
|
||||
#include <i18nutil/x_rtl_ustring.h>
|
||||
#include <comphelper/string.hxx>
|
||||
#include "widthfolding_data.h"
|
||||
|
||||
using namespace com::sun::star::uno;
|
||||
@@ -56,7 +56,7 @@ OUString widthfolding::decompose_ja_voiced_sound_marks (const OUString& inStr, s
|
||||
// Create a string buffer which can hold nCount * 2 + 1 characters.
|
||||
// Its size may become double of nCount.
|
||||
// The reference count is 1 now.
|
||||
rtl_uString * newStr = x_rtl_uString_new_WithLength(nCount * 2);
|
||||
rtl_uString * newStr = comphelper::string::rtl_uString_alloc(nCount * 2);
|
||||
|
||||
sal_Int32 *p = NULL;
|
||||
sal_Int32 position = 0;
|
||||
@@ -118,7 +118,7 @@ OUString widthfolding::compose_ja_voiced_sound_marks (const OUString& inStr, sal
|
||||
// Create a string buffer which can hold nCount + 1 characters.
|
||||
// Its size may become equal to nCount or smaller.
|
||||
// The reference count is 1 now.
|
||||
rtl_uString * newStr = x_rtl_uString_new_WithLength(nCount);
|
||||
rtl_uString * newStr = comphelper::string::rtl_uString_alloc(nCount);
|
||||
|
||||
// Prepare pointers of unicode character arrays.
|
||||
const sal_Unicode* src = inStr.getStr() + startPos;
|
||||
|
Reference in New Issue
Block a user