1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: minstack.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _SFXMINSTACK_HXX
31 #define _SFXMINSTACK_HXX
33 //ASDBG #ifndef _SFXMINARRAY_HXX
36 #define DECL_OBJSTACK( ARR, T, nI, nG ) \
37 DECL_OBJARRAY( ARR##arr_, T, nI, nG ); \
38 class ARR: private ARR##arr_ \
41 ARR( BYTE nInitSize = nI, BYTE nGrowSize = nG ): \
42 ARR##arr_( nInitSize, nGrowSize ) \
45 ARR( const ARR& rOrig ): \
49 USHORT Count() const { return ARR##arr_::Count(); } \
50 void Push( const T& rElem ) { Append( rElem ); } \
51 const T& Top( USHORT nLevel = 0 ) const \
52 { return (*this)[Count()-nLevel-1]; } \
53 const T& Bottom() const { return (*this)[0]; } \
55 void Clear() { ARR##arr_::Clear(); } \
56 BOOL Contains( const T& rItem ) const \
57 { return ARR##arr_::Contains( rItem ); } \
60 #define IMPL_OBJSTACK( ARR, T ) \
61 IMPL_OBJARRAY( ARR##arr_, T ); \
64 { T aRet = (*this)[Count()-1]; \
65 Remove( Count()-1, 1 ); \
68 //STRIP008 the following "DECL_PTRARRAY( ARR##arr_, T, nI, nG );\" should be "DECL_PTRARRAY( ARR##arr_, T, nI, nG )\"
69 #define DECL_PTRSTACK( ARR, T, nI, nG ) \
70 DECL_PTRARRAY( ARR##arr_, T, nI, nG ) \
71 class ARR: private ARR##arr_ \
74 ARR( BYTE nInitSize = nI, BYTE nGrowSize = nG ): \
75 ARR##arr_( nInitSize, nGrowSize ) \
78 ARR( const ARR& rOrig ): \
82 USHORT Count() const { return ARR##arr_::Count(); } \
83 void Push( T rElem ) { Append( rElem ); } \
84 BOOL Replace( T rOldElem, T rNewElem ) \
85 { return ARR##arr_::Replace( rOldElem, rNewElem ); } \
86 T Top( USHORT nLevel = 0 ) const \
87 { return (*this)[Count()-nLevel-1]; } \
88 T Bottom() const { return (*this)[0]; } \
90 { T aRet = (*this)[Count()-1]; \
91 Remove( Count()-1, 1 ); \
95 { return &(*this)[Count()-1]; } \
96 void Clear() { ARR##arr_::Clear(); } \
97 BOOL Contains( const T pItem ) const \
98 { return ARR##arr_::Contains( pItem ); } \
101 }//end of namespace binfilter