Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / soltools / inc / gi_list.hxx
blob3444235837a5d9bcc744488c46fb2a14dab713b9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef SOLTOOLS_GI_LIST_HXX
30 #define SOLTOOLS_GI_LIST_HXX
33 #include "st_list.hxx"
36 class GenericInfo;
38 /** Holds set of generic informations in a sorted list.
40 At different places, methods of this class have a parameter,
41 whose name includes "path". Those are paths like this:
43 src370/drives/o:
45 which are used to access GenericInfo keys in deep search through
46 the lists and their sublists.
48 class List_GenericInfo
50 public:
51 // TYPES
52 class const_iterator
54 public:
55 const GenericInfo & operator*() const;
56 const_iterator & operator++();
57 bool operator==( const const_iterator & ) const;
58 bool operator!=( const const_iterator & ) const;
60 const_iterator();
61 const_iterator( const DynamicList< GenericInfo >::const_iterator & );
62 private: DynamicList< GenericInfo >::const_iterator it;
64 class iterator
65 { public:
66 GenericInfo & operator*() const;
67 iterator & operator++();
68 bool operator==( const iterator & ) const;
69 bool operator!=( const iterator & ) const;
71 iterator();
72 iterator( const DynamicList< GenericInfo >::iterator & );
73 private: DynamicList< GenericInfo >::iterator it;
76 typedef const char * KeyPath;
78 // LIFECYCLE
79 List_GenericInfo();
80 List_GenericInfo(
81 const List_GenericInfo &
82 i_rList );
83 ~List_GenericInfo();
85 // OPERATORS
86 List_GenericInfo & operator=(
87 const List_GenericInfo &
88 i_rList );
89 const GenericInfo * operator[](
90 KeyPath i_sKeyPath ) const;
91 GenericInfo * operator[](
92 KeyPath i_sKeyPath );
94 // OPERATIONS
95 bool InsertInfo(
96 GenericInfo * let_dpInfo, /// Will be owned by this object.
97 bool i_bOverwrite = true );
98 bool InsertInfoByPath(
99 GenericInfo * let_dpInfo, /// Will be owned by this object.
100 KeyPath i_sKeyPath,
101 bool i_bCreatePath,
102 bool i_bOverwrite = true );
104 GenericInfo * ReleaseInfo( /// Removes the GenericInfo from its parent.
105 KeyPath i_sKeyPath );
107 void DeleteInfo(
108 KeyPath i_sKeyPath );
110 // INFO
111 unsigned Size() const;
113 const_iterator Begin() const;
114 const_iterator End() const;
116 // ACCESS
117 iterator Begin();
118 iterator End();
120 private:
121 typedef DynamicList< GenericInfo >::iterator sub_iterator;
123 sub_iterator lower_bound(
124 bool & o_bExists,
125 const char * & o_sNextPathSegment,
126 KeyPath i_sKeyPath );
128 DynamicList< GenericInfo >
129 aChildren;
133 // IMPLEMENTATION
136 inline const GenericInfo &
137 List_GenericInfo::
138 const_iterator::operator*() const
139 { return *(*it); }
141 inline List_GenericInfo::const_iterator &
142 List_GenericInfo::
143 const_iterator::operator++()
144 { ++it; return *this; }
146 inline bool
147 List_GenericInfo::
148 const_iterator::operator==( const const_iterator & i_rIter ) const
149 { return it == i_rIter.it; }
151 inline bool
152 List_GenericInfo::
153 const_iterator::operator!=( const const_iterator & i_rIter ) const
154 { return it != i_rIter.it; }
156 inline List_GenericInfo::
157 const_iterator::const_iterator()
158 : it(0) { }
160 inline List_GenericInfo::
161 const_iterator::const_iterator( const DynamicList< GenericInfo >::const_iterator & i_rDynListIter )
162 : it(i_rDynListIter) { }
165 inline GenericInfo &
166 List_GenericInfo::
167 iterator::operator*() const
168 { return *(*it); }
170 inline List_GenericInfo::iterator &
171 List_GenericInfo::
172 iterator::operator++()
173 { ++it; return *this; }
175 inline bool
176 List_GenericInfo::
177 iterator::operator==( const iterator & i_rIter ) const
178 { return it == i_rIter.it; }
180 inline bool
181 List_GenericInfo::
182 iterator::operator!=( const iterator & i_rIter ) const
183 { return it != i_rIter.it; }
185 inline List_GenericInfo::
186 iterator::iterator()
187 : it(0) { }
189 inline List_GenericInfo::
190 iterator::iterator( const DynamicList< GenericInfo >::iterator & i_rDynListIter )
191 : it(i_rDynListIter) { }
193 inline unsigned
194 List_GenericInfo::Size() const
195 { return aChildren.size(); }
197 inline List_GenericInfo::const_iterator
198 List_GenericInfo::Begin() const
199 { return aChildren.begin(); }
201 inline List_GenericInfo::const_iterator
202 List_GenericInfo::End() const
203 { return aChildren.end(); }
205 inline List_GenericInfo::iterator
206 List_GenericInfo::Begin()
207 { return aChildren.begin(); }
209 inline List_GenericInfo::iterator
210 List_GenericInfo::End()
211 { return aChildren.end(); }
215 #endif
217 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */