1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _DYNARY_HXX 25 #define _DYNARY_HXX 26 27 #include <tools/solar.h> 28 #include <tools/contnr.hxx> 29 30 // ------------ 31 // - DynArray - 32 // ------------ 33 34 #define DYNARRAY_ENTRY_NOTFOUND CONTAINER_ENTRY_NOTFOUND 35 36 class DynArray : private Container 37 { 38 public: 39 using Container::SetSize; 40 using Container::GetSize; 41 using Container::Clear; 42 DynArray(sal_uIntPtr nSize=16)43 DynArray( sal_uIntPtr nSize = 16 ) : Container( nSize ) {} DynArray(const DynArray & rAry)44 DynArray( const DynArray& rAry ) : Container( rAry ) {} 45 Put(sal_uIntPtr nIndex,void * p)46 void* Put( sal_uIntPtr nIndex, void* p ) 47 { return Container::Replace( p, nIndex ); } Get(sal_uIntPtr nIndex) const48 void* Get( sal_uIntPtr nIndex ) const 49 { return Container::GetObject( nIndex ); } 50 GetIndex(const void * p) const51 sal_uIntPtr GetIndex( const void* p ) const 52 { return Container::GetPos( p ); } GetIndex(const void * p,sal_uIntPtr nStartIndex,sal_Bool bForward=sal_True) const53 sal_uIntPtr GetIndex( const void* p, sal_uIntPtr nStartIndex, 54 sal_Bool bForward = sal_True ) const 55 { return Container::GetPos( p, nStartIndex, bForward ); } 56 operator =(const DynArray & rAry)57 DynArray& operator =( const DynArray& rAry ) 58 { Container::operator =( rAry ); return *this; } 59 operator ==(const DynArray & rAry) const60 sal_Bool operator ==( const DynArray& rAry ) const 61 { return Container::operator ==( rAry ); } operator !=(const DynArray & rAry) const62 sal_Bool operator !=( const DynArray& rAry ) const 63 { return Container::operator !=( rAry ); } 64 }; 65 66 // -------------------- 67 // - DECLARE_DYNARRAY - 68 // -------------------- 69 70 #define DECLARE_DYNARRAY( ClassName, Type ) \ 71 class ClassName : private DynArray \ 72 { \ 73 public: \ 74 using DynArray::SetSize; \ 75 using DynArray::GetSize; \ 76 using DynArray::Clear; \ 77 \ 78 ClassName( sal_uIntPtr nSize = 16 ) : \ 79 DynArray( nSize ) {} \ 80 ClassName( const ClassName& rClassName ) : \ 81 DynArray( rClassName ) {} \ 82 \ 83 Type Put( sal_uIntPtr nIndex, Type p ) \ 84 { return (Type)DynArray::Put( nIndex, (void*)p ); } \ 85 Type Get( sal_uIntPtr nIndex ) const \ 86 { return (Type)DynArray::Get( nIndex ); } \ 87 \ 88 sal_uIntPtr GetIndex( const Type p ) const \ 89 { return DynArray::GetIndex( (const void*)p ); } \ 90 sal_uIntPtr GetIndex( const Type p, sal_uIntPtr nStartIndex, \ 91 sal_Bool bForward = sal_True ) const \ 92 { return DynArray::GetIndex( (const void*)p, \ 93 nStartIndex, \ 94 bForward ); } \ 95 \ 96 ClassName& operator =( const ClassName& rClassName ) \ 97 { DynArray::operator =( rClassName ); \ 98 return *this; } \ 99 \ 100 sal_Bool operator ==( const ClassName& rAry ) const \ 101 { return DynArray::operator ==( rAry ); } \ 102 sal_Bool operator !=( const ClassName& rAry ) const \ 103 { return DynArray::operator !=( rAry ); } \ 104 }; 105 106 #endif // _DYNARY_HXX 107