diff options
author | Michael Stahl <mstahl@redhat.com> | 2012-04-18 16:23:24 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-04-18 16:50:55 +0200 |
commit | 319d686449ecf259763137d98e7ac2ce16701a28 (patch) | |
tree | 26e8de4ba797a539c8187f219208b23ceed0bc8c | |
parent | partially revert 271e19336e594195ac6e40dd01ba62d2592f24e8 (diff) | |
download | binfilter-319d686449ecf259763137d98e7ac2ce16701a28.tar.gz binfilter-319d686449ecf259763137d98e7ac2ce16701a28.zip |
move tools/table.hxx to binfilter
22 files changed, 527 insertions, 20 deletions
diff --git a/binfilter/bf_starmath/source/starmath_register.cxx b/binfilter/bf_starmath/source/starmath_register.cxx index d2461ed51..1f32129b2 100644 --- a/binfilter/bf_starmath/source/starmath_register.cxx +++ b/binfilter/bf_starmath/source/starmath_register.cxx @@ -35,8 +35,6 @@ #include <cppuhelper/factory.hxx> -#include <tools/table.hxx> - namespace binfilter { using namespace ::rtl; diff --git a/binfilter/bf_svtools/source/filter.vcl/wmf/winmtf.hxx b/binfilter/bf_svtools/source/filter.vcl/wmf/winmtf.hxx index 92e47a0d0..f10937582 100644 --- a/binfilter/bf_svtools/source/filter.vcl/wmf/winmtf.hxx +++ b/binfilter/bf_svtools/source/filter.vcl/wmf/winmtf.hxx @@ -40,7 +40,6 @@ #include <sot/object.hxx> #include <boost/shared_ptr.hpp> #include <tools/debug.hxx> -#include <tools/table.hxx> #include <vcl/graph.hxx> #include <vcl/virdev.hxx> #include <tools/poly.hxx> diff --git a/binfilter/bf_svtools/source/items/svt_macitem.cxx b/binfilter/bf_svtools/source/items/svt_macitem.cxx index 3b2a7f67b..82442783d 100644 --- a/binfilter/bf_svtools/source/items/svt_macitem.cxx +++ b/binfilter/bf_svtools/source/items/svt_macitem.cxx @@ -27,7 +27,6 @@ ************************************************************************/ #include <tools/stream.hxx> -#include <tools/table.hxx> #include <bf_svtools/macitem.hxx> diff --git a/binfilter/bf_svtools/source/memtools/makefile.mk b/binfilter/bf_svtools/source/memtools/makefile.mk index 24aaa1070..112b16b40 100644 --- a/binfilter/bf_svtools/source/memtools/makefile.mk +++ b/binfilter/bf_svtools/source/memtools/makefile.mk @@ -40,6 +40,7 @@ INC+= -I$(PRJ)$/inc$/bf_svtools SLOFILES=\ $(SLO)$/svt_svarray.obj \ $(SLO)$/tl_contnr.obj \ + $(SLO)$/tl_table.obj \ $(SLO)$/tl_unqidx.obj # --- Targets ------------------------------------------------------- diff --git a/binfilter/bf_svtools/source/memtools/tl_table.cxx b/binfilter/bf_svtools/source/memtools/tl_table.cxx new file mode 100644 index 000000000..2b9d27f7f --- /dev/null +++ b/binfilter/bf_svtools/source/memtools/tl_table.cxx @@ -0,0 +1,363 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#define _TOOLS_TABLE_CXX + +// ----------------------------------------------------------------------- +#include <tools/debug.hxx> +#include <bf_tools/impcont.hxx> +#include <bf_tools/table.hxx> + +namespace binfilter +{ + +// ======================================================================= + +sal_uIntPtr Table::ImplGetIndex( sal_uIntPtr nKey, sal_uIntPtr* pIndex ) const +{ + // Abpruefen, ob der erste Key groesser als der Vergleichskey ist + if ( !nCount || (nKey < (sal_uIntPtr)Container::ImpGetObject(0)) ) + return TABLE_ENTRY_NOTFOUND; + + sal_uIntPtr nLow; + sal_uIntPtr nHigh; + sal_uIntPtr nMid; + sal_uIntPtr nCompareKey; + void** pNodes = Container::ImpGetOnlyNodes(); + + // Binaeres Suchen + nLow = 0; + nHigh = nCount-1; + if ( pNodes ) + { + do + { + nMid = (nLow + nHigh) / 2; + nCompareKey = (sal_uIntPtr)pNodes[nMid*2]; + if ( nKey < nCompareKey ) + nHigh = nMid-1; + else + { + if ( nKey > nCompareKey ) + nLow = nMid + 1; + else + return nMid*2; + } + } + while ( nLow <= nHigh ); + } + else + { + do + { + nMid = (nLow + nHigh) / 2; + nCompareKey = (sal_uIntPtr)Container::ImpGetObject( nMid*2 ); + if ( nKey < nCompareKey ) + nHigh = nMid-1; + else + { + if ( nKey > nCompareKey ) + nLow = nMid + 1; + else + return nMid*2; + } + } + while ( nLow <= nHigh ); + } + + if ( pIndex ) + { + if ( nKey > nCompareKey ) + *pIndex = (nMid+1)*2; + else + *pIndex = nMid*2; + } + + return TABLE_ENTRY_NOTFOUND; +} + +// ======================================================================= + +Table::Table( sal_uInt16 _nInitSize, sal_uInt16 _nReSize ) : + Container( CONTAINER_MAXBLOCKSIZE, _nInitSize*2, _nReSize*2 ) +{ + DBG_ASSERT( _nInitSize <= 32767, "Table::Table(): InitSize > 32767" ); + DBG_ASSERT( _nReSize <= 32767, "Table::Table(): ReSize > 32767" ); + nCount = 0; +} + +// ----------------------------------------------------------------------- + +sal_Bool Table::Insert( sal_uIntPtr nKey, void* p ) +{ + // Tabellenelement einsortieren + sal_uIntPtr i; + if ( nCount ) + { + if ( nCount <= 24 ) + { + sal_uInt16 nTempCount = (sal_uInt16)nCount * 2; + + if( void** pNodes = Container::ImpGetOnlyNodes() ) + { + sal_uInt16 n = 0; + sal_uIntPtr nCompareKey = (sal_uIntPtr)(*pNodes); + while ( nKey > nCompareKey ) + { + n += 2; + pNodes += 2; + if ( n < nTempCount ) + nCompareKey = (sal_uIntPtr)(*pNodes); + else + { + nCompareKey = 0; + break; + } + } + + // Testen, ob sich der Key schon in der Tabelle befindet + if ( nKey == nCompareKey ) + return sal_False; + + i = n; + } + else + { + i = 0; + if ( ImplGetIndex( nKey, &i ) != TABLE_ENTRY_NOTFOUND ) + return sal_False; + } + } + else + { + i = 0; + if ( ImplGetIndex( nKey, &i ) != TABLE_ENTRY_NOTFOUND ) + return sal_False; + } + } + else + i = 0; + + // Eintrag einfuegen (Key vor Pointer) + Container::Insert( (void*)nKey, i ); + Container::Insert( p, i+1 ); + + // Ein neuer Eintrag + nCount++; + + return sal_True; +} + +// ----------------------------------------------------------------------- + +void* Table::Remove( sal_uIntPtr nKey ) +{ + // Index besorgen + sal_uIntPtr nIndex = ImplGetIndex( nKey ); + + // Testen, ob sich der Key in der Tabelle befindet + if ( nIndex == TABLE_ENTRY_NOTFOUND ) + return NULL; + + // Itemanzahl erniedrigen + nCount--; + + // Key entfernen + Container::Remove( nIndex ); + + // Pointer entfernen und zurueckgeben + return Container::Remove( nIndex ); +} + +// ----------------------------------------------------------------------- + +void* Table::Replace( sal_uIntPtr nKey, void* p ) +{ + // Index abfragen + sal_uIntPtr nIndex = ImplGetIndex( nKey ); + + // Existiert kein Eintrag mit dem Schluessel + if ( nIndex == TABLE_ENTRY_NOTFOUND ) + return NULL; + else + return Container::Replace( p, nIndex+1 ); +} + +// ----------------------------------------------------------------------- + +void* Table::Get( sal_uIntPtr nKey ) const +{ + // Index besorgen + sal_uIntPtr nIndex = ImplGetIndex( nKey ); + + // Testen, ob sich der Key in der Tabelle befindet + if ( nIndex == TABLE_ENTRY_NOTFOUND ) + return NULL; + else + return Container::ImpGetObject( nIndex+1 ); +} + +// ----------------------------------------------------------------------- + +void* Table::GetCurObject() const +{ + return Container::ImpGetObject( Container::GetCurPos()+1 ); +} + +// ----------------------------------------------------------------------- + +sal_uIntPtr Table::GetKey( const void* p ) const +{ + sal_uIntPtr nIndex = 0; + + // Solange noch Eintraege Vorhanden sind + while ( nIndex < nCount ) + { + // Stimmt der Pointer ueberein, wird der Key zurueckgegeben + if ( p == Container::ImpGetObject( (nIndex*2)+1 ) ) + return (sal_uIntPtr)Container::ImpGetObject( nIndex*2 ); + + nIndex++; + } + + return TABLE_ENTRY_NOTFOUND; +} + +// ----------------------------------------------------------------------- + +sal_Bool Table::IsKeyValid( sal_uIntPtr nKey ) const +{ + return (ImplGetIndex( nKey ) != TABLE_ENTRY_NOTFOUND) ? sal_True : sal_False; +} + +// ----------------------------------------------------------------------- + +sal_uIntPtr Table::SearchKey( sal_uIntPtr nKey, sal_uIntPtr* pPos ) const +{ + *pPos = 0; + sal_uIntPtr nPos = ImplGetIndex( nKey, pPos ); + if ( nPos != TABLE_ENTRY_NOTFOUND ) + { + nPos /= 2; + *pPos = nPos; + } + else + *pPos /= 2; + return nPos; +} + +// ----------------------------------------------------------------------- + +void* Table::Seek( sal_uIntPtr nKey ) +{ + // Testen, ob ein Eintrag vorhanden ist + if ( nCount ) + { + sal_uIntPtr nIndex = ImplGetIndex( nKey ); + + // Ist Key nicht enthalten + if ( nIndex == TABLE_ENTRY_NOTFOUND ) + return NULL; + else + { + // Index setzen + Container::Seek( nIndex ); + + // Pointer zurueckgeben + return Container::ImpGetObject( Container::GetCurPos() + 1 ); + } + } + else + return NULL; +} + +void* Table::First() +{ + // Testen, ob ein Eintrag vorhanden ist + if ( nCount ) + { + // Auf ersten Eintag setzen + Container::First(); + + // Pointer zurueckgeben + return Container::ImpGetObject( 1 ); + } + else + return NULL; +} + +// ----------------------------------------------------------------------- + +void* Table::Last() +{ + // Testen, ob ein Eintrag vorhanden ist + if ( nCount ) + { + // Last auf letzten Eintrag setzen + void* p = Container::Last(); + Container::Prev(); + + // Pointer zurueckgeben + return p; + } + else + return NULL; +} + +// ----------------------------------------------------------------------- + +void* Table::Next() +{ + // Ueber den Pointer weiterschalten + Container::Next(); + + // Nachsten Eintag + Container::Next(); + + // Pointer vom naechsten Key zurueckgeben + return Container::ImpGetObject( Container::GetCurPos() + 1 ); +} + +// ----------------------------------------------------------------------- + +void* Table::Prev() +{ + // Ueber den Pointer weiterschalten + void* p = Container::Prev(); + + // Nachsten Eintag + Container::Prev(); + + // Pointer vom vorherigen Key zurueckgeben + return p; +} + +} // namespace binfilter + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_svtools/source/misc/svt_imap.cxx b/binfilter/bf_svtools/source/misc/svt_imap.cxx index 49b76e904..32ea4cb22 100644 --- a/binfilter/bf_svtools/source/misc/svt_imap.cxx +++ b/binfilter/bf_svtools/source/misc/svt_imap.cxx @@ -26,7 +26,6 @@ * ************************************************************************/ -#include <tools/table.hxx> #include <string.h> #include <math.h> #include <tools/urlobj.hxx> diff --git a/binfilter/bf_svtools/source/misc/svt_urihelper.cxx b/binfilter/bf_svtools/source/misc/svt_urihelper.cxx index 0ba6f92a8..0fb3982a6 100644 --- a/binfilter/bf_svtools/source/misc/svt_urihelper.cxx +++ b/binfilter/bf_svtools/source/misc/svt_urihelper.cxx @@ -27,7 +27,6 @@ ************************************************************************/ #include <tools/urlobj.hxx> -#include <tools/table.hxx> #include <urihelper.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include "com/sun/star/lang/WrappedTargetRuntimeException.hpp" diff --git a/binfilter/bf_svtools/source/misc1/svt_inettype.cxx b/binfilter/bf_svtools/source/misc1/svt_inettype.cxx index a4419afff..4f5e865c7 100644 --- a/binfilter/bf_svtools/source/misc1/svt_inettype.cxx +++ b/binfilter/bf_svtools/source/misc1/svt_inettype.cxx @@ -26,7 +26,7 @@ * ************************************************************************/ -#include <tools/table.hxx> +#include <bf_tools/table.hxx> #include <tools/wldcrd.hxx> #include <bf_svtools/inettype.hxx> diff --git a/binfilter/bf_svtools/source/uno/svt_unoevent.cxx b/binfilter/bf_svtools/source/uno/svt_unoevent.cxx index 223ef9aab..8c0b5d220 100644 --- a/binfilter/bf_svtools/source/uno/svt_unoevent.cxx +++ b/binfilter/bf_svtools/source/uno/svt_unoevent.cxx @@ -26,7 +26,6 @@ * ************************************************************************/ -#include <tools/table.hxx> #include <bf_tools/string.hxx> #include <com/sun/star/beans/PropertyValue.hpp> #include <rtl/ustrbuf.hxx> diff --git a/binfilter/bf_svtools/source/uno/svt_unoimap.cxx b/binfilter/bf_svtools/source/uno/svt_unoimap.cxx index 58d5eb746..5446f0181 100644 --- a/binfilter/bf_svtools/source/uno/svt_unoimap.cxx +++ b/binfilter/bf_svtools/source/uno/svt_unoimap.cxx @@ -44,7 +44,6 @@ #include <cppuhelper/weakagg.hxx> #include <cppuhelper/implbase3.hxx> -#include <tools/table.hxx> #include <list> #include <rtl/uuid.h> diff --git a/binfilter/bf_svx/source/editeng/editdoc.hxx b/binfilter/bf_svx/source/editeng/editdoc.hxx index a4af2c9b8..f7bb1d176 100644 --- a/binfilter/bf_svx/source/editeng/editdoc.hxx +++ b/binfilter/bf_svx/source/editeng/editdoc.hxx @@ -38,7 +38,6 @@ #include <bf_svtools/itempool.hxx> -#include <tools/table.hxx> namespace binfilter { class ImpEditEngine; diff --git a/binfilter/bf_sw/source/core/text/inftxt.hxx b/binfilter/bf_sw/source/core/text/inftxt.hxx index b4e876756..6fe228dda 100644 --- a/binfilter/bf_sw/source/core/text/inftxt.hxx +++ b/binfilter/bf_sw/source/core/text/inftxt.hxx @@ -32,7 +32,7 @@ #include <com/sun/star/linguistic2/XHyphenatedWord.hpp> #include <com/sun/star/beans/PropertyValues.hpp> -#include <tools/table.hxx> +#include <bf_tools/table.hxx> #include "swtypes.hxx" #include "txttypes.hxx" diff --git a/binfilter/inc/bf_sc/chgtrack.hxx b/binfilter/inc/bf_sc/chgtrack.hxx index 6c860b7d4..ba14f2be3 100644 --- a/binfilter/inc/bf_sc/chgtrack.hxx +++ b/binfilter/inc/bf_sc/chgtrack.hxx @@ -35,7 +35,7 @@ #include <tools/datetime.hxx> -#include <tools/table.hxx> +#include <bf_tools/table.hxx> #include <tools/mempool.hxx> #include <bf_tools/stack.hxx> #include <bf_svtools/lstner.hxx> diff --git a/binfilter/inc/bf_sch/schopt.hxx b/binfilter/inc/bf_sch/schopt.hxx index 766477469..29296bcd4 100644 --- a/binfilter/inc/bf_sch/schopt.hxx +++ b/binfilter/inc/bf_sch/schopt.hxx @@ -40,7 +40,7 @@ // header for Color #include <tools/color.hxx> // header for Table -#include <tools/table.hxx> +#include <bf_tools/table.hxx> // header for XColorEntry #include <bf_svx/xtable.hxx> namespace binfilter { diff --git a/binfilter/inc/bf_sfx2/objsh.hxx b/binfilter/inc/bf_sfx2/objsh.hxx index 2aacaf005..62e29ea70 100644 --- a/binfilter/inc/bf_sfx2/objsh.hxx +++ b/binfilter/inc/bf_sfx2/objsh.hxx @@ -46,7 +46,7 @@ #include <bf_so3/persist.hxx> #include <bf_so3/so2defs.hxx> #include <bf_so3/svstor.hxx> -#include <tools/table.hxx> +#include <bf_tools/table.hxx> #include <vcl/timer.hxx> #include <vcl/bitmap.hxx> diff --git a/binfilter/inc/bf_svtools/macitem.hxx b/binfilter/inc/bf_svtools/macitem.hxx index d26ead389..3c907357e 100644 --- a/binfilter/inc/bf_svtools/macitem.hxx +++ b/binfilter/inc/bf_svtools/macitem.hxx @@ -42,7 +42,7 @@ #include <bf_tools/string.hxx> -#include <tools/table.hxx> +#include <bf_tools/table.hxx> class SvStream; diff --git a/binfilter/inc/bf_svtools/zforlist.hxx b/binfilter/inc/bf_svtools/zforlist.hxx index 5477e6334..88ab12523 100644 --- a/binfilter/inc/bf_svtools/zforlist.hxx +++ b/binfilter/inc/bf_svtools/zforlist.hxx @@ -33,7 +33,7 @@ #include "bf_svtools/svtdllapi.h" #include <bf_tools/string.hxx> -#include <tools/table.hxx> +#include <bf_tools/table.hxx> #include <i18npool/lang.h> #include <bf_svtools/svarray.hxx> #include <com/sun/star/uno/Reference.hxx> diff --git a/binfilter/inc/bf_svx/forbiddencharacterstable.hxx b/binfilter/inc/bf_svx/forbiddencharacterstable.hxx index bb09b52e6..c07b483d1 100644 --- a/binfilter/inc/bf_svx/forbiddencharacterstable.hxx +++ b/binfilter/inc/bf_svx/forbiddencharacterstable.hxx @@ -31,7 +31,7 @@ #include <bf_svtools/bf_solar.h> -#include <tools/table.hxx> +#include <bf_tools/table.hxx> #include <salhelper/simplereferenceobject.hxx> diff --git a/binfilter/inc/bf_svx/svdmodel.hxx b/binfilter/inc/bf_svx/svdmodel.hxx index 370bb1332..60c4a5a1a 100644 --- a/binfilter/inc/bf_svx/svdmodel.hxx +++ b/binfilter/inc/bf_svx/svdmodel.hxx @@ -36,7 +36,7 @@ #include <bf_so3/svstor.hxx> #include <tools/link.hxx> -#include <tools/contnr.hxx> +#include <bf_tools/contnr.hxx> #include <vcl/mapmod.hxx> #include <bf_svtools/brdcst.hxx> #include <bf_tools/string.hxx> diff --git a/binfilter/inc/bf_svx/xtable.hxx b/binfilter/inc/bf_svx/xtable.hxx index aa6f3d0e2..0d8bf2ad6 100644 --- a/binfilter/inc/bf_svx/xtable.hxx +++ b/binfilter/inc/bf_svx/xtable.hxx @@ -44,7 +44,6 @@ #include <bf_tools/string.hxx> -#include <tools/table.hxx> class Color; class Bitmap; class VirtualDevice; diff --git a/binfilter/inc/bf_sw/hints.hxx b/binfilter/inc/bf_sw/hints.hxx index 4e7d8c6ee..2737491c1 100644 --- a/binfilter/inc/bf_sw/hints.hxx +++ b/binfilter/inc/bf_sw/hints.hxx @@ -30,7 +30,7 @@ #include <bf_svtools/bf_solar.h> -#include <tools/table.hxx> +#include <bf_tools/table.hxx> #include <swatrset.hxx> class OutputDevice; namespace binfilter { diff --git a/binfilter/inc/bf_tools/table.hxx b/binfilter/inc/bf_tools/table.hxx new file mode 100644 index 000000000..e39b33460 --- /dev/null +++ b/binfilter/inc/bf_tools/table.hxx @@ -0,0 +1,153 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _TOOLS_TABLE_HXX +#define _TOOLS_TABLE_HXX + +#include "tools/toolsdllapi.h" +#include <tools/solar.h> +#include <bf_tools/contnr.hxx> + +namespace binfilter +{ + +// --------- +// - Table - +// --------- + +#define TABLE_ENTRY_NOTFOUND CONTAINER_ENTRY_NOTFOUND + +class TOOLS_DLLPUBLIC Table : private Container +{ +private: + sal_uIntPtr nCount; + TOOLS_DLLPRIVATE sal_uIntPtr ImplGetIndex( sal_uIntPtr nKey, sal_uIntPtr* pIndex = NULL ) const; +public: + Table( sal_uInt16 nInitSize = 16, sal_uInt16 nReSize = 16 ); + Table( const Table& rTable ) : Container( rTable ) + { nCount = rTable.nCount; } + + sal_Bool Insert( sal_uIntPtr nKey, void* p ); + void* Remove( sal_uIntPtr nKey ); + void* Replace( sal_uIntPtr nKey, void* p ); + void* Get( sal_uIntPtr nKey ) const; + + void Clear() { Container::Clear(); nCount = 0; } + sal_uIntPtr Count() const { return( nCount ); } + + void* GetCurObject() const; + sal_uIntPtr GetCurKey() const { return (sal_uIntPtr)Container::GetCurObject(); } + sal_uIntPtr GetKey( const void* p ) const; + sal_Bool IsKeyValid( sal_uIntPtr nKey ) const; + + void* GetObject( sal_uIntPtr nPos ) const + { return Container::GetObject( (nPos*2)+1 ); } + sal_uIntPtr GetObjectKey( sal_uIntPtr nPos ) const + { return (sal_uIntPtr)Container::GetObject( nPos*2 ); } + sal_uIntPtr SearchKey( sal_uIntPtr nKey, sal_uIntPtr* pPos = NULL ) const; + + void* Seek( sal_uIntPtr nKey ); + void* First(); + void* Last(); + void* Next(); + void* Prev(); + + Table& operator =( const Table& rTable ); + + sal_Bool operator ==( const Table& rTable ) const + { return Container::operator ==( rTable ); } + sal_Bool operator !=( const Table& rTable ) const + { return Container::operator !=( rTable ); } +}; + +inline Table& Table::operator =( const Table& r ) +{ + Container::operator =( r ); + nCount = r.nCount; + return *this; +} + +// ----------------- +// - DECLARE_TABLE - +// ----------------- + +#define DECLARE_TABLE( ClassName, Type ) \ +class ClassName : private Table \ +{ \ +public: \ + using Table::Clear; \ + using Table::Count; \ + using Table::GetCurKey; \ + using Table::GetObjectKey; \ + using Table::SearchKey; \ + using Table::IsKeyValid; \ + \ + ClassName( sal_uInt16 _nInitSize = 16, \ + sal_uInt16 _nReSize = 16 ) : \ + Table( _nInitSize, _nReSize ) {} \ + ClassName( const ClassName& rClassName ) : \ + Table( rClassName ) {} \ + \ + sal_Bool Insert( sal_uIntPtr nKey, Type p ) \ + { return Table::Insert( nKey, (void*)p ); } \ + Type Remove( sal_uIntPtr nKey ) \ + { return (Type)Table::Remove( nKey ); } \ + Type Replace( sal_uIntPtr nKey, Type p ) \ + { return (Type)Table::Replace( nKey, (void*)p ); } \ + Type Get( sal_uIntPtr nKey ) const \ + { return (Type)Table::Get( nKey ); } \ + \ + Type GetCurObject() const \ + { return (Type)Table::GetCurObject(); } \ + sal_uIntPtr GetKey( const Type p ) const \ + { return Table::GetKey( (const void*)p ); } \ + \ + Type GetObject( sal_uIntPtr nPos ) const \ + { return (Type)Table::GetObject( nPos ); } \ + \ + Type Seek( sal_uIntPtr nKey ) \ + { return (Type)Table::Seek( nKey ); } \ + Type First() { return (Type)Table::First(); } \ + Type Last() { return (Type)Table::Last(); } \ + Type Next() { return (Type)Table::Next(); } \ + Type Prev() { return (Type)Table::Prev(); } \ + \ + ClassName& operator =( const ClassName& rClassName ) \ + { Table::operator =( rClassName ); \ + return *this; } \ + \ + sal_Bool operator ==( const ClassName& rTable ) const \ + { return Table::operator ==( rTable ); } \ + sal_Bool operator !=( const ClassName& rTable ) const \ + { return Table::operator !=( rTable ); } \ +}; + +} // namespace binfilter + +#endif // _TOOLS_TABLE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |