diff options
-rw-r--r-- | tools/Library_tl.mk | 3 | ||||
-rw-r--r-- | tools/inc/impstrg.hxx | 1 | ||||
-rw-r--r-- | tools/inc/tools/fsys.hxx | 5 | ||||
-rw-r--r-- | tools/inc/tools/string.hxx | 174 | ||||
-rw-r--r-- | tools/source/string/strcvt.cxx | 74 | ||||
-rw-r--r-- | tools/source/string/strucvt.cxx | 5 | ||||
-rw-r--r-- | tools/source/string/tstring.cxx | 172 | ||||
-rw-r--r-- | tools/source/string/tustring.cxx | 21 |
8 files changed, 27 insertions, 428 deletions
diff --git a/tools/Library_tl.mk b/tools/Library_tl.mk index d8f8dd61d4a2..d0f05a7c3123 100644 --- a/tools/Library_tl.mk +++ b/tools/Library_tl.mk @@ -106,7 +106,6 @@ $(eval $(call gb_Library_add_exception_objects,tl,\ tools/source/stream/strmsys \ tools/source/stream/vcompat \ tools/source/string/tenccvt \ - tools/source/string/tstring \ tools/source/string/tustring \ tools/source/string/reversemap \ tools/source/zcodec/zcodec \ @@ -140,6 +139,4 @@ $(eval $(call gb_Library_add_linked_libs,tl,\ endif -# no -DTOOLS_DLLIMPLEMENTATION on toolsdll -# -DEXCEPTIONS_OFF -fno-exceptions on datetime tdate ttime bigint color config fract gen line link poly2 svborder toolsin inetmime inetmsg inetstrm contnr mempool multisel table unqidx cachestr stream strmsys vcompat tenccvt tstring tustring # vim: set noet sw=4 ts=4: diff --git a/tools/inc/impstrg.hxx b/tools/inc/impstrg.hxx index 178bccec26e8..fb8bbe18f307 100644 --- a/tools/inc/impstrg.hxx +++ b/tools/inc/impstrg.hxx @@ -36,7 +36,6 @@ // - Debug-Methoden fuer String - // ------------------------------ -const char* DbgCheckByteString( const void* pString ); const char* DbgCheckUniString( const void* pString ); // ------------------------------- diff --git a/tools/inc/tools/fsys.hxx b/tools/inc/tools/fsys.hxx index 33ac3cbf56d5..d15c19ca27e9 100644 --- a/tools/inc/tools/fsys.hxx +++ b/tools/inc/tools/fsys.hxx @@ -267,7 +267,10 @@ public: void SetExtension( const String& rExt, char cSep = '.' ); String GetExtension( char cSep = '.' ) const; void SetName( const String& rName, FSysPathStyle eFormatter = FSYS_STYLE_HOST ); - inline const String GetNameDirect() const { return String(aName, osl_getThreadTextEncoding()); } + const String GetNameDirect() const + { + return rtl::OStringToOUString(aName, osl_getThreadTextEncoding()); + } String GetName( FSysPathStyle eFormatter = FSYS_STYLE_HOST ) const; String CutName( FSysPathStyle eFormatter = FSYS_STYLE_HOST ); String GetBase(char cSep = '.' ) const; diff --git a/tools/inc/tools/string.hxx b/tools/inc/tools/string.hxx index ecd48c6b93c8..a4b3e46d2944 100644 --- a/tools/inc/tools/string.hxx +++ b/tools/inc/tools/string.hxx @@ -54,7 +54,6 @@ class ResId; class String; -class ByteString; class UniString; // ----------------------------------------------------------------------- @@ -111,172 +110,6 @@ enum StringCompare { COMPARE_LESS = -1, COMPARE_EQUAL = 0, COMPARE_GREATER = 1 } // Nur fuer Debug-Zwecke (darf nie direkt einem String zugewiesen werden) #ifdef SAL_W32 -#pragma pack(push, 8) -#endif - -typedef struct _ByteStringData -{ - sal_Int32 mnRefCount; // Referenz counter - sal_Int32 mnLen; // Length of the String - sal_Char maStr[1]; // CharArray (String) -} ByteStringData; - -#ifdef SAL_W32 -#pragma pack(pop) -#endif - -// -------------- -// - ByteString - -// -------------- - -class TOOLS_DLLPUBLIC ByteString -{ - friend class UniString; - -private: - ByteStringData* mpData; - - TOOLS_DLLPRIVATE inline void ImplCopyData(); - TOOLS_DLLPRIVATE inline char * ImplCopyStringData(char *); - - ByteString( const int* pDummy ); // not implemented: to prevent ByteString( NULL ) - ByteString(int); // not implemented; to detect misuses - // of ByteString(sal_Char); - ByteString( sal_Char c ); //not implemented - ByteString( const UniString& rUniStr, xub_StrLen nPos, xub_StrLen nLen, - rtl_TextEncoding eTextEncoding, - sal_uInt32 nCvtFlags = UNISTRING_TO_BYTESTRING_CVTFLAGS ); //not implemented, to detect use of removed methods without compiler making something to fit - ByteString( const sal_Unicode* pUniStr, xub_StrLen nLen, - rtl_TextEncoding eTextEncoding, - sal_uInt32 nCvtFlags = UNISTRING_TO_BYTESTRING_CVTFLAGS ); //not implemented, to detect use of removed methods without compiler making something to fit - ByteString( const UniString& rUniStr, - rtl_TextEncoding eTextEncoding, - sal_uInt32 nCvtFlags = UNISTRING_TO_BYTESTRING_CVTFLAGS ); //not implemented, to detect use of removed methods without compiler making something to fit - ByteString( const sal_Char* pCharStr, xub_StrLen nLen ); //not implemented, to detect use of removed methods without compiler making something to fit - void Assign(int); // not implemented; to detect misuses of - // Assign(sal_Char) - ByteString& Assign( const sal_Char* pCharStr, xub_StrLen nLen ); //not implemented, to detect use of removed methods without compiler making something to fit - ByteString& Assign( const sal_Char* pCharStr ); //not implemented, to detect use of removed methods without compiler making something to fit - ByteString& operator =( const sal_Char* ); //not implemented, to detect use of removed methods without compiler making something to fit - ByteString& operator =(const sal_Char); //not implemented, to detect use of removed methods without compiler making something to fit - - ByteString& Assign(sal_Char); //not implemented, to detect use of removed methods without compiler making something to fit - void operator =(int); // not implemented; to detect misuses - // of operator =(sal_Char) - void Append(int); // not implemented; to detect misuses of - // Append(char) - ByteString& Append( const sal_Char* pCharStr, xub_StrLen nLen ); // not implemented, to detect use of removed methods without compiler making something to fit - ByteString& operator +=(sal_Char); //not implemented, to detect use of removed methods without compiler making something to fit - ByteString& Append( char c ); //not implemented, to detect use of removed methods without compiler making something to fit - void operator +=(int); // not implemented; to detect misuses - // of operator +=(sal_Char) - - friend sal_Bool operator == ( const ByteString& rStr1, const ByteString& rStr2 ); //not implemented, to detect use of removed methods without compiler making something to fit - friend sal_Bool operator < ( const ByteString& rStr1, const ByteString& rStr2 ); //not implemented, to detect use of removed methods without compiler making something to fit - friend sal_Bool operator > ( const ByteString& rStr1, const ByteString& rStr2 ); //not implemented, to detect use of removed methods without compiler making something to fit -public: - ByteString(); - ByteString( const ByteString& rStr ); - ByteString( const ByteString& rStr, xub_StrLen nPos, xub_StrLen nLen ); - ByteString( const rtl::OString& rStr ); - ByteString( const sal_Char* pCharStr ); - ~ByteString(); - - operator rtl::OString () const - { - return rtl::OString (reinterpret_cast<rtl_String*>(mpData)); - } - - ByteString& Assign( const ByteString& rStr ); - ByteString& Assign( const rtl::OString& rStr ); - ByteString& operator =( const ByteString& rStr ) - { return Assign( rStr ); } - ByteString& operator =( const rtl::OString& rStr ) - { return Assign( rStr ); } - - ByteString& Append( const ByteString& rStr ); - ByteString& Append( const sal_Char* pCharStr ); - ByteString& operator +=( const ByteString& rStr ) - { return Append( rStr ); } - ByteString& operator +=( const sal_Char* pCharStr ) - { return Append( pCharStr ); } - - void SetChar( xub_StrLen nIndex, sal_Char c ); - sal_Char GetChar( xub_StrLen nIndex ) const - { return mpData->maStr[nIndex]; } - - xub_StrLen Len() const { return (xub_StrLen)mpData->mnLen; } - - ByteString& Insert( const ByteString& rStr, xub_StrLen nIndex = STRING_LEN ); - ByteString& Replace( xub_StrLen nIndex, xub_StrLen nCount, const ByteString& rStr ); - ByteString& Erase( xub_StrLen nIndex = 0, xub_StrLen nCount = STRING_LEN ); - ByteString Copy( xub_StrLen nIndex = 0, xub_StrLen nCount = STRING_LEN ) const; - - ByteString& ToLowerAscii(); - - StringCompare CompareTo( const sal_Char* pCharStr, - xub_StrLen nLen = STRING_LEN ) const; - StringCompare CompareIgnoreCaseToAscii( const sal_Char* pCharStr, - xub_StrLen nLen = STRING_LEN ) const; - sal_Bool Equals( const sal_Char* pCharStr ) const; - - xub_StrLen Search( sal_Char c, xub_StrLen nIndex = 0 ) const; - xub_StrLen Search( const ByteString& rStr, xub_StrLen nIndex = 0 ) const; - xub_StrLen Search( const sal_Char* pCharStr, xub_StrLen nIndex = 0 ) const; - - void SearchAndReplaceAll( sal_Char c, sal_Char cRep ); - - ByteString GetToken( xub_StrLen nToken, sal_Char cTok = ';' ) const; - - const sal_Char* GetBuffer() const { return mpData->maStr; } - - friend sal_Bool operator == ( const ByteString& rStr, const sal_Char* pCharStr ) - { return rStr.Equals( pCharStr ); } - friend sal_Bool operator == ( const sal_Char* pCharStr, const ByteString& rStr ) - { return rStr.Equals( pCharStr ); } - friend sal_Bool operator != ( const ByteString& rStr1, const ByteString& rStr2 ) - { return !(operator == ( rStr1, rStr2 )); } - friend sal_Bool operator != ( const ByteString& rStr, const sal_Char* pCharStr ) - { return !(operator == ( rStr, pCharStr )); } - friend sal_Bool operator != ( const sal_Char* pCharStr, const ByteString& rStr ) - { return !(operator == ( pCharStr, rStr )); } - friend sal_Bool operator < ( const ByteString& rStr, const sal_Char* pCharStr ) - { return (rStr.CompareTo( pCharStr ) == COMPARE_LESS); } - friend sal_Bool operator < ( const sal_Char* pCharStr, const ByteString& rStr ) - { return (rStr.CompareTo( pCharStr ) >= COMPARE_EQUAL); } - friend sal_Bool operator > ( const ByteString& rStr, const sal_Char* pCharStr ) - { return (rStr.CompareTo( pCharStr ) == COMPARE_GREATER); } - friend sal_Bool operator > ( const sal_Char* pCharStr, const ByteString& rStr ) - { return (rStr.CompareTo( pCharStr ) <= COMPARE_EQUAL); } - friend sal_Bool operator <= ( const ByteString& rStr1, const ByteString& rStr2 ) - { return !(operator > ( rStr1, rStr2 )); } - friend sal_Bool operator <= ( const ByteString& rStr, const sal_Char* pCharStr ) - { return !(operator > ( rStr, pCharStr )); } - friend sal_Bool operator <= ( const sal_Char* pCharStr, const ByteString& rStr ) - { return !(operator > ( pCharStr, rStr )); } - friend sal_Bool operator >= ( const ByteString& rStr1, const ByteString& rStr2 ) - { return !(operator < ( rStr1, rStr2 )); } - friend sal_Bool operator >= ( const ByteString& rStr, const sal_Char* pCharStr ) - { return !(operator < ( rStr, pCharStr )); } - friend sal_Bool operator >= ( const sal_Char* pCharStr, const ByteString& rStr ) - { return !(operator < ( pCharStr, rStr )); } -}; - -inline ByteString ByteString::Copy( xub_StrLen nIndex, xub_StrLen nCount ) const -{ - return ByteString( *this, nIndex, nCount ); -} - -// ----------------------------------------------------------------------- - -// ------------------------ -// - Interne String-Daten - -// ------------------------ - -// Daten vom String, mit denen der String verwaltet wird -// Nur fuer Debug-Zwecke (darf nie direkt einem String zugewiesen werden) - -#ifdef SAL_W32 #pragma pack(push, 4) #endif @@ -297,8 +130,6 @@ typedef struct _UniStringData class TOOLS_DLLPUBLIC UniString { - friend class ByteString; - TOOLS_DLLPRIVATE void InitStringRes( const sal_Char* pUTF8Str, sal_Int32 nLen ); private: @@ -318,9 +149,6 @@ private: // Append(sal_Unicode) void operator +=(int); // not implemented; to detect misuses // of operator +=(sal_Unicode) - UniString( const ByteString& rByteStr, xub_StrLen nPos, xub_StrLen nLen, - rtl_TextEncoding eTextEncoding, - sal_uInt32 nCvtFlags = BYTESTRING_TO_UNISTRING_CVTFLAGS ); //not implemented, removed //detect and reject use of RTL_CONSTASCII_STRINGPARAM instead of RTL_CONSTASCII_USTRINGPARAM TOOLS_DLLPRIVATE UniString( const sal_Char*, sal_Int32 ); @@ -334,7 +162,7 @@ public: UniString( const sal_Unicode* pCharStr, xub_StrLen nLen ); UniString( sal_Unicode c ); UniString(char c); // ...but allow "UniString('a')" - UniString( const ByteString& rByteStr, + UniString( const rtl::OString& rByteStr, rtl_TextEncoding eTextEncoding, sal_uInt32 nCvtFlags = BYTESTRING_TO_UNISTRING_CVTFLAGS ); UniString( const sal_Char* pByteStr, diff --git a/tools/source/string/strcvt.cxx b/tools/source/string/strcvt.cxx deleted file mode 100644 index 0f4a14516fce..000000000000 --- a/tools/source/string/strcvt.cxx +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -// ======================================================================= - -ByteString::ByteString( const rtl::OString& rStr ) - : mpData(NULL) -{ - DBG_CTOR( ByteString, DbgCheckByteString ); - - OSL_ENSURE(rStr.pData->length < STRING_MAXLEN, - "Overflowing rtl::OString -> ByteString cut to zero length"); - - if (rStr.pData->length < STRING_MAXLEN) - { - mpData = reinterpret_cast< ByteStringData * >(const_cast< rtl::OString & >(rStr).pData); - STRING_ACQUIRE((STRING_TYPE *)mpData); - } - else - { - STRING_NEW((STRING_TYPE **)&mpData); - } -} - -// ----------------------------------------------------------------------- - -ByteString& ByteString::Assign( const rtl::OString& rStr ) -{ - DBG_CHKTHIS( ByteString, DbgCheckByteString ); - - OSL_ENSURE(rStr.pData->length < STRING_MAXLEN, - "Overflowing rtl::OString -> ByteString cut to zero length"); - - if (rStr.pData->length < STRING_MAXLEN) - { - STRING_RELEASE((STRING_TYPE *)mpData); - mpData = reinterpret_cast< ByteStringData * >(const_cast< rtl::OString & >(rStr).pData); - STRING_ACQUIRE((STRING_TYPE *)mpData); - } - else - { - STRING_NEW((STRING_TYPE **)&mpData); - } - - return *this; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/tools/source/string/strucvt.cxx b/tools/source/string/strucvt.cxx index d047cb4ba3b5..6db930277ea8 100644 --- a/tools/source/string/strucvt.cxx +++ b/tools/source/string/strucvt.cxx @@ -45,14 +45,13 @@ void UniString::InitStringRes( const char* pUTF8Str, sal_Int32 nLen ) // ======================================================================= -UniString::UniString( const ByteString& rByteStr, rtl_TextEncoding eTextEncoding, sal_uInt32 nCvtFlags ) +UniString::UniString( const rtl::OString& rByteStr, rtl_TextEncoding eTextEncoding, sal_uInt32 nCvtFlags ) { DBG_CTOR( UniString, DbgCheckUniString ); - DBG_CHKOBJ( &rByteStr, ByteString, DbgCheckByteString ); mpData = NULL; rtl_string2UString( (rtl_uString **)(&mpData), - rByteStr.mpData->maStr, rByteStr.mpData->mnLen, + rByteStr.getStr(), rByteStr.getLength(), eTextEncoding, nCvtFlags ); } diff --git a/tools/source/string/tstring.cxx b/tools/source/string/tstring.cxx deleted file mode 100644 index 97bad851b5e3..000000000000 --- a/tools/source/string/tstring.cxx +++ /dev/null @@ -1,172 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -#include <string.h> - -#include "osl/diagnose.h" -#include <osl/interlck.h> -#include <rtl/alloc.h> -#include <rtl/memory.h> -#include <rtl/tencinfo.h> - -#include <tools/string.hxx> -#include <impstrg.hxx> - -#include <tools/debug.hxx> - -// ======================================================================= - -DBG_NAME( ByteString ) -DBG_NAMEEX( UniString ) - -// ----------------------------------------------------------------------- - -#define STRCODE sal_Char -#define STRCODEU unsigned char -#define STRING ByteString -#define STRINGDATA ByteStringData -#define DBGCHECKSTRING DbgCheckByteString -#define STRING_TYPE rtl_String -#define STRING_ACQUIRE rtl_string_acquire -#define STRING_RELEASE rtl_string_release -#define STRING_NEW rtl_string_new - - -// ----------------------------------------------------------------------- - -xub_StrLen ImplStringLen( const sal_Char* pStr ) -{ - const sal_Char* pTempStr = pStr; - while( *pTempStr ) - ++pTempStr; - return (xub_StrLen)(pTempStr-pStr); -} - -// ----------------------------------------------------------------------- - -xub_StrLen ImplStringLen( const sal_Unicode* pStr ) -{ - const sal_Unicode* pTempStr = pStr; - while( *pTempStr ) - ++pTempStr; - return (xub_StrLen)(pTempStr-pStr); -} - -// ----------------------------------------------------------------------- - -#include <strimp.cxx> -#include <strcvt.cxx> - -static sal_Int32 ImplStringICompare( const STRCODE* pStr1, const STRCODE* pStr2, - xub_StrLen nCount ) -{ - sal_Int32 nRet = 0; - STRCODE c1; - STRCODE c2; - do - { - if ( !nCount ) - break; - - // Ist das Zeichen zwischen 'A' und 'Z' dann umwandeln - c1 = *pStr1; - c2 = *pStr2; - if ( (c1 >= 65) && (c1 <= 90) ) - c1 += 32; - if ( (c2 >= 65) && (c2 <= 90) ) - c2 += 32; - nRet = ((sal_Int32)((STRCODEU)c1))-((sal_Int32)((STRCODEU)c2)); - if ( nRet != 0 ) - break; - - ++pStr1, - ++pStr2, - --nCount; - } - while ( c2 ); - - return nRet; -} - -StringCompare STRING::CompareIgnoreCaseToAscii( const STRCODE* pCharStr, - xub_StrLen nLen ) const -{ - DBG_CHKTHIS( STRING, DBGCHECKSTRING ); - - // String vergleichen - sal_Int32 nCompare = ImplStringICompare( mpData->maStr, pCharStr, nLen ); - - // Rueckgabewert anpassen - if ( nCompare == 0 ) - return COMPARE_EQUAL; - else if ( nCompare < 0 ) - return COMPARE_LESS; - else - return COMPARE_GREATER; -} - -StringCompare STRING::CompareTo( const STRCODE* pCharStr, xub_StrLen nLen ) const -{ - DBG_CHKTHIS( STRING, DBGCHECKSTRING ); - - // String vergleichen - sal_Int32 nCompare = ImplStringCompare( mpData->maStr, pCharStr, nLen ); - - // Rueckgabewert anpassen - if ( nCompare == 0 ) - return COMPARE_EQUAL; - else if ( nCompare < 0 ) - return COMPARE_LESS; - else - return COMPARE_GREATER; -} - -// ======================================================================= - -static sal_Int32 ImplStringCompare( const STRCODE* pStr1, const STRCODE* pStr2 ) -{ - sal_Int32 nRet; - while ( ((nRet = ((sal_Int32)((STRCODEU)*pStr1))-((sal_Int32)((STRCODEU)*pStr2))) == 0) && - *pStr2 ) - { - ++pStr1, - ++pStr2; - } - - return nRet; -} - -sal_Bool STRING::Equals( const STRCODE* pCharStr ) const -{ - DBG_CHKTHIS( STRING, DBGCHECKSTRING ); - - return (ImplStringCompare( mpData->maStr, pCharStr ) == 0); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/tools/source/string/tustring.cxx b/tools/source/string/tustring.cxx index 033498d5719c..4bb515e30ad8 100644 --- a/tools/source/string/tustring.cxx +++ b/tools/source/string/tustring.cxx @@ -45,7 +45,6 @@ // ======================================================================= DBG_NAME( UniString ) -DBG_NAMEEX( ByteString ) // ----------------------------------------------------------------------- @@ -1205,4 +1204,24 @@ STRING& STRING::Assign( const STRCODE* pCharStr ) return *this; } +// ----------------------------------------------------------------------- + +xub_StrLen ImplStringLen( const sal_Char* pStr ) +{ + const sal_Char* pTempStr = pStr; + while( *pTempStr ) + ++pTempStr; + return (xub_StrLen)(pTempStr-pStr); +} + +// ----------------------------------------------------------------------- + +xub_StrLen ImplStringLen( const sal_Unicode* pStr ) +{ + const sal_Unicode* pTempStr = pStr; + while( *pTempStr ) + ++pTempStr; + return (xub_StrLen)(pTempStr-pStr); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |