diff options
author | Caolán McNamara <caolanm@redhat.com> | 2013-10-22 09:20:52 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-10-22 12:50:48 +0100 |
commit | b37e2dd071c83454b3b06c0959a76b6012f53abb (patch) | |
tree | 91de7e6d0c01e7391276a1142d9d1b2f503ab35a /tools | |
parent | b9eaa646815bf9b400ecc0d5726de5241428cf34 (diff) |
Resolves: fdo#38838 remove UniString
hammer silver nails into coffin and bury in concrete
Change-Id: I3fda2ff47738bb33793adab97faba2d439ac9a28
Diffstat (limited to 'tools')
-rw-r--r-- | tools/Library_tl.mk | 1 | ||||
-rw-r--r-- | tools/source/string/strimp.cxx | 136 | ||||
-rw-r--r-- | tools/source/string/strucvt.cxx | 58 | ||||
-rw-r--r-- | tools/source/string/tustring.cxx | 96 |
4 files changed, 0 insertions, 291 deletions
diff --git a/tools/Library_tl.mk b/tools/Library_tl.mk index 0676abf656c2..db2360b077f4 100644 --- a/tools/Library_tl.mk +++ b/tools/Library_tl.mk @@ -83,7 +83,6 @@ $(eval $(call gb_Library_add_exception_objects,tl,\ tools/source/stream/strmsys \ tools/source/stream/vcompat \ tools/source/string/tenccvt \ - tools/source/string/tustring \ tools/source/string/reversemap \ tools/source/zcodec/zcodec \ )) diff --git a/tools/source/string/strimp.cxx b/tools/source/string/strimp.cxx deleted file mode 100644 index de479e450669..000000000000 --- a/tools/source/string/strimp.cxx +++ /dev/null @@ -1,136 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -static sal_Int32 ImplStringCompareWithoutZero( const STRCODE* pStr1, const STRCODE* pStr2, - sal_Int32 nCount ) -{ - sal_Int32 nRet = 0; - while ( nCount && - ((nRet = ((sal_Int32)((STRCODEU)*pStr1))-((sal_Int32)((STRCODEU)*pStr2))) == 0) ) - { - ++pStr1, - ++pStr2, - --nCount; - } - - return nRet; -} - -static STRINGDATA* ImplAllocData( sal_Int32 nLen ) -{ - STRINGDATA* pData = (STRINGDATA*)rtl_allocateMemory( sizeof(STRINGDATA)+(nLen*sizeof( STRCODE )) ); - pData->mnRefCount = 1; - pData->mnLen = nLen; - pData->maStr[nLen] = 0; - return pData; -} - -static STRINGDATA* _ImplCopyData( STRINGDATA* pData ) -{ - unsigned int nSize = sizeof(STRINGDATA)+(pData->mnLen*sizeof( STRCODE )); - STRINGDATA* pNewData = (STRINGDATA*)rtl_allocateMemory( nSize ); - memcpy( pNewData, pData, nSize ); - pNewData->mnRefCount = 1; - STRING_RELEASE((STRING_TYPE *)pData); - return pNewData; -} - -inline void STRING::ImplCopyData() -{ - DBG_ASSERT( (mpData->mnRefCount != 0), "String::ImplCopyData() - RefCount == 0" ); - - // Dereference data if this string is referenced - if ( mpData->mnRefCount != 1 ) - mpData = _ImplCopyData( mpData ); -} - -inline STRCODE* STRING::ImplCopyStringData( STRCODE* pStr ) -{ - if ( mpData->mnRefCount != 1 ) { - DBG_ASSERT( (pStr >= mpData->maStr) && - ((pStr-mpData->maStr) < mpData->mnLen), - "ImplCopyStringData - pStr from other String-Instanz" ); - unsigned int nIndex = (unsigned int)(pStr-mpData->maStr); - mpData = _ImplCopyData( mpData ); - pStr = mpData->maStr + nIndex; - } - return pStr; -} - -inline sal_Int32 ImplGetCopyLen( sal_Int32 nStrLen, sal_Int32 nCopyLen ) -{ - OSL_ASSERT(nStrLen <= STRING_MAXLEN && nCopyLen <= STRING_MAXLEN); - if ( nCopyLen > STRING_MAXLEN-nStrLen ) - nCopyLen = STRING_MAXLEN-nStrLen; - return nCopyLen; -} - -STRING::STRING() - : mpData(NULL) -{ - STRING_NEW((STRING_TYPE **)&mpData); -} - -STRING::STRING( const STRING& rStr ) -{ - // Set pointer to argument string and increase reference counter - STRING_ACQUIRE((STRING_TYPE *)rStr.mpData); - mpData = rStr.mpData; -} - -STRING::~STRING() -{ - // free string data - STRING_RELEASE((STRING_TYPE *)mpData); -} - -STRING& STRING::Append( const STRING& rStr ) -{ - // Assignment is sufficient if string is empty - sal_Int32 nLen = mpData->mnLen; - if ( !nLen ) - { - STRING_ACQUIRE((STRING_TYPE *)rStr.mpData); - STRING_RELEASE((STRING_TYPE *)mpData); - mpData = rStr.mpData; - } - else - { - // Detect overflow - sal_Int32 nCopyLen = ImplGetCopyLen( nLen, rStr.mpData->mnLen ); - - if ( nCopyLen ) - { - // allocate string of new size - STRINGDATA* pNewData = ImplAllocData( nLen+nCopyLen ); - - // copy string - memcpy( pNewData->maStr, mpData->maStr, nLen*sizeof( STRCODE ) ); - memcpy( pNewData->maStr+nLen, rStr.mpData->maStr, nCopyLen*sizeof( STRCODE ) ); - - // free old string - STRING_RELEASE((STRING_TYPE *)mpData); - mpData = pNewData; - } - } - - return *this; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/tools/source/string/strucvt.cxx b/tools/source/string/strucvt.cxx deleted file mode 100644 index 916eb04116ad..000000000000 --- a/tools/source/string/strucvt.cxx +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -UniString::UniString( const OUString& rStr ) - : mpData(NULL) -{ - OSL_ENSURE(rStr.pData->length < STRING_MAXLEN, - "Overflowing OUString -> UniString cut to zero length"); - - - if (rStr.pData->length < STRING_MAXLEN) - { - mpData = reinterpret_cast< UniStringData * >(const_cast< OUString & >(rStr).pData); - STRING_ACQUIRE((STRING_TYPE *)mpData); - } - else - { - STRING_NEW((STRING_TYPE **)&mpData); - } -} - -UniString& UniString::Assign( const OUString& rStr ) -{ - OSL_ENSURE(rStr.pData->length < STRING_MAXLEN, - "Overflowing OUString -> UniString cut to zero length"); - - if (rStr.pData->length < STRING_MAXLEN) - { - if( mpData != NULL ) - STRING_RELEASE((STRING_TYPE *)mpData); - mpData = reinterpret_cast< UniStringData * >(const_cast< OUString & >(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/tustring.cxx b/tools/source/string/tustring.cxx deleted file mode 100644 index cc4f27d3915b..000000000000 --- a/tools/source/string/tustring.cxx +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <string.h> - -#include "boost/static_assert.hpp" - -#include <osl/interlck.h> -#include <rtl/alloc.h> -#include <rtl/tencinfo.h> -#include <rtl/instance.hxx> -#include <tools/string.hxx> - -#include <impstrg.hxx> - -#include <tools/debug.hxx> - -DBG_NAME( UniString ) - -#define STRCODE sal_Unicode -#define STRCODEU sal_Unicode -#define STRING UniString -#define STRINGDATA UniStringData -#define STRING_TYPE rtl_uString -#define STRING_ACQUIRE rtl_uString_acquire -#define STRING_RELEASE rtl_uString_release -#define STRING_NEW rtl_uString_new - -#include <strimp.cxx> -#include <strucvt.cxx> - -StringCompare STRING::CompareTo( const STRING& rStr, xub_StrLen nLen ) const -{ - if ( mpData == rStr.mpData ) - return COMPARE_EQUAL; - - // determine maximal length - if ( mpData->mnLen < nLen ) - nLen = static_cast< xub_StrLen >(mpData->mnLen+1); - if ( rStr.mpData->mnLen < nLen ) - nLen = static_cast< xub_StrLen >(rStr.mpData->mnLen+1); - - sal_Int32 nCompare = ImplStringCompareWithoutZero( mpData->maStr, rStr.mpData->maStr, nLen ); - - if ( nCompare == 0 ) - return COMPARE_EQUAL; - else if ( nCompare < 0 ) - return COMPARE_LESS; - else - return COMPARE_GREATER; -} - -sal_Bool operator==(const UniString& rStr1, const UniString& rStr2) -{ - if ( rStr1.mpData == rStr2.mpData ) - return sal_True; - - if ( rStr1.mpData->mnLen != rStr2.mpData->mnLen ) - return sal_False; - - return (ImplStringCompareWithoutZero( rStr1.mpData->maStr, rStr2.mpData->maStr, rStr1.mpData->mnLen ) == 0); -} - -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: */ |