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