1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef _CONTNR_HXX 28 #define _CONTNR_HXX 29 30 #include "tools/toolsdllapi.h" 31 #include <tools/solar.h> 32 33 #include <limits.h> 34 35 class CBlock; 36 37 // ------------- 38 // - Container - 39 // ------------- 40 41 // Maximale Blockgroesse 42 #define CONTAINER_MAXBLOCKSIZE ((sal_uInt16)0x3FF0) 43 44 #define CONTAINER_APPEND ULONG_MAX 45 #define CONTAINER_ENTRY_NOTFOUND ULONG_MAX 46 47 class TOOLS_DLLPUBLIC Container 48 { 49 private: 50 CBlock* pFirstBlock; 51 CBlock* pCurBlock; 52 CBlock* pLastBlock; 53 sal_uInt16 nCurIndex; 54 sal_uInt16 nBlockSize; 55 sal_uInt16 nInitSize; 56 sal_uInt16 nReSize; 57 sal_uIntPtr nCount; 58 59 TOOLS_DLLPRIVATE void ImpCopyContainer(Container const *); 60 #if defined DBG_UTIL 61 TOOLS_DLLPRIVATE static char const * DbgCheckContainer(void const *); 62 #endif 63 64 protected: 65 #ifdef _IMPCONT_HXX 66 void ImpInsert( void* p, CBlock* pBlock, sal_uInt16 nIndex ); 67 void* ImpRemove( CBlock* pBlock, sal_uInt16 nIndex ); 68 void* ImpGetObject( sal_uIntPtr nIndex ) const; 69 void** ImpGetOnlyNodes() const; 70 #endif 71 void** GetObjectPtr( sal_uIntPtr nIndex ); 72 73 public: 74 Container( sal_uInt16 nBlockSize, 75 sal_uInt16 nInitSize, 76 sal_uInt16 nReSize ); 77 Container( sal_uIntPtr nSize ); 78 Container( const Container& rContainer ); 79 ~Container(); 80 81 void Insert( void* p ); 82 void Insert( void* p, sal_uIntPtr nIndex ); 83 void Insert( void* pNew, void* pOld ); 84 85 void* Remove(); 86 void* Remove( sal_uIntPtr nIndex ); 87 void* Remove( void* p ) 88 { return Remove( GetPos( p ) ); } 89 90 void* Replace( void* p ); 91 void* Replace( void* p, sal_uIntPtr nIndex ); 92 void* Replace( void* pNew, void* pOld ) 93 { return Replace( pNew, GetPos( pOld ) ); } 94 95 void SetSize( sal_uIntPtr nNewSize ); 96 sal_uIntPtr GetSize() const { return nCount; } 97 98 sal_uIntPtr Count() const { return nCount; } 99 void Clear(); 100 101 void* GetCurObject() const; 102 sal_uIntPtr GetCurPos() const; 103 void* GetObject( sal_uIntPtr nIndex ) const; 104 sal_uIntPtr GetPos( const void* p ) const; 105 sal_uIntPtr GetPos( const void* p, sal_uIntPtr nStartIndex, 106 sal_Bool bForward = sal_True ) const; 107 108 void* Seek( sal_uIntPtr nIndex ); 109 void* Seek( void* p ) { return Seek( GetPos( p ) ); } 110 111 void* First(); 112 void* Last(); 113 void* Next(); 114 void* Prev(); 115 116 Container& operator =( const Container& rContainer ); 117 118 sal_Bool operator ==( const Container& rContainer ) const; 119 sal_Bool operator !=( const Container& rContainer ) const 120 { return !(Container::operator==( rContainer )); } 121 }; 122 123 #endif // _CONTNR_HXX 124