Kaydet (Commit) fa77c78a authored tarafından Jan Holesovsky's avatar Jan Holesovsky

callcatcher: Remove unused ByteArr class, and DECL_1BYTEARRAY define.

üst 099c219c
......@@ -390,71 +390,6 @@ public:\
void Clear() { Remove( 0, Count() ); }\
};
class ByteArr
{
private:
char* pData;
sal_uInt16 nUsed;
sal_uInt8 nGrow;
sal_uInt8 nUnused;
public:
ByteArr( sal_uInt8 nInitSize = 0, sal_uInt8 nGrowSize = 8 );
ByteArr( const ByteArr& rOrig );
~ByteArr();
ByteArr& operator= ( const ByteArr& rOrig );
char GetObject( sal_uInt16 nPos ) const { return operator[](nPos); }
char& GetObject( sal_uInt16 nPos ) { return operator[](nPos); }
void Insert( sal_uInt16 nPos, char rElem );
void Append( char rElem );
sal_Bool Remove( char rElem );
sal_uInt16 Remove( sal_uInt16 nPos, sal_uInt16 nLen );
sal_uInt16 Count() const { return nUsed; }
char* operator*();
char operator[]( sal_uInt16 nPos ) const;
char& operator[]( sal_uInt16 nPos );
sal_Bool Contains( const char rItem ) const;
void Clear() { Remove( 0, Count() ); }
};
inline char* ByteArr::operator*()
{
return ( nUsed==0 ? 0 : pData );
}
#define DECL_1BYTEARRAY(ARR, T, nI, nG)\
class ARR: public ByteArr\
{\
public:\
ARR( sal_uInt8 nIni=nI, sal_uInt8 nGrow=nG ):\
ByteArr(nIni,nGrow) \
{}\
ARR( const ARR& rOrig ):\
ByteArr(rOrig) \
{}\
T GetObject( sal_uInt16 nPos ) const { return operator[](nPos); } \
T& GetObject( sal_uInt16 nPos ) { return operator[](nPos); } \
void Insert( sal_uInt16 nPos, T aElement ) {\
ByteArr::Insert(nPos,(char)aElement);\
}\
void Append( T aElement ) {\
ByteArr::Append((char)aElement);\
}\
void Remove( T aElement ) {\
ByteArr::Remove((char)aElement);\
}\
void Remove( sal_uInt16 nPos, sal_uInt16 nLen = 1 ) {\
ByteArr::Remove( nPos, nLen ); \
}\
T* operator *() {\
return (T*) ByteArr::operator*();\
}\
T operator[]( sal_uInt16 nPos ) const { \
return (T) ByteArr::operator[](nPos); } \
T& operator[]( sal_uInt16 nPos ) { \
return (T&) ByteArr::operator[](nPos); } \
void Clear() { Remove( 0, Count() ); }\
};
class WordArr
{
private:
......
......@@ -267,238 +267,6 @@ void SfxPtrArr::Insert( sal_uInt16 nPos, void* rElem )
nUnused -= 1;
}
// class ByteArr ---------------------------------------------------------
ByteArr::ByteArr( sal_uInt8 nInitSize, sal_uInt8 nGrowSize ):
nUsed( 0 ),
nGrow( nGrowSize ? nGrowSize : 1 ),
nUnused( nInitSize )
{
DBG_MEMTEST();
sal_uInt16 nMSCBug = nInitSize;
if ( nInitSize > 0 )
pData = new char[nMSCBug];
else
pData = 0;
}
// -----------------------------------------------------------------------
ByteArr::ByteArr( const ByteArr& rOrig )
{
DBG_MEMTEST();
nUsed = rOrig.nUsed;
nGrow = rOrig.nGrow;
nUnused = rOrig.nUnused;
if ( rOrig.pData != 0 )
{
pData = new char[nUsed+nUnused];
memcpy( pData, rOrig.pData, nUsed*sizeof(char) );
}
else
pData = 0;
}
// -----------------------------------------------------------------------
ByteArr::~ByteArr()
{
DBG_MEMTEST();
delete [] pData;
}
// -----------------------------------------------------------------------
ByteArr& ByteArr::operator=( const ByteArr& rOrig )
{
DBG_MEMTEST();
delete [] pData;
nUsed = rOrig.nUsed;
nGrow = rOrig.nGrow;
nUnused = rOrig.nUnused;
if ( rOrig.pData != 0 )
{
pData = new char[nUsed+nUnused];
memcpy( pData, rOrig.pData, nUsed*sizeof(char) );
}
else
pData = 0;
return *this;
}
// -----------------------------------------------------------------------
void ByteArr::Append( char aElem )
{
DBG_MEMTEST();
// Does the Array have o be copied?
if ( nUnused == 0 )
{
sal_uInt16 nNewSize = (nUsed == 1) ? (nGrow==1 ? 2 : nGrow) : nUsed+nGrow;
char* pNewData = new char[nNewSize];
if ( pData )
{
DBG_ASSERT( nUsed <= nNewSize, "" );
memmove( pNewData, pData, sizeof(char)*nUsed );
delete [] pData;
}
nUnused = sal::static_int_cast< sal_uInt8 >(nNewSize-nUsed);
pData = pNewData;
}
// now write at the back in the open space
pData[nUsed] = aElem;
++nUsed;
--nUnused;
}
// -----------------------------------------------------------------------
sal_uInt16 ByteArr::Remove( sal_uInt16 nPos, sal_uInt16 nLen )
{
DBG_MEMTEST();
// Adjust nLen, thus to avoid deleting beyond the end
nLen = Min( (sal_uInt16)(nUsed-nPos), nLen );
// simple problems require simple solutions!
if ( nLen == 0 )
return 0;
// Maybe no one will remain
if ( (nUsed-nLen) == 0 )
{
delete [] pData;
pData = 0;
nUsed = 0;
nUnused = 0;
return nLen;
}
// Determine whether the array has physically shrunk...
if ( (nUnused+nLen) >= nGrow )
{
// reduce (rounded up) to the next Grow-border
sal_uInt16 nNewUsed = nUsed-nLen;
sal_uInt16 nNewSize = ((nNewUsed+nGrow-1)/nGrow) * nGrow;
DBG_ASSERT( nNewUsed <= nNewSize && nNewUsed+nGrow > nNewSize,
"shrink size computation failed" );
char* pNewData = new char[nNewSize];
if ( nPos > 0 )
{
DBG_ASSERT( nPos <= nNewSize, "" );
memmove( pNewData, pData, sizeof(char)*nPos );
}
if ( nNewUsed != nPos )
memmove( pNewData+nPos, pData+nPos+nLen,
sizeof(char)*(nNewUsed-nPos) );
delete [] pData;
pData = pNewData;
nUsed = nNewUsed;
nUnused = sal::static_int_cast< sal_uInt8 >(nNewSize - nNewUsed);
return nLen;
}
// in all other cases, only push together
if ( nUsed-nPos-nLen > 0 )
memmove( pData+nPos, pData+nPos+nLen, (nUsed-nPos-nLen)*sizeof(char) );
nUsed = nUsed - nLen;
nUnused = sal::static_int_cast< sal_uInt8 >(nUnused + nLen);
return nLen;
}
// -----------------------------------------------------------------------
sal_Bool ByteArr::Remove( char aElem )
{
DBG_MEMTEST();
// simple tasks ...
if ( nUsed == 0 )
return sal_False;
// backwards, since most of the last is first removed
char *pIter = pData + nUsed - 1;
for ( sal_uInt16 n = 0; n < nUsed; ++n, --pIter )
if ( *pIter == aElem )
{
Remove(nUsed-n-1, 1);
return sal_True;
}
return sal_False;
}
// -----------------------------------------------------------------------
sal_Bool ByteArr::Contains( const char rItem ) const
{
DBG_MEMTEST();
if ( !nUsed )
return sal_False;
for ( sal_uInt16 n = 0; n < nUsed; ++n )
{
char p = GetObject(n);
if ( p == rItem )
return sal_True;
}
return sal_False;
}
// -----------------------------------------------------------------------
void ByteArr::Insert( sal_uInt16 nPos, char rElem )
{
DBG_MEMTEST();
// Does the Array need to be copied?
if ( nUnused == 0 )
{
// increase (rounded up) to the next Grow-border
sal_uInt16 nNewSize = nUsed+nGrow;
char* pNewData = new char[nNewSize];
if ( pData )
{
DBG_ASSERT( nUsed < nNewSize, "" );
memmove( pNewData, pData, sizeof(char)*nUsed );
delete [] pData;
}
nUnused = sal::static_int_cast< sal_uInt8 >(nNewSize-nUsed);
pData = pNewData;
}
// Now move the rear part
if ( nPos < nUsed )
memmove( pData+nPos+1, pData+nPos, (nUsed-nPos)*sizeof(char) );
// now write at the back in the open space
memmove( pData+nPos, &rElem, sizeof(char) );
nUsed += 1;
nUnused -= 1;
}
// -----------------------------------------------------------------------
char ByteArr::operator[]( sal_uInt16 nPos ) const
{
DBG_MEMTEST();
DBG_ASSERT( nPos < nUsed, "" );
return *(pData+nPos);
}
// -----------------------------------------------------------------------
char& ByteArr::operator [] (sal_uInt16 nPos)
{
DBG_MEMTEST();
DBG_ASSERT( nPos < nUsed, "" );
return *(pData+nPos);
}
// class WordArr ---------------------------------------------------------
WordArr::WordArr( sal_uInt8 nInitSize, sal_uInt8 nGrowSize ):
......
......@@ -14,12 +14,6 @@ BitmapPalette::IsGreyPalette() const
BreakPointList::clear()
BreakPointList::push_back(BreakPoint*)
BufferNode::childAt(int) const
ByteArr::Append(char)
ByteArr::ByteArr(unsigned char, unsigned char)
ByteArr::Contains(char) const
ByteArr::Insert(unsigned short, char)
ByteArr::Remove(char)
ByteArr::~ByteArr()
CAT::Inverse() const
CAT::makeChromaticAdaptationTag() const
CIccCmm::FromInternalEncoding(icColorSpaceSignature, unsigned char*, float const*)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment