xref: /aoo41x/main/tools/inc/tools/list.hxx (revision 8b851043)
1*8b851043SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*8b851043SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*8b851043SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*8b851043SAndrew Rist  * distributed with this work for additional information
6*8b851043SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*8b851043SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*8b851043SAndrew Rist  * "License"); you may not use this file except in compliance
9*8b851043SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*8b851043SAndrew Rist  *
11*8b851043SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*8b851043SAndrew Rist  *
13*8b851043SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*8b851043SAndrew Rist  * software distributed under the License is distributed on an
15*8b851043SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*8b851043SAndrew Rist  * KIND, either express or implied.  See the License for the
17*8b851043SAndrew Rist  * specific language governing permissions and limitations
18*8b851043SAndrew Rist  * under the License.
19*8b851043SAndrew Rist  *
20*8b851043SAndrew Rist  *************************************************************/
21*8b851043SAndrew Rist 
22*8b851043SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _LIST_HXX
25cdf0e10cSrcweir #define _LIST_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <tools/solar.h>
28cdf0e10cSrcweir #include <tools/contnr.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir // --------
31cdf0e10cSrcweir // - List -
32cdf0e10cSrcweir // --------
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #define LIST_APPEND           CONTAINER_APPEND
35cdf0e10cSrcweir #define LIST_ENTRY_NOTFOUND   CONTAINER_ENTRY_NOTFOUND
36cdf0e10cSrcweir 
37cdf0e10cSrcweir class List : private Container
38cdf0e10cSrcweir {
39cdf0e10cSrcweir public:
40cdf0e10cSrcweir 			using Container::Insert;
41cdf0e10cSrcweir             using Container::Remove;
42cdf0e10cSrcweir             using Container::Replace;
43cdf0e10cSrcweir             using Container::Clear;
44cdf0e10cSrcweir             using Container::Count;
45cdf0e10cSrcweir             using Container::GetCurObject;
46cdf0e10cSrcweir             using Container::GetCurPos;
47cdf0e10cSrcweir             using Container::GetObject;
48cdf0e10cSrcweir             using Container::GetPos;
49cdf0e10cSrcweir             using Container::Seek;
50cdf0e10cSrcweir             using Container::First;
51cdf0e10cSrcweir             using Container::Last;
52cdf0e10cSrcweir             using Container::Next;
53cdf0e10cSrcweir             using Container::Prev;
54cdf0e10cSrcweir 
List(sal_uInt16 _nInitSize=16,sal_uInt16 _nReSize=16)55cdf0e10cSrcweir             List( sal_uInt16 _nInitSize = 16, sal_uInt16 _nReSize = 16 ) :
56cdf0e10cSrcweir                 Container( 1024, _nInitSize, _nReSize ) {}
List(sal_uInt16 _nBlockSize,sal_uInt16 _nInitSize,sal_uInt16 _nReSize)57cdf0e10cSrcweir             List( sal_uInt16 _nBlockSize, sal_uInt16 _nInitSize, sal_uInt16 _nReSize ) :
58cdf0e10cSrcweir                 Container( _nBlockSize, _nInitSize, _nReSize ) {}
List(const List & rList)59cdf0e10cSrcweir             List( const List& rList ) : Container( rList ) {}
60cdf0e10cSrcweir 
operator =(const List & rList)61cdf0e10cSrcweir     List&   operator =( const List& rList )
62cdf0e10cSrcweir                 { Container::operator =( rList ); return *this; }
63cdf0e10cSrcweir 
operator ==(const List & rList) const64cdf0e10cSrcweir     sal_Bool    operator ==( const List& rList ) const
65cdf0e10cSrcweir                 { return Container::operator ==( rList ); }
operator !=(const List & rList) const66cdf0e10cSrcweir     sal_Bool    operator !=( const List& rList ) const
67cdf0e10cSrcweir                 { return Container::operator !=( rList ); }
68cdf0e10cSrcweir };
69cdf0e10cSrcweir 
70cdf0e10cSrcweir // ----------------
71cdf0e10cSrcweir // - DECLARE_LIST -
72cdf0e10cSrcweir // ----------------
73cdf0e10cSrcweir 
74cdf0e10cSrcweir #define DECLARE_LIST( ClassName, Type )                                 \
75cdf0e10cSrcweir class ClassName : private List                                          \
76cdf0e10cSrcweir {                                                                       \
77cdf0e10cSrcweir public:                                                                 \
78cdf0e10cSrcweir                 using List::Clear;                                      \
79cdf0e10cSrcweir                 using List::Count;                                      \
80cdf0e10cSrcweir                 using List::GetCurPos;                                  \
81cdf0e10cSrcweir 																		\
82cdf0e10cSrcweir                 ClassName( sal_uInt16 _nInitSize = 16,                      \
83cdf0e10cSrcweir                            sal_uInt16 _nReSize = 16 ) :                     \
84cdf0e10cSrcweir                     List( _nInitSize, _nReSize ) {}                     \
85cdf0e10cSrcweir                 ClassName( sal_uInt16 _nBlockSize, sal_uInt16 _nInitSize,       \
86cdf0e10cSrcweir                            sal_uInt16 _nReSize ) :                          \
87cdf0e10cSrcweir                     List( _nBlockSize, _nInitSize, _nReSize ) {}        \
88cdf0e10cSrcweir                 ClassName( const ClassName& rClassName ) :              \
89cdf0e10cSrcweir                     List( rClassName ) {}                               \
90cdf0e10cSrcweir                                                                         \
91cdf0e10cSrcweir     void        Insert( Type p, sal_uIntPtr nIndex )                          \
92cdf0e10cSrcweir                     { List::Insert( (void*)p, nIndex ); }               \
93cdf0e10cSrcweir     void        Insert( Type p )                                        \
94cdf0e10cSrcweir                     { List::Insert( (void*)p ); }                       \
95cdf0e10cSrcweir     void        Insert( Type pNew, Type pOld )                          \
96cdf0e10cSrcweir                     { List::Insert( (void*)pNew, (void*)pOld ); }       \
97cdf0e10cSrcweir     Type        Remove()                                                \
98cdf0e10cSrcweir                     { return (Type)List::Remove(); }                    \
99cdf0e10cSrcweir     Type        Remove( sal_uIntPtr nIndex )                                  \
100cdf0e10cSrcweir                     { return (Type)List::Remove( nIndex ); }            \
101cdf0e10cSrcweir     Type        Remove( Type p )                                        \
102cdf0e10cSrcweir                     { return (Type)List::Remove( (void*)p ); }          \
103cdf0e10cSrcweir     Type        Replace( Type p )                                       \
104cdf0e10cSrcweir                     { return (Type)List::Replace( (void*)p ); }         \
105cdf0e10cSrcweir     Type        Replace( Type p, sal_uIntPtr nIndex )                         \
106cdf0e10cSrcweir                     { return (Type)List::Replace( (void*)p, nIndex ); } \
107cdf0e10cSrcweir     Type        Replace( Type pNew, Type pOld )                         \
108cdf0e10cSrcweir                     { return (Type)List::Replace( (void*)pNew,          \
109cdf0e10cSrcweir                                                   (void*)pOld ); }      \
110cdf0e10cSrcweir                                                                         \
111cdf0e10cSrcweir     Type        GetCurObject() const                                    \
112cdf0e10cSrcweir                     { return (Type)List::GetCurObject(); }              \
113cdf0e10cSrcweir     Type        GetObject( sal_uIntPtr nIndex ) const                         \
114cdf0e10cSrcweir                     { return (Type)List::GetObject( nIndex ); }         \
115cdf0e10cSrcweir     sal_uIntPtr       GetPos( const Type p ) const                            \
116cdf0e10cSrcweir                     { return List::GetPos( (const void*)p ); }          \
117cdf0e10cSrcweir     sal_uIntPtr       GetPos( const Type p, sal_uIntPtr nStartIndex,                \
118cdf0e10cSrcweir                         sal_Bool bForward = sal_True ) const                    \
119cdf0e10cSrcweir                     { return List::GetPos( (const void*)p, nStartIndex, \
120cdf0e10cSrcweir                                            bForward ); }                \
121cdf0e10cSrcweir                                                                         \
122cdf0e10cSrcweir     Type        Seek( sal_uIntPtr nIndex )                                    \
123cdf0e10cSrcweir                     { return (Type)List::Seek( nIndex ); }              \
124cdf0e10cSrcweir     Type        Seek( void* p ) { return (Type)List::Seek( p ); }       \
125cdf0e10cSrcweir     Type        First()         { return (Type)List::First(); }         \
126cdf0e10cSrcweir     Type        Last()          { return (Type)List::Last(); }          \
127cdf0e10cSrcweir     Type        Next()          { return (Type)List::Next(); }          \
128cdf0e10cSrcweir     Type        Prev()          { return (Type)List::Prev(); }          \
129cdf0e10cSrcweir                                                                         \
130cdf0e10cSrcweir     ClassName&  operator =( const ClassName& rClassName )               \
131cdf0e10cSrcweir                     { List::operator =( rClassName ); return *this; }   \
132cdf0e10cSrcweir                                                                         \
133cdf0e10cSrcweir     sal_Bool        operator ==( const ClassName& rList ) const             \
134cdf0e10cSrcweir                     { return List::operator ==( rList ); }              \
135cdf0e10cSrcweir     sal_Bool        operator !=( const ClassName& rList ) const             \
136cdf0e10cSrcweir                     { return List::operator !=( rList ); }              \
137cdf0e10cSrcweir };
138cdf0e10cSrcweir 
139cdf0e10cSrcweir #endif // _LIST_HXX
140