summaryrefslogtreecommitdiffstats
path: root/tools/source/string/tustring.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-02-23 15:57:11 +0000
committerCaolán McNamara <caolanm@redhat.com>2012-02-23 15:58:52 +0000
commit67f67509ff20c0d5b6e9f3557fb1e427655601ee (patch)
treecfc6a68c839e0725e2717e8a7821a24df8f2bc1c /tools/source/string/tustring.cxx
parenttypo (diff)
downloadcore-67f67509ff20c0d5b6e9f3557fb1e427655601ee.tar.gz
core-67f67509ff20c0d5b6e9f3557fb1e427655601ee.zip
lock in ByteString gains
Diffstat (limited to 'tools/source/string/tustring.cxx')
-rw-r--r--tools/source/string/tustring.cxx86
1 files changed, 86 insertions, 0 deletions
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: */