diff options
Diffstat (limited to 'tools/source')
-rw-r--r-- | tools/source/string/strimp.cxx | 86 | ||||
-rw-r--r-- | tools/source/string/tstring.cxx | 13 | ||||
-rw-r--r-- | tools/source/string/tustring.cxx | 86 |
3 files changed, 86 insertions, 99 deletions
diff --git a/tools/source/string/strimp.cxx b/tools/source/string/strimp.cxx index 1eef75d8b86d..dd00878a071d 100644 --- a/tools/source/string/strimp.cxx +++ b/tools/source/string/strimp.cxx @@ -60,34 +60,6 @@ static sal_Int32 ImplStringCompareWithoutZero( const STRCODE* pStr1, const STRCO return nRet; } -// ----------------------------------------------------------------------- - -static sal_Int32 ImplStringICompare( const STRCODE* pStr1, const STRCODE* pStr2 ) -{ - sal_Int32 nRet; - STRCODE c1; - STRCODE c2; - do - { - // 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; - } - while ( c2 ); - - return nRet; -} - // ======================================================================= #ifdef DBG_UTIL @@ -280,39 +252,6 @@ STRING& STRING::Assign( const STRING& rStr ) // ----------------------------------------------------------------------- -STRING& STRING::Assign( const STRCODE* pCharStr ) -{ - DBG_CHKTHIS( STRING, DBGCHECKSTRING ); - DBG_ASSERT( pCharStr, "String::Assign() - pCharStr is NULL" ); - - // Stringlaenge ermitteln - xub_StrLen nLen = ImplStringLen( pCharStr ); - - if ( !nLen ) - { - STRING_NEW((STRING_TYPE **)&mpData); - } - else - { - // Wenn String genauso lang ist, wie der String, dann direkt kopieren - if ( (nLen == mpData->mnLen) && (mpData->mnRefCount == 1) ) - memcpy( mpData->maStr, pCharStr, nLen*sizeof( STRCODE ) ); - else - { - // Alte Daten loeschen - STRING_RELEASE((STRING_TYPE *)mpData); - - // Daten initialisieren und String kopieren - mpData = ImplAllocData( nLen ); - memcpy( mpData->maStr, pCharStr, nLen*sizeof( STRCODE ) ); - } - } - - return *this; -} - -// ----------------------------------------------------------------------- - STRING& STRING::Append( const STRING& rStr ) { DBG_CHKTHIS( STRING, DBGCHECKSTRING ); @@ -554,15 +493,6 @@ STRING& STRING::ToLowerAscii() // ----------------------------------------------------------------------- -sal_Bool STRING::EqualsIgnoreCaseAscii( const STRCODE* pCharStr ) const -{ - DBG_CHKTHIS( STRING, DBGCHECKSTRING ); - - return (ImplStringICompare( mpData->maStr, pCharStr ) == 0); -} - -// ----------------------------------------------------------------------- - xub_StrLen STRING::Search( STRCODE c, xub_StrLen nIndex ) const { DBG_CHKTHIS( STRING, DBGCHECKSTRING ); @@ -674,22 +604,6 @@ xub_StrLen STRING::Search( const STRCODE* pCharStr, xub_StrLen nIndex ) const // ----------------------------------------------------------------------- -xub_StrLen STRING::SearchAndReplace( const STRING& rStr, const STRING& rRepStr, - xub_StrLen nIndex ) -{ - DBG_CHKTHIS( STRING, DBGCHECKSTRING ); - DBG_CHKOBJ( &rStr, STRING, DBGCHECKSTRING ); - DBG_CHKOBJ( &rRepStr, STRING, DBGCHECKSTRING ); - - xub_StrLen nSPos = Search( rStr, nIndex ); - if ( nSPos != STRING_NOTFOUND ) - Replace( nSPos, rStr.Len(), rRepStr ); - - return nSPos; -} - -// ----------------------------------------------------------------------- - void STRING::SearchAndReplaceAll( STRCODE c, STRCODE cRep ) { DBG_CHKTHIS( STRING, DBGCHECKSTRING ); diff --git a/tools/source/string/tstring.cxx b/tools/source/string/tstring.cxx index e87316be2ca3..97bad851b5e3 100644 --- a/tools/source/string/tstring.cxx +++ b/tools/source/string/tstring.cxx @@ -83,19 +83,6 @@ xub_StrLen ImplStringLen( const sal_Unicode* pStr ) #include <strimp.cxx> #include <strcvt.cxx> -xub_StrLen STRING::SearchAndReplace( const STRCODE* pCharStr, const STRING& rRepStr, - xub_StrLen nIndex ) -{ - DBG_CHKTHIS( STRING, DBGCHECKSTRING ); - DBG_CHKOBJ( &rRepStr, STRING, DBGCHECKSTRING ); - - xub_StrLen nSPos = Search( pCharStr, nIndex ); - if ( nSPos != STRING_NOTFOUND ) - Replace( nSPos, ImplStringLen( pCharStr ), rRepStr ); - - return nSPos; -} - static sal_Int32 ImplStringICompare( const STRCODE* pStr1, const STRCODE* pStr2, xub_StrLen nCount ) { diff --git a/tools/source/string/tustring.cxx b/tools/source/string/tustring.cxx index 26a4ccf1bde4..033498d5719c 100644 --- a/tools/source/string/tustring.cxx +++ b/tools/source/string/tustring.cxx @@ -1119,4 +1119,90 @@ STRING& STRING::Assign( STRCODE c ) return *this; } +// ----------------------------------------------------------------------- + +xub_StrLen STRING::SearchAndReplace( const STRING& rStr, const STRING& rRepStr, + xub_StrLen nIndex ) +{ + DBG_CHKTHIS( STRING, DBGCHECKSTRING ); + DBG_CHKOBJ( &rStr, STRING, DBGCHECKSTRING ); + DBG_CHKOBJ( &rRepStr, STRING, DBGCHECKSTRING ); + + xub_StrLen nSPos = Search( rStr, nIndex ); + if ( nSPos != STRING_NOTFOUND ) + Replace( nSPos, rStr.Len(), rRepStr ); + + return nSPos; +} + +// ----------------------------------------------------------------------- + +static sal_Int32 ImplStringICompare( const STRCODE* pStr1, const STRCODE* pStr2 ) +{ + sal_Int32 nRet; + STRCODE c1; + STRCODE c2; + do + { + // 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; + } + while ( c2 ); + + return nRet; +} + +// ----------------------------------------------------------------------- + +sal_Bool STRING::EqualsIgnoreCaseAscii( const STRCODE* pCharStr ) const +{ + DBG_CHKTHIS( STRING, DBGCHECKSTRING ); + + return (ImplStringICompare( mpData->maStr, pCharStr ) == 0); +} + +// ----------------------------------------------------------------------- + +STRING& STRING::Assign( const STRCODE* pCharStr ) +{ + DBG_CHKTHIS( STRING, DBGCHECKSTRING ); + DBG_ASSERT( pCharStr, "String::Assign() - pCharStr is NULL" ); + + // Stringlaenge ermitteln + xub_StrLen nLen = ImplStringLen( pCharStr ); + + if ( !nLen ) + { + STRING_NEW((STRING_TYPE **)&mpData); + } + else + { + // Wenn String genauso lang ist, wie der String, dann direkt kopieren + if ( (nLen == mpData->mnLen) && (mpData->mnRefCount == 1) ) + memcpy( mpData->maStr, pCharStr, nLen*sizeof( STRCODE ) ); + else + { + // Alte Daten loeschen + STRING_RELEASE((STRING_TYPE *)mpData); + + // Daten initialisieren und String kopieren + mpData = ImplAllocData( nLen ); + memcpy( mpData->maStr, pCharStr, nLen*sizeof( STRCODE ) ); + } + } + + return *this; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |