Update ooo320-m1
[ooovba.git] / soltools / inc / gi_list.hxx
blob3d27493cbb7f79a5447331e3208082a837870d04
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: gi_list.hxx,v $
10 * $Revision: 1.4 $
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 SOLTOOLS_GI_LIST_HXX
32 #define SOLTOOLS_GI_LIST_HXX
35 #include "st_list.hxx"
38 class GenericInfo;
40 /** Holds set of generic informations in a sorted list.
42 At different places, methods of this class have a parameter,
43 whose name includes "path". Those are paths like this:
45 src370/drives/o:
47 which are used to access GenericInfo keys in deep search through
48 the lists and their sublists.
50 class List_GenericInfo
52 public:
53 // TYPES
54 class const_iterator
56 public:
57 const GenericInfo & operator*() const;
58 const_iterator & operator++();
59 bool operator==( const const_iterator & ) const;
60 bool operator!=( const const_iterator & ) const;
62 const_iterator();
63 const_iterator( const DynamicList< GenericInfo >::const_iterator & );
64 private: DynamicList< GenericInfo >::const_iterator it;
66 class iterator
67 { public:
68 GenericInfo & operator*() const;
69 iterator & operator++();
70 bool operator==( const iterator & ) const;
71 bool operator!=( const iterator & ) const;
73 iterator();
74 iterator( const DynamicList< GenericInfo >::iterator & );
75 private: DynamicList< GenericInfo >::iterator it;
78 typedef const char * KeyPath;
80 // LIFECYCLE
81 List_GenericInfo();
82 List_GenericInfo(
83 const List_GenericInfo &
84 i_rList );
85 ~List_GenericInfo();
87 // OPERATORS
88 List_GenericInfo & operator=(
89 const List_GenericInfo &
90 i_rList );
91 const GenericInfo * operator[](
92 KeyPath i_sKeyPath ) const;
93 GenericInfo * operator[](
94 KeyPath i_sKeyPath );
96 // OPERATIONS
97 bool InsertInfo(
98 GenericInfo * let_dpInfo, /// Will be owned by this object.
99 bool i_bOverwrite = true );
100 bool InsertInfoByPath(
101 GenericInfo * let_dpInfo, /// Will be owned by this object.
102 KeyPath i_sKeyPath,
103 bool i_bCreatePath,
104 bool i_bOverwrite = true );
106 GenericInfo * ReleaseInfo( /// Removes the GenericInfo from its parent.
107 KeyPath i_sKeyPath );
109 void DeleteInfo(
110 KeyPath i_sKeyPath );
112 // INFO
113 unsigned Size() const;
115 const_iterator Begin() const;
116 const_iterator End() const;
118 // ACCESS
119 iterator Begin();
120 iterator End();
122 private:
123 typedef DynamicList< GenericInfo >::iterator sub_iterator;
125 sub_iterator lower_bound(
126 bool & o_bExists,
127 const char * & o_sNextPathSegment,
128 KeyPath i_sKeyPath );
130 DynamicList< GenericInfo >
131 aChildren;
135 // IMPLEMENTATION
138 inline const GenericInfo &
139 List_GenericInfo::
140 const_iterator::operator*() const
141 { return *(*it); }
143 inline List_GenericInfo::const_iterator &
144 List_GenericInfo::
145 const_iterator::operator++()
146 { ++it; return *this; }
148 inline bool
149 List_GenericInfo::
150 const_iterator::operator==( const const_iterator & i_rIter ) const
151 { return it == i_rIter.it; }
153 inline bool
154 List_GenericInfo::
155 const_iterator::operator!=( const const_iterator & i_rIter ) const
156 { return it != i_rIter.it; }
158 inline List_GenericInfo::
159 const_iterator::const_iterator()
160 : it(0) { }
162 inline List_GenericInfo::
163 const_iterator::const_iterator( const DynamicList< GenericInfo >::const_iterator & i_rDynListIter )
164 : it(i_rDynListIter) { }
167 inline GenericInfo &
168 List_GenericInfo::
169 iterator::operator*() const
170 { return *(*it); }
172 inline List_GenericInfo::iterator &
173 List_GenericInfo::
174 iterator::operator++()
175 { ++it; return *this; }
177 inline bool
178 List_GenericInfo::
179 iterator::operator==( const iterator & i_rIter ) const
180 { return it == i_rIter.it; }
182 inline bool
183 List_GenericInfo::
184 iterator::operator!=( const iterator & i_rIter ) const
185 { return it != i_rIter.it; }
187 inline List_GenericInfo::
188 iterator::iterator()
189 : it(0) { }
191 inline List_GenericInfo::
192 iterator::iterator( const DynamicList< GenericInfo >::iterator & i_rDynListIter )
193 : it(i_rDynListIter) { }
195 inline unsigned
196 List_GenericInfo::Size() const
197 { return aChildren.size(); }
199 inline List_GenericInfo::const_iterator
200 List_GenericInfo::Begin() const
201 { return aChildren.begin(); }
203 inline List_GenericInfo::const_iterator
204 List_GenericInfo::End() const
205 { return aChildren.end(); }
207 inline List_GenericInfo::iterator
208 List_GenericInfo::Begin()
209 { return aChildren.begin(); }
211 inline List_GenericInfo::iterator
212 List_GenericInfo::End()
213 { return aChildren.end(); }
217 #endif