merge the formfield patch from ooo-build
[ooovba.git] / sw / qa / core / bigpointerarray-new.hxx
blob51a769beb22bf6b3b99f8fb6e5bf0901adb45895
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: bigpointerarray-new.hxx,v $
10 * $Revision: 1.3 $
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 ************************************************************************/
31 #ifndef _BPARR_HXX
32 #define _BPARR_HXX
34 #include <tools/solar.h>
35 #include <tools/debug.hxx>
37 #include <deque>
39 class BigPtrArray;
41 /** Base class for container entries
43 class BigPtrEntry
45 friend class BigPtrArray;
46 BigPtrArray* pBigPtrArray_;
47 ULONG pos_;
49 protected:
50 BigPtrEntry() : pBigPtrArray_(0), pos_(0)
53 virtual ~BigPtrEntry()
56 ULONG GetPos() const
58 return pos_;
61 BigPtrArray& GetArray() const
63 return *pBigPtrArray_;
67 typedef BigPtrEntry* ElementPtr;
68 typedef BOOL (*FnForEach)(const ElementPtr&, void* pArgs);
70 /** A container abstraction
72 class BigPtrArray
74 public:
75 typedef std::deque<ElementPtr> Container_t;
77 public:
78 /**
80 BigPtrArray();
82 /** Return the number of entries inserted
83 into the array
85 ULONG Count() const;
87 /** Insert an Element into the array at a certain
88 position
90 @param rElem
91 [in] the element
93 @param pos
94 [in] the position where to insert the element.
96 @pre (pos >= 0 && pos <= BigPtrArray.Count())
97 @post (((oldCount + 1) == BigPtrArray.Count()) && BigPtrArray[pos] == rElem)
99 void Insert(const ElementPtr& rElem, ULONG pos);
101 /** Remove a specified number of elements starting at a certain position.
103 @param pos
104 [in] the position where to start removing elements
106 @param n
107 [in] the number of elements to remove
109 @pre (pos < BigPtrArray.Count() && n <= BigPtrArray.Count())
110 @post ((oldCount - n) == BigPtrArray.Count())
112 void Remove(ULONG pos, ULONG n = 1);
114 /** Move an entry from a certain position to another on.
116 @param from
117 [in]
119 @param to
120 [in]
122 void Move(ULONG fromPos, ULONG toPos);
124 /** Replace an entry at a certain position
126 @param pos
127 [in] the position of the entry
129 @param rElem
130 [in] the new entry
132 @pre pos < BigPtrArray.Count()
133 @post (oldCount == BigPtrArray.Count() && BigPtrArray[pos] == rElem)
135 void Replace(ULONG pos, const ElementPtr& rElem);
137 /** Get the entry at a certain index
139 @param pos
140 [in] the position of the entry
142 @pre pos < BigPtrArray.Count()
144 ElementPtr operator[](ULONG pos) const;
146 /**
148 void ForEach(FnForEach fn, void* pArgs = NULL);
152 void ForEach(ULONG fromPos, ULONG toPos, FnForEach fn, void* pArgs = NULL);
154 private:
156 void FixElementIndizes(Container_t::const_iterator begin, Container_t::const_iterator end) const;
158 private:
159 Container_t container_;
162 #endif