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: svarray.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 ************************************************************************/
34 #ifndef INCLUDED_STRING_H
35 #include <string.h> // memmove()
36 #define INCLUDED_STRING_H
39 #ifndef INCLUDED_LIMITS_H
40 #include <limits.h> // USHRT_MAX
41 #define INCLUDED_LIMITS_H
45 #include <rtl/alloc.h>
49 #include <tools/solar.h>
55 #define CONCAT(x,y) x##y
59 inline void* operator new( size_t, DummyType
* pPtr
)
63 inline void operator delete( void*, DummyType
* ) {}
69 #define _SVVARARR_DEF_GET_OP_INLINE( nm, ArrElem ) \
70 ArrElem& operator[](USHORT nP) const { return *(pData+nP); }\
72 void Insert( const nm * pI, USHORT nP,\
73 USHORT nS = 0, USHORT nE = USHRT_MAX )\
75 if( USHRT_MAX == nE ) \
78 Insert( (const ArrElem*)pI->pData+nS, (USHORT)nE-nS, nP );\
81 #define _SVVARARR_IMPL_GET_OP_INLINE( nm, ArrElem )
85 #define _SVVARARR_DEF_GET_OP_INLINE( nm,ArrElem )\
86 ArrElem& operator[](USHORT nP) const;\
87 void Insert( const nm *pI, USHORT nP,\
88 USHORT nS = 0, USHORT nE = USHRT_MAX );
90 #define _SVVARARR_IMPL_GET_OP_INLINE( nm, ArrElem )\
91 ArrElem& nm::operator[](USHORT nP) const\
93 DBG_ASSERT( pData && nP < nA,"Op[]");\
96 void nm::Insert( const nm *pI, USHORT nP, USHORT nStt, USHORT nE)\
98 DBG_ASSERT(nP<=nA,"Ins,Ar[Start.End]");\
99 if( USHRT_MAX == nE ) \
102 Insert( (const ArrElem*)pI->pData+nStt, (USHORT)nE-nStt, nP );\
107 #define _SV_DECL_VARARR_GEN(nm, AE, IS, GS, AERef, vis )\
108 typedef BOOL (*FnForEach_##nm)( const AERef, void* );\
116 void _resize(size_t n);\
119 nm( USHORT= IS, BYTE= GS );\
120 ~nm() { rtl_freeMemory( pData ); }\
122 _SVVARARR_DEF_GET_OP_INLINE(nm, AE )\
123 AERef GetObject(USHORT nP) const { return (*this)[nP]; } \
125 void Insert( const AERef aE, USHORT nP );\
126 void Insert( const AE *pE, USHORT nL, USHORT nP );\
127 void Remove( USHORT nP, USHORT nL = 1 );\
128 void Replace( const AERef aE, USHORT nP );\
129 void Replace( const AE *pE, USHORT nL, USHORT nP );\
130 USHORT Count() const { return nA; }\
131 const AE* GetData() const { return (const AE*)pData; }\
133 void ForEach( CONCAT( FnForEach_, nm ) fnForEach, void* pArgs = 0 )\
135 _ForEach( 0, nA, fnForEach, pArgs );\
137 void ForEach( USHORT nS, USHORT nE, \
138 CONCAT( FnForEach_, nm ) fnForEach, void* pArgs = 0 )\
140 _ForEach( nS, nE, fnForEach, pArgs );\
143 void _ForEach( USHORT nStt, USHORT nE, \
144 CONCAT( FnForEach_, nm ) fnCall, void* pArgs = 0 );\
147 #define _SV_DECL_VARARR(nm, AE, IS, GS ) \
148 _SV_DECL_VARARR_GEN(nm, AE, IS, GS, AE & )
150 #define SV_DECL_VARARR_GEN(nm, AE, IS, GS, AERef, vis )\
151 _SV_DECL_VARARR_GEN(nm, AE, IS, GS, AERef, vis )\
154 nm& operator=( const nm& );\
157 #define SV_DECL_VARARR(nm, AE, IS, GS ) \
158 SV_DECL_VARARR_GEN(nm, AE, IS, GS, AE &, )
160 #define SV_DECL_VARARR_VISIBILITY(nm, AE, IS, GS, vis ) \
161 SV_DECL_VARARR_GEN(nm, AE, IS, GS, AE &, vis )
163 #define SV_IMPL_VARARR_GEN( nm, AE, AERef )\
164 nm::nm( USHORT nInit, BYTE )\
171 pData = (AE*)(rtl_allocateMemory(sizeof(AE) * nInit));\
172 DBG_ASSERT( pData, "CTOR, allocate");\
176 void nm::_resize (size_t n)\
178 USHORT nL = ((n < USHRT_MAX) ? USHORT(n) : USHRT_MAX);\
179 AE* pE = (AE*)(rtl_reallocateMemory (pData, sizeof(AE) * nL));\
180 if ((pE != 0) || (nL == 0))\
187 void nm::Insert( const AERef aE, USHORT nP )\
189 DBG_ASSERT(nP <= nA && nA < USHRT_MAX, "Ins 1");\
191 _resize (nA + ((nA > 1) ? nA : 1));\
192 if( pData && nP < nA )\
193 memmove( pData+nP+1, pData+nP, (nA-nP) * sizeof( AE ));\
194 *(pData+nP) = (AE&)aE;\
198 void nm::Insert( const AE* pE, USHORT nL, USHORT nP )\
200 DBG_ASSERT(nP<=nA && ((long)nA+nL)<USHRT_MAX,"Ins n");\
202 _resize (nA + ((nA > nL) ? nA : nL));\
203 if( pData && nP < nA )\
204 memmove( pData+nP+nL, pData+nP, (nA-nP) * sizeof( AE ));\
206 memcpy( pData+nP, pE, nL * sizeof( AE ));\
207 nA = nA + nL; nFree = nFree - nL;\
210 void nm::Replace( const AERef aE, USHORT nP )\
213 *(pData+nP) = (AE&)aE;\
216 void nm::Replace( const AE *pE, USHORT nL, USHORT nP )\
221 memcpy( pData + nP, pE, nL * sizeof( AE ));\
222 else if( nP + nL < nA + nFree )\
224 memcpy( pData + nP, pE, nL * sizeof( AE ));\
225 nP = nP + (nL - nA); \
230 USHORT nTmpLen = nA + nFree - nP; \
231 memcpy( pData + nP, pE, nTmpLen * sizeof( AE ));\
234 Insert( pE + nTmpLen, nL - nTmpLen, nA );\
239 void nm::Remove( USHORT nP, USHORT nL )\
243 DBG_ASSERT( nP < nA && nP + nL <= nA,"Del");\
244 if( pData && nP+1 < nA )\
245 memmove( pData+nP, pData+nP+nL, (nA-nP-nL) * sizeof( AE ));\
246 nA = nA - nL; nFree = nFree + nL;\
251 void nm::_ForEach( USHORT nStt, USHORT nE, \
252 CONCAT( FnForEach_, nm ) fnCall, void* pArgs )\
254 if( nStt >= nE || nE > nA )\
256 for( ; nStt < nE && (*fnCall)( *(const AE*)(pData+nStt), pArgs ); nStt++)\
260 _SVVARARR_IMPL_GET_OP_INLINE(nm, AE )\
262 #define SV_IMPL_VARARR( nm, AE ) \
263 SV_IMPL_VARARR_GEN( nm, AE, AE & )
267 #define _SVOBJARR_DEF_GET_OP_INLINE( nm,ArrElem )\
268 ArrElem& operator[](USHORT nP) const { return *(pData+nP); }\
270 void Insert( const nm *pI, USHORT nP,\
271 USHORT nS = 0, USHORT nE = USHRT_MAX )\
273 if( USHRT_MAX == nE ) \
276 Insert( (const ArrElem*)pI->pData+nS, (USHORT)nE-nS, nP );\
279 #define _SVOBJARR_IMPL_GET_OP_INLINE( nm, ArrElem )
283 #define _SVOBJARR_DEF_GET_OP_INLINE( nm,ArrElem ) \
284 ArrElem& operator[](USHORT nP) const;\
285 void Insert( const nm *pI, USHORT nP,\
286 USHORT nS = 0, USHORT nE = USHRT_MAX );
288 #define _SVOBJARR_IMPL_GET_OP_INLINE( nm, ArrElem )\
289 ArrElem& nm::operator[](USHORT nP) const\
291 DBG_ASSERT( pData && nP < nA,"Op[]");\
294 void nm::Insert( const nm *pI, USHORT nP, USHORT nStt, USHORT nE )\
296 DBG_ASSERT( nP <= nA,"Ins,Ar[Start.End]");\
297 if( USHRT_MAX == nE ) \
300 Insert( (const ArrElem*)pI->pData+nStt, (USHORT)nE-nStt, nP );\
305 #define _SV_DECL_OBJARR(nm, AE, IS, GS)\
306 typedef BOOL (*FnForEach_##nm)( const AE&, void* );\
314 void _resize(size_t n);\
318 nm( USHORT= IS, BYTE= GS );\
319 ~nm() { _destroy(); }\
321 _SVOBJARR_DEF_GET_OP_INLINE(nm,AE)\
322 AE& GetObject(USHORT nP) const { return (*this)[nP]; } \
324 void Insert( const AE &aE, USHORT nP );\
325 void Insert( const AE *pE, USHORT nL, USHORT nP );\
326 void Remove( USHORT nP, USHORT nL = 1 );\
327 USHORT Count() const { return nA; }\
328 const AE* GetData() const { return (const AE*)pData; }\
330 void ForEach( CONCAT( FnForEach_, nm ) fnForEach, void* pArgs = 0 )\
332 _ForEach( 0, nA, fnForEach, pArgs );\
334 void ForEach( USHORT nS, USHORT nE, \
335 CONCAT( FnForEach_, nm ) fnForEach, void* pArgs = 0 )\
337 _ForEach( nS, nE, fnForEach, pArgs );\
340 void _ForEach( USHORT nStt, USHORT nE, \
341 CONCAT( FnForEach_, nm ) fnCall, void* pArgs = 0 );\
344 #define SV_DECL_OBJARR(nm, AE, IS, GS)\
345 _SV_DECL_OBJARR(nm, AE, IS, GS)\
348 nm& operator=( const nm& );\
351 #define SV_IMPL_OBJARR( nm, AE )\
352 nm::nm( USHORT nInit, BYTE )\
359 pData = (AE*)(rtl_allocateMemory(sizeof(AE) * nInit));\
360 DBG_ASSERT( pData, "CTOR, allocate");\
369 for(USHORT n=0; n < nA; n++,pTmp++ )\
373 rtl_freeMemory(pData);\
378 void nm::_resize (size_t n)\
380 USHORT nL = ((n < USHRT_MAX) ? USHORT(n) : USHRT_MAX);\
381 AE* pE = (AE*)(rtl_reallocateMemory (pData, sizeof(AE) * nL));\
382 if ((pE != 0) || (nL == 0))\
389 void nm::Insert( const AE &aE, USHORT nP )\
391 DBG_ASSERT( nP <= nA && nA < USHRT_MAX,"Ins 1");\
393 _resize (nA + ((nA > 1) ? nA : 1));\
394 if( pData && nP < nA )\
395 memmove( pData+nP+1, pData+nP, (nA-nP) * sizeof( AE ));\
396 AE* pTmp = pData+nP;\
397 new( (DummyType*) pTmp ) AE( (AE&)aE );\
401 void nm::Insert( const AE* pE, USHORT nL, USHORT nP )\
403 DBG_ASSERT(nP<=nA && ((long)nA+nL) < USHRT_MAX, "Ins n");\
405 _resize (nA + ((nA > nL) ? nA : nL));\
406 if( pData && nP < nA )\
407 memmove( pData+nP+nL, pData+nP, (nA-nP) * sizeof( AE ));\
410 AE* pTmp = pData+nP;\
411 for( USHORT n = 0; n < nL; n++, pTmp++, pE++)\
413 new( (DummyType*) pTmp ) AE( (AE&)*pE );\
416 nA = nA + nL; nFree = nFree - nL;\
419 void nm::Remove( USHORT nP, USHORT nL )\
423 DBG_ASSERT( nP < nA && nP + nL <= nA,"Del");\
426 for(USHORT n=0; n < nL; n++,pTmp++,nCtr++)\
431 if( pData && nP+1 < nA )\
432 memmove( pData+nP, pData+nP+nL, (nA-nP-nL) * sizeof( AE ));\
433 nA = nA - nL; nFree = nFree + nL;\
438 void nm::_ForEach( USHORT nStt, USHORT nE, \
439 CONCAT( FnForEach_, nm ) fnCall, void* pArgs )\
441 if( nStt >= nE || nE > nA )\
443 for( ; nStt < nE && (*fnCall)( *(pData+nStt), pArgs ); nStt++)\
447 _SVOBJARR_IMPL_GET_OP_INLINE(nm, AE)\
449 #define _SV_DECL_PTRARR_DEF_GEN( nm, AE, IS, GS, AERef, vis )\
450 _SV_DECL_VARARR_GEN( nm, AE, IS, GS, AERef, vis)\
451 USHORT GetPos( const AERef aE ) const;\
454 #define _SV_DECL_PTRARR_DEF( nm, AE, IS, GS, vis )\
455 _SV_DECL_PTRARR_DEF_GEN( nm, AE, IS, GS, AE &, vis )
457 #define SV_DECL_PTRARR_GEN(nm, AE, IS, GS, Base, AERef, VPRef, vis )\
458 typedef BOOL (*FnForEach_##nm)( const AERef, void* );\
459 class vis nm: public Base \
462 nm( USHORT nIni=IS, BYTE nG=GS )\
464 void Insert( const nm *pI, USHORT nP, \
465 USHORT nS = 0, USHORT nE = USHRT_MAX ) {\
466 Base::Insert((const Base*)pI, nP, nS, nE);\
468 void Insert( const AERef aE, USHORT nP ) {\
469 Base::Insert( (const VPRef )aE, nP );\
471 void Insert( const AE *pE, USHORT nL, USHORT nP ) {\
472 Base::Insert( (const VoidPtr*)pE, nL, nP );\
474 void Replace( const AERef aE, USHORT nP ) {\
475 Base::Replace( (const VPRef)aE, nP );\
477 void Replace( const AE *pE, USHORT nL, USHORT nP ) {\
478 Base::Replace( (const VoidPtr*)pE, nL, nP );\
480 void Remove( USHORT nP, USHORT nL = 1) {\
481 Base::Remove(nP,nL);\
483 const AE* GetData() const {\
484 return (const AE*)Base::GetData();\
486 void ForEach( CONCAT( FnForEach_, nm ) fnForEach, void* pArgs = 0 )\
488 _ForEach( 0, nA, (FnForEach_##Base)fnForEach, pArgs );\
490 void ForEach( USHORT nS, USHORT nE, \
491 CONCAT( FnForEach_, nm ) fnForEach, void* pArgs = 0 )\
493 _ForEach( nS, nE, (FnForEach_##Base)fnForEach, pArgs );\
495 AE operator[]( USHORT nP )const { \
496 return (AE)Base::operator[](nP); }\
497 AE GetObject(USHORT nP) const { \
498 return (AE)Base::GetObject(nP); }\
500 USHORT GetPos( const AERef aE ) const { \
501 return Base::GetPos((const VPRef)aE);\
503 void DeleteAndDestroy( USHORT nP, USHORT nL=1 );\
506 nm& operator=( const nm& );\
509 #define SV_DECL_PTRARR(nm, AE, IS, GS )\
510 SV_DECL_PTRARR_GEN(nm, AE, IS, GS, SvPtrarr, AE &, VoidPtr &, )
512 #define SV_DECL_PTRARR_VISIBILITY(nm, AE, IS, GS, vis )\
513 SV_DECL_PTRARR_GEN(nm, AE, IS, GS, SvPtrarr, AE &, VoidPtr &, vis )
515 #define SV_DECL_PTRARR_DEL_GEN(nm, AE, IS, GS, Base, AERef, VPRef, vis )\
516 typedef BOOL (*FnForEach_##nm)( const AERef, void* );\
517 class vis nm: public Base \
520 nm( USHORT nIni=IS, BYTE nG=GS )\
522 ~nm() { DeleteAndDestroy( 0, Count() ); }\
523 void Insert( const nm *pI, USHORT nP, \
524 USHORT nS = 0, USHORT nE = USHRT_MAX ) {\
525 Base::Insert((const Base*)pI, nP, nS, nE);\
527 void Insert( const AERef aE, USHORT nP ) {\
528 Base::Insert((const VPRef)aE, nP );\
530 void Insert( const AE *pE, USHORT nL, USHORT nP ) {\
531 Base::Insert( (const VoidPtr *)pE, nL, nP );\
533 void Replace( const AERef aE, USHORT nP ) {\
534 Base::Replace( (const VPRef)aE, nP );\
536 void Replace( const AE *pE, USHORT nL, USHORT nP ) {\
537 Base::Replace( (const VoidPtr*)pE, nL, nP );\
539 void Remove( USHORT nP, USHORT nL = 1) {\
540 Base::Remove(nP,nL);\
542 const AE* GetData() const {\
543 return (const AE*)Base::GetData();\
545 void ForEach( CONCAT( FnForEach_, nm ) fnForEach, void* pArgs = 0 )\
547 _ForEach( 0, nA, (FnForEach_##Base)fnForEach, pArgs );\
549 void ForEach( USHORT nS, USHORT nE, \
550 CONCAT( FnForEach_, nm ) fnForEach, void* pArgs = 0 )\
552 _ForEach( nS, nE, (FnForEach_##Base)fnForEach, pArgs );\
554 AE operator[]( USHORT nP )const { \
555 return (AE)Base::operator[](nP); }\
556 AE GetObject( USHORT nP )const { \
557 return (AE)Base::GetObject(nP); }\
559 USHORT GetPos( const AERef aE ) const { \
560 return Base::GetPos((const VPRef)aE);\
562 void DeleteAndDestroy( USHORT nP, USHORT nL=1 );\
565 nm& operator=( const nm& );\
568 #define SV_DECL_PTRARR_DEL(nm, AE, IS, GS )\
569 SV_DECL_PTRARR_DEL_GEN(nm, AE, IS, GS, SvPtrarr, AE &, VoidPtr &, )
571 #define SV_DECL_PTRARR_DEL_VISIBILITY(nm, AE, IS, GS, vis )\
572 SV_DECL_PTRARR_DEL_GEN(nm, AE, IS, GS, SvPtrarr, AE &, VoidPtr &, vis)
574 #define SV_IMPL_PTRARR_GEN(nm, AE, Base)\
575 void nm::DeleteAndDestroy( USHORT nP, USHORT nL )\
578 DBG_ASSERT( nP < nA && nP + nL <= nA,"Del");\
579 for( USHORT n=nP; n < nP + nL; n++ ) \
580 delete *((AE*)pData+n); \
581 Base::Remove( nP, nL ); \
585 #define SV_IMPL_PTRARR(nm, AE )\
586 SV_IMPL_PTRARR_GEN(nm, AE, SvPtrarr )
588 typedef void* VoidPtr
;
589 _SV_DECL_PTRARR_DEF( SvPtrarr
, VoidPtr
, 0, 1, )
594 #define __MWERKS__PRIVATE public
596 #define __MWERKS__PRIVATE private
599 #define _SORT_CLASS_DEF(nm, AE, IS, GS, vis)\
600 typedef BOOL (*FnForEach_##nm)( const AE&, void* );\
601 class vis nm : __MWERKS__PRIVATE nm##_SAR \
604 nm(USHORT nSize = IS, BYTE nG = GS)\
605 : nm##_SAR(nSize,nG) {}\
606 void Insert( const nm *pI, USHORT nS=0, USHORT nE=USHRT_MAX );\
607 BOOL Insert( const AE& aE );\
608 BOOL Insert( const AE& aE, USHORT& rP );\
609 void Insert( const AE *pE, USHORT nL );\
610 void Remove( USHORT nP, USHORT nL = 1 );\
611 void Remove( const AE& aE, USHORT nL = 1 );\
612 USHORT Count() const { return nm##_SAR::Count(); }\
613 const AE* GetData() const { return (const AE*)pData; }\
615 /* Das Ende stehe im DECL-Makro !!! */
617 #define _SV_SEEK_PTR(nm,AE)\
618 BOOL nm::Seek_Entry( const AE aE, USHORT* pP ) const\
620 register USHORT nO = nm##_SAR::Count(),\
626 register long rCmp = (long)aE;\
629 nM = nU + ( nO - nU ) / 2;\
630 if( (long)*(pData + nM) == rCmp )\
635 else if( (long)*(pData+ nM) < (long)aE )\
650 #define _SV_SEEK_PTR_TO_OBJECT( nm,AE )\
651 BOOL nm::Seek_Entry( const AE aE, USHORT* pP ) const\
653 register USHORT nO = nm##_SAR::Count(),\
661 nM = nU + ( nO - nU ) / 2;\
662 if( *(*((AE*)pData + nM)) == *(aE) )\
667 else if( *(*((AE*)pData + nM)) < *(aE) )\
682 #define _SV_SEEK_OBJECT( nm,AE )\
683 BOOL nm::Seek_Entry( const AE & aE, USHORT* pP ) const\
685 register USHORT nO = nm##_SAR::Count(),\
693 nM = nU + ( nO - nU ) / 2;\
694 if( *(pData + nM) == aE )\
699 else if( *(pData + nM) < aE )\
714 #define _SV_IMPL_SORTAR_ALG(nm, AE)\
715 void nm::Insert( const nm * pI, USHORT nS, USHORT nE )\
717 if( USHRT_MAX == nE )\
720 const AE * pIArr = pI->GetData();\
721 for( ; nS < nE; ++nS )\
723 if( ! Seek_Entry( *(pIArr+nS), &nP) )\
724 nm##_SAR::Insert( *(pIArr+nS), nP );\
725 if( ++nP >= Count() )\
727 nm##_SAR::Insert( pI, nP, nS+1, nE );\
733 BOOL nm::Insert( const AE & aE )\
737 bExist = Seek_Entry( aE, &nP );\
739 nm##_SAR::Insert( aE, nP );\
742 BOOL nm::Insert( const AE & aE, USHORT& rP )\
745 bExist = Seek_Entry( aE, &rP );\
747 nm##_SAR::Insert( aE, rP );\
750 void nm::Insert( const AE* pE, USHORT nL)\
753 for( USHORT n = 0; n < nL; ++n )\
754 if( ! Seek_Entry( *(pE+n), &nP ))\
755 nm##_SAR::Insert( *(pE+n), nP );\
757 void nm::Remove( USHORT nP, USHORT nL )\
760 nm##_SAR::Remove( nP, nL);\
763 void nm::Remove( const AE &aE, USHORT nL )\
766 if( nL && Seek_Entry( aE, &nP ) ) \
767 nm##_SAR::Remove( nP, nL);\
772 #define _SORTARR_BLC_CASTS(nm, AE )\
773 BOOL Insert( AE &aE ) {\
774 return Insert( (const AE&)aE );\
776 USHORT GetPos( AE& aE ) const { \
777 return SvPtrarr::GetPos((const VoidPtr&)aE);\
779 void Remove( AE& aE, USHORT nL = 1 ) { \
780 Remove( (const AE&) aE, nL );\
785 #define _SORTARR_BLC_CASTS(nm, AE )\
786 USHORT GetPos( const AE& aE ) const { \
787 return SvPtrarr::GetPos((const VoidPtr&)aE);\
792 #define _SV_DECL_PTRARR_SORT_ALG(nm, AE, IS, GS, vis)\
793 SV_DECL_PTRARR_VISIBILITY(nm##_SAR, AE, IS, GS, vis)\
794 _SORT_CLASS_DEF(nm, AE, IS, GS, vis)\
795 AE operator[](USHORT nP) const {\
796 return nm##_SAR::operator[]( nP );\
798 AE GetObject(USHORT nP) const {\
799 return nm##_SAR::GetObject( nP );\
801 BOOL Seek_Entry( const AE aE, USHORT* pP = 0 ) const;\
802 void ForEach( CONCAT( FnForEach_, nm ) fnForEach, void* pArgs = 0 )\
804 _ForEach( 0, nA, (FnForEach_SvPtrarr)fnForEach, pArgs );\
806 void ForEach( USHORT nS, USHORT nE, \
807 CONCAT( FnForEach_, nm ) fnForEach, void* pArgs = 0 )\
809 _ForEach( nS, nE, (FnForEach_SvPtrarr)fnForEach, pArgs );\
811 void DeleteAndDestroy( USHORT nP, USHORT nL=1 ); \
812 _SORTARR_BLC_CASTS(nm, AE )\
814 /* Das Ende stehe im DECL-Makro !!! */
816 #define _SV_DECL_PTRARR_SORT(nm, AE, IS, GS, vis)\
817 _SV_DECL_PTRARR_SORT_ALG(nm, AE, IS, GS, vis)\
820 nm& operator=( const nm& );\
823 #define SV_DECL_PTRARR_SORT(nm, AE, IS, GS)\
824 _SV_DECL_PTRARR_SORT(nm, AE, IS, GS, )
826 #define SV_DECL_PTRARR_SORT_VISIBILITY(nm, AE, IS, GS, vis)\
827 _SV_DECL_PTRARR_SORT(nm, AE, IS, GS, vis)
830 #define _SV_DECL_PTRARR_SORT_DEL(nm, AE, IS, GS, vis)\
831 _SV_DECL_PTRARR_SORT_ALG(nm, AE, IS, GS, vis)\
832 ~nm() { DeleteAndDestroy( 0, Count() ); }\
835 nm& operator=( const nm& );\
838 #define SV_DECL_PTRARR_SORT_DEL(nm, AE, IS, GS)\
839 _SV_DECL_PTRARR_SORT_DEL(nm, AE, IS, GS, )
841 #define SV_DECL_PTRARR_SORT_DEL_VISIBILITY(nm, AE, IS, GS, vis)\
842 _SV_DECL_PTRARR_SORT_DEL(nm, AE, IS, GS, vis)
844 #define _SV_DECL_VARARR_SORT(nm, AE, IS, GS, vis)\
845 SV_DECL_VARARR_VISIBILITY(nm##_SAR, AE, IS, GS, vis)\
846 _SORT_CLASS_DEF(nm, AE, IS, GS, vis) \
847 const AE& operator[](USHORT nP) const {\
848 return nm##_SAR::operator[]( nP );\
850 const AE& GetObject(USHORT nP) const {\
851 return nm##_SAR::GetObject( nP );\
853 BOOL Seek_Entry( const AE & aE, USHORT* pP = 0 ) const;\
854 void ForEach( CONCAT( FnForEach_, nm ) fnForEach, void* pArgs = 0 )\
856 _ForEach( 0, nA, (FnForEach_##nm##_SAR)fnForEach, pArgs );\
858 void ForEach( USHORT nS, USHORT nE, \
859 CONCAT( FnForEach_, nm ) fnForEach, void* pArgs = 0 )\
861 _ForEach( nS, nE, (FnForEach_##nm##_SAR)fnForEach, pArgs );\
865 nm& operator=( const nm& );\
868 #define SV_DECL_VARARR_SORT(nm, AE, IS, GS)\
869 _SV_DECL_VARARR_SORT(nm, AE, IS, GS,)
871 #define SV_DECL_VARARR_SORT_VISIBILITY(nm, AE, IS, GS, vis)\
872 _SV_DECL_VARARR_SORT(nm, AE, IS, GS, vis)
874 #define SV_IMPL_PTRARR_SORT( nm,AE )\
875 _SV_IMPL_SORTAR_ALG( nm,AE )\
876 void nm::DeleteAndDestroy( USHORT nP, USHORT nL ) { \
878 DBG_ASSERT( nP < nA && nP + nL <= nA, "ERR_VAR_DEL" );\
879 for( USHORT n=nP; n < nP + nL; n++ ) \
880 delete *((AE*)pData+n); \
881 SvPtrarr::Remove( nP, nL ); \
884 _SV_SEEK_PTR( nm, AE )
886 #define SV_IMPL_OP_PTRARR_SORT( nm,AE )\
887 _SV_IMPL_SORTAR_ALG( nm,AE )\
888 void nm::DeleteAndDestroy( USHORT nP, USHORT nL ) { \
890 DBG_ASSERT( nP < nA && nP + nL <= nA, "ERR_VAR_DEL" );\
891 for( USHORT n=nP; n < nP + nL; n++ ) \
892 delete *((AE*)pData+n); \
893 SvPtrarr::Remove( nP, nL ); \
896 _SV_SEEK_PTR_TO_OBJECT( nm,AE )
898 #define SV_IMPL_VARARR_SORT( nm,AE )\
899 SV_IMPL_VARARR(nm##_SAR, AE)\
900 _SV_IMPL_SORTAR_ALG( nm,AE )\
901 _SV_SEEK_OBJECT( nm,AE )
903 #define SV_DECL_PTRARR_STACK(nm, AE, IS, GS)\
904 class nm: private SvPtrarr \
907 nm( USHORT nIni=IS, BYTE nG=GS )\
908 : SvPtrarr(nIni,nG) {}\
909 void Insert( const nm *pI, USHORT nP,\
910 USHORT nS = 0, USHORT nE = USHRT_MAX ) {\
911 SvPtrarr::Insert( pI, nP, nS, nE ); \
913 void Remove( USHORT nP, USHORT nL = 1 ) {\
914 SvPtrarr::Remove( nP, nL ); \
916 void Push( const AE &aE ) {\
917 SvPtrarr::Insert( (const VoidPtr &)aE, SvPtrarr::Count() );\
919 USHORT Count() const { return SvPtrarr::Count(); }\
920 AE operator[](USHORT nP) const {\
921 return (AE)SvPtrarr::operator[]( nP );\
923 AE GetObject(USHORT nP) const {\
924 return (AE)SvPtrarr::GetObject( nP );\
928 if( SvPtrarr::Count() ){\
929 pRet = GetObject( SvPtrarr::Count()-1 );\
930 SvPtrarr::Remove(Count()-1);\
936 if( SvPtrarr::Count() )\
937 pRet = GetObject( SvPtrarr::Count()-1 ); \
942 #if defined (C40) || defined (C41) || defined (C42) || defined(C50) || defined(C52)
943 #define C40_INSERT( c, p, n) Insert( (c const *) p, n )
944 #define C40_PUSH( c, p) Push( (c const *) p )
945 #define C40_PTR_INSERT( c, p) Insert( (c const *) p )
946 #define C40_REMOVE( c, p ) Remove( (c const *) p )
947 #define C40_REPLACE( c, p, n) Replace( (c const *) p, n )
948 #define C40_PTR_REPLACE( c, p) Replace( (c const *) p )
949 #define C40_GETPOS( c, r) GetPos( (c const *)r )
951 #if defined WTC || defined IRIX || defined ICC || defined HPUX || (defined GCC && __GNUC__ >= 3) || (defined(WNT) && _MSC_VER >= 1400)
952 #define C40_INSERT( c, p, n ) Insert( (c const *&) p, n )
953 #define C40_PUSH( c, p) Push( (c const *&) p )
954 #define C40_PTR_INSERT( c, p ) Insert( (c const *&) p )
955 #define C40_REMOVE( c, p ) Remove( (c const *&) p )
956 #define C40_REPLACE( c, p, n ) Replace( (c const *&) p, n )
957 #define C40_PTR_REPLACE( c, p ) Replace( (c const *&) p )
958 #define C40_GETPOS( c, r) GetPos( (c const *&) r )
960 #define C40_INSERT( c, p, n ) Insert( p, n )
961 #define C40_PUSH( c, p) Push( p )
962 #define C40_PTR_INSERT( c, p ) Insert( p )
963 #define C40_REMOVE( c, p) Remove( p )
964 #define C40_REPLACE( c, p, n ) Replace( p, n )
965 #define C40_PTR_REPLACE( c, p ) Replace( p )
966 #define C40_GETPOS( c, r) GetPos( r )
972 #endif //_SVARRAY_HXX