OOO330
[LibreOffice.git] / soltools / inc / gi_list.hxx
blobad7f8d5e93f8477f7cf13dd8bdeb001d9a4a228d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef SOLTOOLS_GI_LIST_HXX
29 #define SOLTOOLS_GI_LIST_HXX
32 #include "st_list.hxx"
35 class GenericInfo;
37 /** Holds set of generic informations in a sorted list.
39 At different places, methods of this class have a parameter,
40 whose name includes "path". Those are paths like this:
42 src370/drives/o:
44 which are used to access GenericInfo keys in deep search through
45 the lists and their sublists.
47 class List_GenericInfo
49 public:
50 // TYPES
51 class const_iterator
53 public:
54 const GenericInfo & operator*() const;
55 const_iterator & operator++();
56 bool operator==( const const_iterator & ) const;
57 bool operator!=( const const_iterator & ) const;
59 const_iterator();
60 const_iterator( const DynamicList< GenericInfo >::const_iterator & );
61 private: DynamicList< GenericInfo >::const_iterator it;
63 class iterator
64 { public:
65 GenericInfo & operator*() const;
66 iterator & operator++();
67 bool operator==( const iterator & ) const;
68 bool operator!=( const iterator & ) const;
70 iterator();
71 iterator( const DynamicList< GenericInfo >::iterator & );
72 private: DynamicList< GenericInfo >::iterator it;
75 typedef const char * KeyPath;
77 // LIFECYCLE
78 List_GenericInfo();
79 List_GenericInfo(
80 const List_GenericInfo &
81 i_rList );
82 ~List_GenericInfo();
84 // OPERATORS
85 List_GenericInfo & operator=(
86 const List_GenericInfo &
87 i_rList );
88 const GenericInfo * operator[](
89 KeyPath i_sKeyPath ) const;
90 GenericInfo * operator[](
91 KeyPath i_sKeyPath );
93 // OPERATIONS
94 bool InsertInfo(
95 GenericInfo * let_dpInfo, /// Will be owned by this object.
96 bool i_bOverwrite = true );
97 bool InsertInfoByPath(
98 GenericInfo * let_dpInfo, /// Will be owned by this object.
99 KeyPath i_sKeyPath,
100 bool i_bCreatePath,
101 bool i_bOverwrite = true );
103 GenericInfo * ReleaseInfo( /// Removes the GenericInfo from its parent.
104 KeyPath i_sKeyPath );
106 void DeleteInfo(
107 KeyPath i_sKeyPath );
109 // INFO
110 unsigned Size() const;
112 const_iterator Begin() const;
113 const_iterator End() const;
115 // ACCESS
116 iterator Begin();
117 iterator End();
119 private:
120 typedef DynamicList< GenericInfo >::iterator sub_iterator;
122 sub_iterator lower_bound(
123 bool & o_bExists,
124 const char * & o_sNextPathSegment,
125 KeyPath i_sKeyPath );
127 DynamicList< GenericInfo >
128 aChildren;
132 // IMPLEMENTATION
135 inline const GenericInfo &
136 List_GenericInfo::
137 const_iterator::operator*() const
138 { return *(*it); }
140 inline List_GenericInfo::const_iterator &
141 List_GenericInfo::
142 const_iterator::operator++()
143 { ++it; return *this; }
145 inline bool
146 List_GenericInfo::
147 const_iterator::operator==( const const_iterator & i_rIter ) const
148 { return it == i_rIter.it; }
150 inline bool
151 List_GenericInfo::
152 const_iterator::operator!=( const const_iterator & i_rIter ) const
153 { return it != i_rIter.it; }
155 inline List_GenericInfo::
156 const_iterator::const_iterator()
157 : it(0) { }
159 inline List_GenericInfo::
160 const_iterator::const_iterator( const DynamicList< GenericInfo >::const_iterator & i_rDynListIter )
161 : it(i_rDynListIter) { }
164 inline GenericInfo &
165 List_GenericInfo::
166 iterator::operator*() const
167 { return *(*it); }
169 inline List_GenericInfo::iterator &
170 List_GenericInfo::
171 iterator::operator++()
172 { ++it; return *this; }
174 inline bool
175 List_GenericInfo::
176 iterator::operator==( const iterator & i_rIter ) const
177 { return it == i_rIter.it; }
179 inline bool
180 List_GenericInfo::
181 iterator::operator!=( const iterator & i_rIter ) const
182 { return it != i_rIter.it; }
184 inline List_GenericInfo::
185 iterator::iterator()
186 : it(0) { }
188 inline List_GenericInfo::
189 iterator::iterator( const DynamicList< GenericInfo >::iterator & i_rDynListIter )
190 : it(i_rDynListIter) { }
192 inline unsigned
193 List_GenericInfo::Size() const
194 { return aChildren.size(); }
196 inline List_GenericInfo::const_iterator
197 List_GenericInfo::Begin() const
198 { return aChildren.begin(); }
200 inline List_GenericInfo::const_iterator
201 List_GenericInfo::End() const
202 { return aChildren.end(); }
204 inline List_GenericInfo::iterator
205 List_GenericInfo::Begin()
206 { return aChildren.begin(); }
208 inline List_GenericInfo::iterator
209 List_GenericInfo::End()
210 { return aChildren.end(); }
214 #endif