[Libreoffice-commits] .: tools/inc tools/source unusedcode.easy
Caolán McNamara
caolan at kemper.freedesktop.org
Wed Feb 15 03:07:13 PST 2012
tools/inc/tools/string.hxx | 55 ----
tools/source/string/strimp.cxx | 513 ---------------------------------------
tools/source/string/tstring.cxx | 50 ---
tools/source/string/tustring.cxx | 513 +++++++++++++++++++++++++++++++++++++++
unusedcode.easy | 19 -
5 files changed, 526 insertions(+), 624 deletions(-)
New commits:
commit 48649cdfb8671fb49a28b33c1ba1cd71c0999a07
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Feb 15 10:05:30 2012 +0000
lock in those ByteString gains so there's no back-sliding
diff --git a/tools/inc/tools/string.hxx b/tools/inc/tools/string.hxx
index b91170a..c232c07 100644
--- a/tools/inc/tools/string.hxx
+++ b/tools/inc/tools/string.hxx
@@ -148,26 +148,36 @@ private:
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 somethiing to fit
+ 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 somethiing to fit
+ 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& 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( const sal_Char* pCharStr, xub_StrLen nLen );
~ByteString();
operator rtl::OString () const
@@ -178,27 +188,19 @@ public:
ByteString& Assign( const ByteString& rStr );
ByteString& Assign( const rtl::OString& rStr );
ByteString& Assign( const sal_Char* pCharStr );
- ByteString& Assign( const sal_Char* pCharStr, xub_StrLen nLen );
- ByteString& Assign( sal_Char c );
ByteString& operator =( const ByteString& rStr )
{ return Assign( rStr ); }
ByteString& operator =( const rtl::OString& rStr )
{ return Assign( rStr ); }
ByteString& operator =( const sal_Char* pCharStr )
{ return Assign( pCharStr ); }
- ByteString& operator =( const sal_Char c )
- { return Assign( c ); }
ByteString& Append( const ByteString& rStr );
ByteString& Append( const sal_Char* pCharStr );
- ByteString& Append( const sal_Char* pCharStr, xub_StrLen nLen );
- ByteString& Append( char c );
ByteString& operator +=( const ByteString& rStr )
{ return Append( rStr ); }
ByteString& operator +=( const sal_Char* pCharStr )
{ return Append( pCharStr ); }
- ByteString& operator +=( sal_Char c )
- { return Append( c ); }
void SetChar( xub_StrLen nIndex, sal_Char c );
sal_Char GetChar( xub_StrLen nIndex ) const
@@ -207,54 +209,33 @@ public:
xub_StrLen Len() const { return (xub_StrLen)mpData->mnLen; }
ByteString& Insert( const ByteString& rStr, xub_StrLen nIndex = STRING_LEN );
- ByteString& Insert( const sal_Char* pCharStr, xub_StrLen nIndex = STRING_LEN );
- ByteString& Insert( sal_Char c, 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();
- ByteString& ToUpperAscii();
- StringCompare CompareTo( const ByteString& rStr,
- xub_StrLen nLen = STRING_LEN ) const;
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 ByteString& rStr ) const;
sal_Bool Equals( const sal_Char* pCharStr ) const;
- sal_Bool EqualsIgnoreCaseAscii( const ByteString& rStr ) const;
sal_Bool EqualsIgnoreCaseAscii( const sal_Char* pCharStr ) const;
- sal_Bool Equals( const ByteString& rStr,
- xub_StrLen nIndex, xub_StrLen nLen ) const;
- sal_Bool Equals( const sal_Char* pCharStr,
- xub_StrLen nIndex, xub_StrLen nLen ) const;
-
- xub_StrLen Match( const ByteString& rStr ) 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;
- xub_StrLen SearchBackward( sal_Char c, xub_StrLen nIndex = STRING_LEN ) const;
xub_StrLen SearchAndReplace( const ByteString& rStr, const ByteString& rRepStr,
xub_StrLen nIndex = 0 );
xub_StrLen SearchAndReplace( const sal_Char* pCharStr, const ByteString& rRepStr,
xub_StrLen nIndex = 0 );
void SearchAndReplaceAll( sal_Char c, sal_Char cRep );
- void SearchAndReplaceAll( const ByteString& rStr, const ByteString& rRepStr );
- void SearchAndReplaceAll( const sal_Char* pCharStr, const ByteString& rRepStr );
- void SetToken( xub_StrLen nToken, sal_Char cTok, const ByteString& rStr,
- xub_StrLen nIndex = 0 );
- ByteString GetToken( xub_StrLen nToken, sal_Char cTok, xub_StrLen& rIndex ) const;
ByteString GetToken( xub_StrLen nToken, sal_Char cTok = ';' ) const;
const sal_Char* GetBuffer() const { return mpData->maStr; }
- friend sal_Bool operator == ( const ByteString& rStr1, const ByteString& rStr2 )
- { return rStr1.Equals( rStr2 ); }
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 )
@@ -265,14 +246,10 @@ public:
{ 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 (rStr1.CompareTo( rStr2 ) == COMPARE_LESS); }
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& rStr1, const ByteString& rStr2 )
- { return (rStr1.CompareTo( rStr2 ) == COMPARE_GREATER); }
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 )
@@ -296,12 +273,6 @@ inline ByteString ByteString::Copy( xub_StrLen nIndex, xub_StrLen nCount ) const
return ByteString( *this, nIndex, nCount );
}
-inline ByteString ByteString::GetToken( xub_StrLen nToken, sal_Char cTok ) const
-{
- xub_StrLen nTempPos = 0;
- return GetToken( nToken, cTok, nTempPos );
-}
-
// -----------------------------------------------------------------------
// ------------------------
diff --git a/tools/source/string/strimp.cxx b/tools/source/string/strimp.cxx
index 97344b3..1eef75d 100644
--- a/tools/source/string/strimp.cxx
+++ b/tools/source/string/strimp.cxx
@@ -88,37 +88,6 @@ static sal_Int32 ImplStringICompare( const STRCODE* pStr1, const STRCODE* pStr2
return nRet;
}
-// -----------------------------------------------------------------------
-
-static sal_Int32 ImplStringICompareWithoutZero( const STRCODE* pStr1, const STRCODE* pStr2,
- sal_Int32 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));
-
- ++pStr1,
- ++pStr2,
- --nCount;
- }
- while ( nRet == 0 );
-
- return nRet;
-}
-
// =======================================================================
#ifdef DBG_UTIL
@@ -288,43 +257,6 @@ STRING::STRING( const STRCODE* pCharStr )
// -----------------------------------------------------------------------
-STRING::STRING( const STRCODE* pCharStr, xub_StrLen nLen )
-: mpData(NULL)
-{
- DBG_CTOR( STRING, DBGCHECKSTRING );
- DBG_ASSERT( pCharStr, "String::String() - pCharStr is NULL" );
-
- if ( nLen == STRING_LEN )
- nLen = ImplStringLen( pCharStr );
-
-#ifdef DBG_UTIL
- if ( DbgIsAssert() )
- {
- for ( xub_StrLen i = 0; i < nLen; i++ )
- {
- if ( !pCharStr[i] )
- {
- OSL_FAIL( "String::String() : nLen is wrong" );
- }
- }
- }
-#endif
-
- // Ist es kein leerer String
- if ( nLen )
- {
- // Verwaltungsdaten anlegen und String kopieren
- mpData = ImplAllocData( nLen );
- memcpy( mpData->maStr, pCharStr, nLen*sizeof( STRCODE ) );
- }
- else
- {
- STRING_NEW((STRING_TYPE **)&mpData);
- }
-}
-
-// -----------------------------------------------------------------------
-
STRING::~STRING()
{
DBG_DTOR( STRING, DBGCHECKSTRING );
@@ -381,66 +313,6 @@ STRING& STRING::Assign( const STRCODE* pCharStr )
// -----------------------------------------------------------------------
-STRING& STRING::Assign( const STRCODE* pCharStr, xub_StrLen nLen )
-{
- DBG_CHKTHIS( STRING, DBGCHECKSTRING );
- DBG_ASSERT( pCharStr, "String::Assign() - pCharStr is NULL" );
-
- if ( nLen == STRING_LEN )
- nLen = ImplStringLen( pCharStr );
-
-#ifdef DBG_UTIL
- if ( DbgIsAssert() )
- {
- for ( xub_StrLen i = 0; i < nLen; i++ )
- {
- if ( !pCharStr[i] )
- {
- OSL_FAIL( "String::Assign() : nLen is wrong" );
- }
- }
- }
-#endif
-
- 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::Assign( STRCODE c )
-{
- DBG_CHKTHIS( STRING, DBGCHECKSTRING );
- DBG_ASSERT( c, "String::Assign() - c is 0" );
-
- // Verwaltungsdaten anlegen und initialisieren
- STRING_RELEASE((STRING_TYPE *)mpData);
- mpData = ImplAllocData( 1 );
- mpData->maStr[0] = c;
- return *this;
-}
-
-// -----------------------------------------------------------------------
-
STRING& STRING::Append( const STRING& rStr )
{
DBG_CHKTHIS( STRING, DBGCHECKSTRING );
@@ -512,76 +384,6 @@ STRING& STRING::Append( const STRCODE* pCharStr )
// -----------------------------------------------------------------------
-STRING& STRING::Append( const STRCODE* pCharStr, xub_StrLen nCharLen )
-{
- DBG_CHKTHIS( STRING, DBGCHECKSTRING );
- DBG_ASSERT( pCharStr, "String::Append() - pCharStr is NULL" );
-
- if ( nCharLen == STRING_LEN )
- nCharLen = ImplStringLen( pCharStr );
-
-#ifdef DBG_UTIL
- if ( DbgIsAssert() )
- {
- for ( xub_StrLen i = 0; i < nCharLen; i++ )
- {
- if ( !pCharStr[i] )
- {
- OSL_FAIL( "String::Append() : nLen is wrong" );
- }
- }
- }
-#endif
-
- // Ueberlauf abfangen
- sal_Int32 nLen = mpData->mnLen;
- sal_Int32 nCopyLen = ImplGetCopyLen( nLen, nCharLen );
-
- // Ist es kein leerer String
- if ( nCopyLen )
- {
- // Neue Datenstruktur und neuen String erzeugen
- STRINGDATA* pNewData = ImplAllocData( nLen+nCopyLen );
-
- // String kopieren
- memcpy( pNewData->maStr, mpData->maStr, nLen*sizeof( STRCODE ) );
- memcpy( pNewData->maStr+nLen, pCharStr, nCopyLen*sizeof( STRCODE ) );
-
- // Alte Daten loeschen und Neue zuweisen
- STRING_RELEASE((STRING_TYPE *)mpData);
- mpData = pNewData;
- }
-
- return *this;
-}
-
-// -----------------------------------------------------------------------
-
-STRING& STRING::Append( STRCODE c )
-{
- DBG_CHKTHIS( STRING, DBGCHECKSTRING );
-
- // kein 0-Character und maximale Stringlaenge nicht ueberschreiten
- sal_Int32 nLen = mpData->mnLen;
- if ( c && (nLen < STRING_MAXLEN) )
- {
- // Neue Datenstruktur und neuen String erzeugen
- STRINGDATA* pNewData = ImplAllocData( nLen+1 );
-
- // String kopieren
- memcpy( pNewData->maStr, mpData->maStr, nLen*sizeof( STRCODE ) );
- pNewData->maStr[nLen] = c;
-
- // Alte Daten loeschen und Neue zuweisen
- STRING_RELEASE((STRING_TYPE *)mpData);
- mpData = pNewData;
- }
-
- return *this;
-}
-
-// -----------------------------------------------------------------------
-
void STRING::SetChar( xub_StrLen nIndex, STRCODE c )
{
DBG_CHKTHIS( STRING, DBGCHECKSTRING );
@@ -628,36 +430,6 @@ STRING& STRING::Insert( const STRING& rStr, xub_StrLen nIndex )
// -----------------------------------------------------------------------
-STRING& STRING::Insert( STRCODE c, xub_StrLen nIndex )
-{
- DBG_CHKTHIS( STRING, DBGCHECKSTRING );
-
- // Ist es kein 0-Character
- if ( !c || (mpData->mnLen == STRING_MAXLEN) )
- return *this;
-
- // Index groesser als Laenge
- if ( nIndex > mpData->mnLen )
- nIndex = static_cast< xub_StrLen >(mpData->mnLen);
-
- // Neue Laenge ermitteln und neuen String anlegen
- STRINGDATA* pNewData = ImplAllocData( mpData->mnLen+1 );
-
- // String kopieren
- memcpy( pNewData->maStr, mpData->maStr, nIndex*sizeof( STRCODE ) );
- pNewData->maStr[nIndex] = c;
- memcpy( pNewData->maStr+nIndex+1, mpData->maStr+nIndex,
- (mpData->mnLen-nIndex)*sizeof( STRCODE ) );
-
- // Alte Daten loeschen und Neue zuweisen
- STRING_RELEASE((STRING_TYPE *)mpData);
- mpData = pNewData;
-
- return *this;
-}
-
-// -----------------------------------------------------------------------
-
STRING& STRING::Replace( xub_StrLen nIndex, xub_StrLen nCount, const STRING& rStr )
{
DBG_CHKTHIS( STRING, DBGCHECKSTRING );
@@ -782,99 +554,6 @@ STRING& STRING::ToLowerAscii()
// -----------------------------------------------------------------------
-STRING& STRING::ToUpperAscii()
-{
- DBG_CHKTHIS( STRING, DBGCHECKSTRING );
-
- sal_Int32 nIndex = 0;
- sal_Int32 nLen = mpData->mnLen;
- STRCODE* pStr = mpData->maStr;
- while ( nIndex < nLen )
- {
- // Ist das Zeichen zwischen 'a' und 'z' dann umwandeln
- if ( (*pStr >= 97) && (*pStr <= 122) )
- {
- // Daten kopieren, wenn noetig
- pStr = ImplCopyStringData( pStr );
- *pStr -= 32;
- }
-
- ++pStr,
- ++nIndex;
- }
-
- return *this;
-}
-
-// -----------------------------------------------------------------------
-
-StringCompare STRING::CompareTo( const STRING& rStr, xub_StrLen nLen ) const
-{
- DBG_CHKTHIS( STRING, DBGCHECKSTRING );
- DBG_CHKOBJ( &rStr, STRING, DBGCHECKSTRING );
-
- // Auf Gleichheit der Pointer testen
- if ( mpData == rStr.mpData )
- return COMPARE_EQUAL;
-
- // Maximale Laenge ermitteln
- 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);
-
- // String vergleichen
- sal_Int32 nCompare = ImplStringCompareWithoutZero( mpData->maStr, rStr.mpData->maStr, nLen );
-
- // Rueckgabewert anpassen
- if ( nCompare == 0 )
- return COMPARE_EQUAL;
- else if ( nCompare < 0 )
- return COMPARE_LESS;
- else
- return COMPARE_GREATER;
-}
-
-// -----------------------------------------------------------------------
-
-sal_Bool STRING::Equals( const STRING& rStr ) const
-{
- DBG_CHKTHIS( STRING, DBGCHECKSTRING );
- DBG_CHKOBJ( &rStr, STRING, DBGCHECKSTRING );
-
- // Sind die Daten gleich
- if ( mpData == rStr.mpData )
- return sal_True;
-
- // Gleiche Laenge
- if ( mpData->mnLen != rStr.mpData->mnLen )
- return sal_False;
-
- // String vergleichen
- return (ImplStringCompareWithoutZero( mpData->maStr, rStr.mpData->maStr, mpData->mnLen ) == 0);
-}
-
-// -----------------------------------------------------------------------
-
-sal_Bool STRING::EqualsIgnoreCaseAscii( const STRING& rStr ) const
-{
- DBG_CHKTHIS( STRING, DBGCHECKSTRING );
- DBG_CHKOBJ( &rStr, STRING, DBGCHECKSTRING );
-
- // Sind die Daten gleich
- if ( mpData == rStr.mpData )
- return sal_True;
-
- // Gleiche Laenge
- if ( mpData->mnLen != rStr.mpData->mnLen )
- return sal_False;
-
- // String vergleichen
- return (ImplStringICompareWithoutZero( mpData->maStr, rStr.mpData->maStr, mpData->mnLen ) == 0);
-}
-
-// -----------------------------------------------------------------------
-
sal_Bool STRING::EqualsIgnoreCaseAscii( const STRCODE* pCharStr ) const
{
DBG_CHKTHIS( STRING, DBGCHECKSTRING );
@@ -884,69 +563,6 @@ sal_Bool STRING::EqualsIgnoreCaseAscii( const STRCODE* pCharStr ) const
// -----------------------------------------------------------------------
-sal_Bool STRING::Equals( const STRING& rStr, xub_StrLen nIndex, xub_StrLen nLen ) const
-{
- DBG_CHKTHIS( STRING, DBGCHECKSTRING );
- DBG_CHKOBJ( &rStr, STRING, DBGCHECKSTRING );
-
- // Are there enough codes for comparing?
- if ( nIndex > mpData->mnLen )
- return (rStr.mpData->mnLen == 0);
- sal_Int32 nMaxLen = mpData->mnLen-nIndex;
- if ( nMaxLen < nLen )
- {
- if ( rStr.mpData->mnLen != nMaxLen )
- return sal_False;
- nLen = static_cast< xub_StrLen >(nMaxLen);
- }
-
- // String vergleichen
- return (ImplStringCompareWithoutZero( mpData->maStr+nIndex, rStr.mpData->maStr, nLen ) == 0);
-}
-
-// -----------------------------------------------------------------------
-
-sal_Bool STRING::Equals( const STRCODE* pCharStr, xub_StrLen nIndex, xub_StrLen nLen ) const
-{
- DBG_CHKTHIS( STRING, DBGCHECKSTRING );
-
- // Are there enough codes for comparing?
- if ( nIndex > mpData->mnLen )
- return (*pCharStr == 0);
-
- return (ImplStringCompare( mpData->maStr+nIndex, pCharStr, nLen ) == 0);
-}
-
-// -----------------------------------------------------------------------
-
-xub_StrLen STRING::Match( const STRING& rStr ) const
-{
- DBG_CHKTHIS( STRING, DBGCHECKSTRING );
- DBG_CHKOBJ( &rStr, STRING, DBGCHECKSTRING );
-
- // Ist dieser String leer
- if ( !mpData->mnLen )
- return STRING_MATCH;
-
- // Suche bis Stringende nach dem ersten nicht uebereinstimmenden Zeichen
- const STRCODE* pStr1 = mpData->maStr;
- const STRCODE* pStr2 = rStr.mpData->maStr;
- xub_StrLen i = 0;
- while ( i < mpData->mnLen )
- {
- // Stimmt das Zeichen nicht ueberein, dann abbrechen
- if ( *pStr1 != *pStr2 )
- return i;
- ++pStr1,
- ++pStr2,
- ++i;
- }
-
- return STRING_MATCH;
-}
-
-// -----------------------------------------------------------------------
-
xub_StrLen STRING::Search( STRCODE c, xub_StrLen nIndex ) const
{
DBG_CHKTHIS( STRING, DBGCHECKSTRING );
@@ -1058,29 +674,6 @@ xub_StrLen STRING::Search( const STRCODE* pCharStr, xub_StrLen nIndex ) const
// -----------------------------------------------------------------------
-xub_StrLen STRING::SearchBackward( STRCODE c, xub_StrLen nIndex ) const
-{
- DBG_CHKTHIS( STRING, DBGCHECKSTRING );
-
- if ( nIndex > mpData->mnLen )
- nIndex = (xub_StrLen)mpData->mnLen;
-
- const STRCODE* pStr = mpData->maStr;
- pStr += nIndex;
-
- while ( nIndex )
- {
- nIndex--;
- pStr--;
- if ( *pStr == c )
- return nIndex;
- }
-
- return STRING_NOTFOUND;
-}
-
-// -----------------------------------------------------------------------
-
xub_StrLen STRING::SearchAndReplace( const STRING& rStr, const STRING& rRepStr,
xub_StrLen nIndex )
{
@@ -1116,110 +709,4 @@ void STRING::SearchAndReplaceAll( STRCODE c, STRCODE cRep )
}
}
-// -----------------------------------------------------------------------
-
-void STRING::SearchAndReplaceAll( const STRING& rStr, const STRING& rRepStr )
-{
- DBG_CHKTHIS( STRING, DBGCHECKSTRING );
- DBG_CHKOBJ( &rStr, STRING, DBGCHECKSTRING );
- DBG_CHKOBJ( &rRepStr, STRING, DBGCHECKSTRING );
-
- xub_StrLen nSPos = Search( rStr, 0 );
- while ( nSPos != STRING_NOTFOUND )
- {
- Replace( nSPos, rStr.Len(), rRepStr );
- nSPos = nSPos + rRepStr.Len();
- nSPos = Search( rStr, nSPos );
- }
-}
-
-// -----------------------------------------------------------------------
-
-void STRING::SetToken( xub_StrLen nToken, STRCODE cTok, const STRING& rStr,
- xub_StrLen nIndex )
-{
- DBG_CHKTHIS( STRING, DBGCHECKSTRING );
- DBG_CHKOBJ( &rStr, STRING, DBGCHECKSTRING );
-
- const STRCODE* pStr = mpData->maStr;
- xub_StrLen nLen = (xub_StrLen)mpData->mnLen;
- xub_StrLen nTok = 0;
- xub_StrLen nFirstChar = nIndex;
- xub_StrLen i = nFirstChar;
-
- // Bestimme die Token-Position und Laenge
- pStr += i;
- while ( i < nLen )
- {
- // Stimmt das Tokenzeichen ueberein, dann erhoehe TokCount
- if ( *pStr == cTok )
- {
- ++nTok;
-
- if ( nTok == nToken )
- nFirstChar = i+1;
- else
- {
- if ( nTok > nToken )
- break;
- }
- }
-
- ++pStr,
- ++i;
- }
-
- if ( nTok >= nToken )
- Replace( nFirstChar, i-nFirstChar, rStr );
-}
-
-// -----------------------------------------------------------------------
-
-STRING STRING::GetToken( xub_StrLen nToken, STRCODE cTok, xub_StrLen& rIndex ) const
-{
- DBG_CHKTHIS( STRING, DBGCHECKSTRING );
-
- const STRCODE* pStr = mpData->maStr;
- xub_StrLen nLen = (xub_StrLen)mpData->mnLen;
- xub_StrLen nTok = 0;
- xub_StrLen nFirstChar = rIndex;
- xub_StrLen i = nFirstChar;
-
- // Bestimme die Token-Position und Laenge
- pStr += i;
- while ( i < nLen )
- {
- // Stimmt das Tokenzeichen ueberein, dann erhoehe TokCount
- if ( *pStr == cTok )
- {
- ++nTok;
-
- if ( nTok == nToken )
- nFirstChar = i+1;
- else
- {
- if ( nTok > nToken )
- break;
- }
- }
-
- ++pStr,
- ++i;
- }
-
- if ( nTok >= nToken )
- {
- if ( i < nLen )
- rIndex = i+1;
- else
- rIndex = STRING_NOTFOUND;
- return Copy( nFirstChar, i-nFirstChar );
- }
- else
- {
- rIndex = STRING_NOTFOUND;
- return STRING();
- }
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/tools/source/string/tstring.cxx b/tools/source/string/tstring.cxx
index b180ff0..e87316b 100644
--- a/tools/source/string/tstring.cxx
+++ b/tools/source/string/tstring.cxx
@@ -83,21 +83,6 @@ xub_StrLen ImplStringLen( const sal_Unicode* pStr )
#include <strimp.cxx>
#include <strcvt.cxx>
-void STRING::SearchAndReplaceAll( const STRCODE* pCharStr, const STRING& rRepStr )
-{
- DBG_CHKTHIS( STRING, DBGCHECKSTRING );
- DBG_CHKOBJ( &rRepStr, STRING, DBGCHECKSTRING );
-
- xub_StrLen nCharLen = ImplStringLen( pCharStr );
- xub_StrLen nSPos = Search( pCharStr, 0 );
- while ( nSPos != STRING_NOTFOUND )
- {
- Replace( nSPos, nCharLen, rRepStr );
- nSPos = nSPos + rRepStr.Len();
- nSPos = Search( pCharStr, nSPos );
- }
-}
-
xub_StrLen STRING::SearchAndReplace( const STRCODE* pCharStr, const STRING& rRepStr,
xub_StrLen nIndex )
{
@@ -197,39 +182,4 @@ sal_Bool STRING::Equals( const STRCODE* pCharStr ) const
return (ImplStringCompare( mpData->maStr, pCharStr ) == 0);
}
-STRING& STRING::Insert( const STRCODE* pCharStr, xub_StrLen nIndex )
-{
- DBG_CHKTHIS( STRING, DBGCHECKSTRING );
- DBG_ASSERT( pCharStr, "String::Insert() - pCharStr is NULL" );
-
- // Stringlaenge ermitteln
- sal_Int32 nCopyLen = ImplStringLen( pCharStr );
-
- // Ueberlauf abfangen
- nCopyLen = ImplGetCopyLen( mpData->mnLen, nCopyLen );
-
- // Ist der einzufuegende String ein Leerstring
- if ( !nCopyLen )
- return *this;
-
- // Index groesser als Laenge
- if ( nIndex > mpData->mnLen )
- nIndex = static_cast< xub_StrLen >(mpData->mnLen);
-
- // Neue Laenge ermitteln und neuen String anlegen
- STRINGDATA* pNewData = ImplAllocData( mpData->mnLen+nCopyLen );
-
- // String kopieren
- memcpy( pNewData->maStr, mpData->maStr, nIndex*sizeof( STRCODE ) );
- memcpy( pNewData->maStr+nIndex, pCharStr, nCopyLen*sizeof( STRCODE ) );
- memcpy( pNewData->maStr+nIndex+nCopyLen, mpData->maStr+nIndex,
- (mpData->mnLen-nIndex)*sizeof( STRCODE ) );
-
- // Alte Daten loeschen und Neue zuweisen
- STRING_RELEASE((STRING_TYPE *)mpData);
- mpData = pNewData;
-
- return *this;
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/tools/source/string/tustring.cxx b/tools/source/string/tustring.cxx
index f4c98ab..26a4ccf 100644
--- a/tools/source/string/tustring.cxx
+++ b/tools/source/string/tustring.cxx
@@ -390,6 +390,37 @@ STRING STRING::GetQuotedToken( xub_StrLen nToken, const STRING& rQuotedPairs,
// -----------------------------------------------------------------------
+static sal_Int32 ImplStringICompareWithoutZero( const STRCODE* pStr1, const STRCODE* pStr2,
+ sal_Int32 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));
+
+ ++pStr1,
+ ++pStr2,
+ --nCount;
+ }
+ while ( nRet == 0 );
+
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
sal_Bool STRING::EqualsIgnoreCaseAscii( const STRING& rStr, xub_StrLen nIndex, xub_StrLen nLen ) const
{
DBG_CHKTHIS( STRING, DBGCHECKSTRING );
@@ -606,4 +637,486 @@ STRING& STRING::EraseTrailingChars( STRCODE c )
return *this;
}
+// -----------------------------------------------------------------------
+
+STRING& STRING::Insert( STRCODE c, xub_StrLen nIndex )
+{
+ DBG_CHKTHIS( STRING, DBGCHECKSTRING );
+
+ // Ist es kein 0-Character
+ if ( !c || (mpData->mnLen == STRING_MAXLEN) )
+ return *this;
+
+ // Index groesser als Laenge
+ if ( nIndex > mpData->mnLen )
+ nIndex = static_cast< xub_StrLen >(mpData->mnLen);
+
+ // Neue Laenge ermitteln und neuen String anlegen
+ STRINGDATA* pNewData = ImplAllocData( mpData->mnLen+1 );
+
+ // String kopieren
+ memcpy( pNewData->maStr, mpData->maStr, nIndex*sizeof( STRCODE ) );
+ pNewData->maStr[nIndex] = c;
+ memcpy( pNewData->maStr+nIndex+1, mpData->maStr+nIndex,
+ (mpData->mnLen-nIndex)*sizeof( STRCODE ) );
+
+ // Alte Daten loeschen und Neue zuweisen
+ STRING_RELEASE((STRING_TYPE *)mpData);
+ mpData = pNewData;
+
+ return *this;
+}
+
+// -----------------------------------------------------------------------
+
+STRING& STRING::ToUpperAscii()
+{
+ DBG_CHKTHIS( STRING, DBGCHECKSTRING );
+
+ sal_Int32 nIndex = 0;
+ sal_Int32 nLen = mpData->mnLen;
+ STRCODE* pStr = mpData->maStr;
+ while ( nIndex < nLen )
+ {
+ // Ist das Zeichen zwischen 'a' und 'z' dann umwandeln
+ if ( (*pStr >= 97) && (*pStr <= 122) )
+ {
+ // Daten kopieren, wenn noetig
+ pStr = ImplCopyStringData( pStr );
+ *pStr -= 32;
+ }
+
+ ++pStr,
+ ++nIndex;
+ }
+
+ return *this;
+}
+
+// -----------------------------------------------------------------------
+
+StringCompare STRING::CompareTo( const STRING& rStr, xub_StrLen nLen ) const
+{
+ DBG_CHKTHIS( STRING, DBGCHECKSTRING );
+ DBG_CHKOBJ( &rStr, STRING, DBGCHECKSTRING );
+
+ // Auf Gleichheit der Pointer testen
+ if ( mpData == rStr.mpData )
+ return COMPARE_EQUAL;
+
+ // Maximale Laenge ermitteln
+ 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);
+
+ // String vergleichen
+ sal_Int32 nCompare = ImplStringCompareWithoutZero( mpData->maStr, rStr.mpData->maStr, nLen );
+
+ // Rueckgabewert anpassen
+ if ( nCompare == 0 )
+ return COMPARE_EQUAL;
+ else if ( nCompare < 0 )
+ return COMPARE_LESS;
+ else
+ return COMPARE_GREATER;
+}
+
+// -----------------------------------------------------------------------
+
+sal_Bool STRING::Equals( const STRING& rStr ) const
+{
+ DBG_CHKTHIS( STRING, DBGCHECKSTRING );
+ DBG_CHKOBJ( &rStr, STRING, DBGCHECKSTRING );
+
+ // Sind die Daten gleich
+ if ( mpData == rStr.mpData )
+ return sal_True;
+
+ // Gleiche Laenge
+ if ( mpData->mnLen != rStr.mpData->mnLen )
+ return sal_False;
+
+ // String vergleichen
+ return (ImplStringCompareWithoutZero( mpData->maStr, rStr.mpData->maStr, mpData->mnLen ) == 0);
+}
+
+// -----------------------------------------------------------------------
+
+sal_Bool STRING::EqualsIgnoreCaseAscii( const STRING& rStr ) const
+{
+ DBG_CHKTHIS( STRING, DBGCHECKSTRING );
+ DBG_CHKOBJ( &rStr, STRING, DBGCHECKSTRING );
+
+ // Sind die Daten gleich
+ if ( mpData == rStr.mpData )
+ return sal_True;
+
+ // Gleiche Laenge
+ if ( mpData->mnLen != rStr.mpData->mnLen )
+ return sal_False;
+
+ // String vergleichen
+ return (ImplStringICompareWithoutZero( mpData->maStr, rStr.mpData->maStr, mpData->mnLen ) == 0);
+}
+
+// -----------------------------------------------------------------------
+
+sal_Bool STRING::Equals( const STRING& rStr, xub_StrLen nIndex, xub_StrLen nLen ) const
+{
+ DBG_CHKTHIS( STRING, DBGCHECKSTRING );
+ DBG_CHKOBJ( &rStr, STRING, DBGCHECKSTRING );
+
+ // Are there enough codes for comparing?
+ if ( nIndex > mpData->mnLen )
+ return (rStr.mpData->mnLen == 0);
+ sal_Int32 nMaxLen = mpData->mnLen-nIndex;
+ if ( nMaxLen < nLen )
+ {
+ if ( rStr.mpData->mnLen != nMaxLen )
+ return sal_False;
+ nLen = static_cast< xub_StrLen >(nMaxLen);
+ }
+
+ // String vergleichen
+ return (ImplStringCompareWithoutZero( mpData->maStr+nIndex, rStr.mpData->maStr, nLen ) == 0);
+}
+
+// -----------------------------------------------------------------------
+
+sal_Bool STRING::Equals( const STRCODE* pCharStr, xub_StrLen nIndex, xub_StrLen nLen ) const
+{
+ DBG_CHKTHIS( STRING, DBGCHECKSTRING );
+
+ // Are there enough codes for comparing?
+ if ( nIndex > mpData->mnLen )
+ return (*pCharStr == 0);
+
+ return (ImplStringCompare( mpData->maStr+nIndex, pCharStr, nLen ) == 0);
+}
+
+// -----------------------------------------------------------------------
+
+xub_StrLen STRING::Match( const STRING& rStr ) const
+{
+ DBG_CHKTHIS( STRING, DBGCHECKSTRING );
+ DBG_CHKOBJ( &rStr, STRING, DBGCHECKSTRING );
+
+ // Ist dieser String leer
+ if ( !mpData->mnLen )
+ return STRING_MATCH;
+
+ // Suche bis Stringende nach dem ersten nicht uebereinstimmenden Zeichen
+ const STRCODE* pStr1 = mpData->maStr;
+ const STRCODE* pStr2 = rStr.mpData->maStr;
+ xub_StrLen i = 0;
+ while ( i < mpData->mnLen )
+ {
+ // Stimmt das Zeichen nicht ueberein, dann abbrechen
+ if ( *pStr1 != *pStr2 )
+ return i;
+ ++pStr1,
+ ++pStr2,
+ ++i;
+ }
+
+ return STRING_MATCH;
+}
+
+// -----------------------------------------------------------------------
+
+xub_StrLen STRING::SearchBackward( STRCODE c, xub_StrLen nIndex ) const
+{
+ DBG_CHKTHIS( STRING, DBGCHECKSTRING );
+
+ if ( nIndex > mpData->mnLen )
+ nIndex = (xub_StrLen)mpData->mnLen;
+
+ const STRCODE* pStr = mpData->maStr;
+ pStr += nIndex;
+
+ while ( nIndex )
+ {
+ nIndex--;
+ pStr--;
+ if ( *pStr == c )
+ return nIndex;
+ }
+
+ return STRING_NOTFOUND;
+}
+
+// -----------------------------------------------------------------------
+
+void STRING::SearchAndReplaceAll( const STRING& rStr, const STRING& rRepStr )
+{
+ DBG_CHKTHIS( STRING, DBGCHECKSTRING );
+ DBG_CHKOBJ( &rStr, STRING, DBGCHECKSTRING );
+ DBG_CHKOBJ( &rRepStr, STRING, DBGCHECKSTRING );
+
+ xub_StrLen nSPos = Search( rStr, 0 );
+ while ( nSPos != STRING_NOTFOUND )
+ {
+ Replace( nSPos, rStr.Len(), rRepStr );
+ nSPos = nSPos + rRepStr.Len();
+ nSPos = Search( rStr, nSPos );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void STRING::SetToken( xub_StrLen nToken, STRCODE cTok, const STRING& rStr,
+ xub_StrLen nIndex )
+{
+ DBG_CHKTHIS( STRING, DBGCHECKSTRING );
+ DBG_CHKOBJ( &rStr, STRING, DBGCHECKSTRING );
+
+ const STRCODE* pStr = mpData->maStr;
+ xub_StrLen nLen = (xub_StrLen)mpData->mnLen;
+ xub_StrLen nTok = 0;
+ xub_StrLen nFirstChar = nIndex;
+ xub_StrLen i = nFirstChar;
+
+ // Bestimme die Token-Position und Laenge
+ pStr += i;
+ while ( i < nLen )
+ {
+ // Stimmt das Tokenzeichen ueberein, dann erhoehe TokCount
+ if ( *pStr == cTok )
+ {
+ ++nTok;
+
+ if ( nTok == nToken )
+ nFirstChar = i+1;
+ else
+ {
+ if ( nTok > nToken )
+ break;
+ }
+ }
+
+ ++pStr,
+ ++i;
+ }
+
+ if ( nTok >= nToken )
+ Replace( nFirstChar, i-nFirstChar, rStr );
+}
+
+// -----------------------------------------------------------------------
+
+STRING STRING::GetToken( xub_StrLen nToken, STRCODE cTok, xub_StrLen& rIndex ) const
+{
+ DBG_CHKTHIS( STRING, DBGCHECKSTRING );
+
+ const STRCODE* pStr = mpData->maStr;
+ xub_StrLen nLen = (xub_StrLen)mpData->mnLen;
+ xub_StrLen nTok = 0;
+ xub_StrLen nFirstChar = rIndex;
+ xub_StrLen i = nFirstChar;
+
+ // Bestimme die Token-Position und Laenge
+ pStr += i;
+ while ( i < nLen )
+ {
+ // Stimmt das Tokenzeichen ueberein, dann erhoehe TokCount
+ if ( *pStr == cTok )
+ {
+ ++nTok;
+
+ if ( nTok == nToken )
+ nFirstChar = i+1;
+ else
+ {
+ if ( nTok > nToken )
+ break;
+ }
+ }
+
+ ++pStr,
+ ++i;
+ }
+
+ if ( nTok >= nToken )
+ {
+ if ( i < nLen )
+ rIndex = i+1;
+ else
+ rIndex = STRING_NOTFOUND;
+ return Copy( nFirstChar, i-nFirstChar );
+ }
+ else
+ {
+ rIndex = STRING_NOTFOUND;
+ return STRING();
+ }
+}
+
+// -----------------------------------------------------------------------
+
+STRING::STRING( const STRCODE* pCharStr, xub_StrLen nLen )
+: mpData(NULL)
+{
+ DBG_CTOR( STRING, DBGCHECKSTRING );
+ DBG_ASSERT( pCharStr, "String::String() - pCharStr is NULL" );
+
+ if ( nLen == STRING_LEN )
+ nLen = ImplStringLen( pCharStr );
+
+#ifdef DBG_UTIL
+ if ( DbgIsAssert() )
+ {
+ for ( xub_StrLen i = 0; i < nLen; i++ )
+ {
+ if ( !pCharStr[i] )
+ {
+ OSL_FAIL( "String::String() : nLen is wrong" );
+ }
+ }
+ }
+#endif
+
+ // Ist es kein leerer String
+ if ( nLen )
+ {
+ // Verwaltungsdaten anlegen und String kopieren
+ mpData = ImplAllocData( nLen );
+ memcpy( mpData->maStr, pCharStr, nLen*sizeof( STRCODE ) );
+ }
+ else
+ {
+ STRING_NEW((STRING_TYPE **)&mpData);
+ }
+}
+
+// -----------------------------------------------------------------------
+
+STRING& STRING::Append( const STRCODE* pCharStr, xub_StrLen nCharLen )
+{
+ DBG_CHKTHIS( STRING, DBGCHECKSTRING );
+ DBG_ASSERT( pCharStr, "String::Append() - pCharStr is NULL" );
+
+ if ( nCharLen == STRING_LEN )
+ nCharLen = ImplStringLen( pCharStr );
+
+#ifdef DBG_UTIL
+ if ( DbgIsAssert() )
+ {
+ for ( xub_StrLen i = 0; i < nCharLen; i++ )
+ {
+ if ( !pCharStr[i] )
+ {
+ OSL_FAIL( "String::Append() : nLen is wrong" );
+ }
+ }
+ }
+#endif
+
+ // Ueberlauf abfangen
+ sal_Int32 nLen = mpData->mnLen;
+ sal_Int32 nCopyLen = ImplGetCopyLen( nLen, nCharLen );
+
+ // Ist es kein leerer String
+ if ( nCopyLen )
+ {
+ // Neue Datenstruktur und neuen String erzeugen
+ STRINGDATA* pNewData = ImplAllocData( nLen+nCopyLen );
+
+ // String kopieren
+ memcpy( pNewData->maStr, mpData->maStr, nLen*sizeof( STRCODE ) );
+ memcpy( pNewData->maStr+nLen, pCharStr, nCopyLen*sizeof( STRCODE ) );
+
+ // Alte Daten loeschen und Neue zuweisen
+ STRING_RELEASE((STRING_TYPE *)mpData);
+ mpData = pNewData;
+ }
+
+ return *this;
+}
+
+// -----------------------------------------------------------------------
+
+STRING& STRING::Append( STRCODE c )
+{
+ DBG_CHKTHIS( STRING, DBGCHECKSTRING );
+
+ // kein 0-Character und maximale Stringlaenge nicht ueberschreiten
+ sal_Int32 nLen = mpData->mnLen;
+ if ( c && (nLen < STRING_MAXLEN) )
+ {
+ // Neue Datenstruktur und neuen String erzeugen
+ STRINGDATA* pNewData = ImplAllocData( nLen+1 );
+
+ // String kopieren
+ memcpy( pNewData->maStr, mpData->maStr, nLen*sizeof( STRCODE ) );
+ pNewData->maStr[nLen] = c;
+
+ // Alte Daten loeschen und Neue zuweisen
+ STRING_RELEASE((STRING_TYPE *)mpData);
+ mpData = pNewData;
+ }
+
+ return *this;
+}
+
+// -----------------------------------------------------------------------
+
+STRING& STRING::Assign( const STRCODE* pCharStr, xub_StrLen nLen )
+{
+ DBG_CHKTHIS( STRING, DBGCHECKSTRING );
+ DBG_ASSERT( pCharStr, "String::Assign() - pCharStr is NULL" );
+
+ if ( nLen == STRING_LEN )
+ nLen = ImplStringLen( pCharStr );
+
+#ifdef DBG_UTIL
+ if ( DbgIsAssert() )
+ {
+ for ( xub_StrLen i = 0; i < nLen; i++ )
+ {
+ if ( !pCharStr[i] )
+ {
+ OSL_FAIL( "String::Assign() : nLen is wrong" );
+ }
+ }
+ }
+#endif
+
+ 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::Assign( STRCODE c )
+{
+ DBG_CHKTHIS( STRING, DBGCHECKSTRING );
+ DBG_ASSERT( c, "String::Assign() - c is 0" );
+
+ // Verwaltungsdaten anlegen und initialisieren
+ STRING_RELEASE((STRING_TYPE *)mpData);
+ mpData = ImplAllocData( 1 );
+ mpData->maStr[0] = c;
+ return *this;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unusedcode.easy b/unusedcode.easy
index 95f65eb..af2cff9 100755
--- a/unusedcode.easy
+++ b/unusedcode.easy
@@ -1,22 +1,3 @@
-ByteString::Append(char const*, unsigned short)
-ByteString::Append(char)
-ByteString::Assign(char const*, unsigned short)
-ByteString::Assign(char)
-ByteString::ByteString(char const*, unsigned short)
-ByteString::CompareTo(ByteString const&, unsigned short) const
-ByteString::Equals(ByteString const&) const
-ByteString::Equals(ByteString const&, unsigned short, unsigned short) const
-ByteString::Equals(char const*, unsigned short, unsigned short) const
-ByteString::EqualsIgnoreCaseAscii(ByteString const&) const
-ByteString::GetToken(unsigned short, char, unsigned short&) const
-ByteString::Insert(char const*, unsigned short)
-ByteString::Insert(char, unsigned short)
-ByteString::Match(ByteString const&) const
-ByteString::SearchAndReplaceAll(ByteString const&, ByteString const&)
-ByteString::SearchAndReplaceAll(char const*, ByteString const&)
-ByteString::SearchBackward(char, unsigned short) const
-ByteString::SetToken(unsigned short, char, ByteString const&, unsigned short)
-ByteString::ToUpperAscii()
CertificateExtension_XmlSecImpl::setCertExtn(com::sun::star::uno::Sequence<signed char>, com::sun::star::uno::Sequence<signed char>, unsigned char)
CharPosArray::Insert(CharPosArray const*, unsigned short, unsigned short, unsigned short)
CharPosArray::Replace(int const&, unsigned short)
More information about the Libreoffice-commits
mailing list