xref: /aoo41x/main/autodoc/source/ary/inc/sci_impl.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
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.
14  *
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).
20  *
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.
25  *
26  ************************************************************************/
27 
28 #ifndef ARY_SCI_IMPL_HXX
29 #define ARY_SCI_IMPL_HXX
30 
31 
32 
33 // USED SERVICES
34     // BASE CLASSES
35 #include <ary/stdconstiter.hxx>
36     // COMPONENTS
37     // PARAMETERS
38 
39 
40 namespace ary
41 {
42 
43 
44 //*************************     SCI_Vector      **********************************//
45 
46 template <class ELEM>
47 class SCI_Vector : public StdConstIterator<ELEM>
48 {
49   public:
50     typedef std::vector<ELEM>       source;
51     typedef typename source::const_iterator source_iterator;
52 
53                         SCI_Vector(
54                             const source &      i_rSource  );
55     virtual             ~SCI_Vector();
56 
57   private:
58     // Interface StdConstIterator<>:
59     virtual void        do_Advance();
60     virtual const ELEM *
61                         inq_CurElement() const;
62     virtual bool        inq_IsSorted() const;
63 
64     // DATA
65     source_iterator     itRun;
66     source_iterator     itEnd;
67 };
68 
69 
70 
71 //*************************     SCI_Map      **********************************//
72 
73 template <class KEY, class VALUE>
74 class SCI_Map : public StdConstIterator< typename std::map<KEY,VALUE>::value_type >
75 {
76   public:
77     typedef std::map<KEY,VALUE>     source;
78     typedef typename source::const_iterator source_iterator;
79 
80                         SCI_Map(
81                             const source &      i_rSource  );
82     virtual             ~SCI_Map();
83 
84   private:
85     // Interface StdConstIterator<>:
86     virtual void        do_Advance();
87     virtual const typename std::map<KEY,VALUE>::value_type *
88                         inq_CurElement() const;
89     virtual bool        inq_IsSorted() const;
90 
91     // DATA
92     source_iterator     itRun;
93     source_iterator     itEnd;
94 };
95 
96 
97 //*************************     SCI_MultiMap      **********************************//
98 
99 template <class KEY, class VALUE>
100 class SCI_MultiMap : public StdConstIterator< typename std::multimap<KEY,VALUE>::value_type >
101 {
102   public:
103     typedef std::multimap<KEY,VALUE>    source;
104     typedef typename source::const_iterator      source_iterator;
105 
106                         SCI_MultiMap(
107                             const source &      i_rSource  );
108                         SCI_MultiMap(
109                             source_iterator     i_begin,
110                             source_iterator     i_end );
111     virtual             ~SCI_MultiMap();
112 
113   private:
114     // Interface StdConstIterator<>:
115     virtual void        do_Advance();
116     virtual const typename std::multimap<KEY,VALUE>::value_type *
117                         inq_CurElement() const;
118     virtual bool        inq_IsSorted() const;
119 
120     // DATA
121     source_iterator     itRun;
122     source_iterator     itEnd;
123 };
124 
125 
126 
127 //*************************     SCI_Set     **********************************//
128 
129 
130 template <class TYPES>
131 class SCI_Set : public StdConstIterator<typename TYPES::element_type>
132 {
133   public:
134     typedef typename TYPES::element_type    element;
135     typedef typename TYPES::sort_type       sorter;
136     typedef std::set<element, sorter>       source;
137     typedef typename source::const_iterator source_iterator;
138 
139                         SCI_Set(
140                             const source &      i_rSource  );
141     virtual             ~SCI_Set();
142 
143   private:
144     // Interface StdConstIterator<>:
145     virtual void        do_Advance();
146     virtual const element *
147                         inq_CurElement() const;
148     virtual bool        inq_IsSorted() const;
149 
150     // DATA
151     source_iterator     itRun;
152     source_iterator     itEnd;
153 };
154 
155 //*************************     SCI_DataInMap    **********************************//
156 
157 template <class KEY, class VALUE>
158 class SCI_DataInMap : public StdConstIterator<VALUE>
159 {
160   public:
161     typedef std::map<KEY,VALUE>     source;
162     typedef typename source::const_iterator  source_iterator;
163 
164                         SCI_DataInMap(
165                             const source &      i_rSource  );
166     virtual             ~SCI_DataInMap();
167 
168   private:
169     // Interface StdConstIterator<>:
170     virtual void        do_Advance();
171     virtual const VALUE *
172                         inq_CurElement() const;
173     virtual bool        inq_IsSorted() const;
174 
175     // DATA
176     source_iterator     itRun;
177     source_iterator     itEnd;
178 };
179 
180 
181 
182 
183 
184 //********************************************************************//
185 
186 
187 // IMPLEMENTATION
188 
189 template <class ELEM>
190 SCI_Vector<ELEM>::SCI_Vector( const source & i_rSource  )
191     :   itRun(i_rSource.begin()),
192         itEnd(i_rSource.end())
193 {
194 }
195 
196 template <class ELEM>
197 SCI_Vector<ELEM>::~SCI_Vector()
198 {
199 }
200 
201 
202 template <class ELEM>
203 void
204 SCI_Vector<ELEM>::do_Advance()
205 {
206     if (itRun != itEnd)
207         ++itRun;
208 }
209 
210 template <class ELEM>
211 const ELEM *
212 SCI_Vector<ELEM>::inq_CurElement() const
213 {
214     if (itRun != itEnd)
215         return &(*itRun);
216     return 0;
217 }
218 
219 template <class ELEM>
220 bool
221 SCI_Vector<ELEM>::inq_IsSorted() const
222 {
223     return false;
224 }
225 
226 
227 
228 
229 template <class KEY, class VALUE>
230 SCI_Map<KEY,VALUE>::SCI_Map( const source & i_rSource  )
231     :   itRun(i_rSource.begin()),
232         itEnd(i_rSource.end())
233 {
234 }
235 
236 template <class KEY, class VALUE>
237 SCI_Map<KEY,VALUE>::~SCI_Map()
238 {
239 }
240 
241 template <class KEY, class VALUE>
242 void
243 SCI_Map<KEY,VALUE>::do_Advance()
244 {
245     if (itRun != itEnd)
246         ++itRun;
247 }
248 
249 template <class KEY, class VALUE>
250 const typename std::map<KEY,VALUE>::value_type *
251 SCI_Map<KEY,VALUE>::inq_CurElement() const
252 {
253     if (itRun != itEnd)
254         return &(*itRun);
255     return 0;
256 }
257 
258 
259 template <class KEY, class VALUE>
260 bool
261 SCI_Map<KEY,VALUE>::inq_IsSorted() const
262 {
263     return true;
264 }
265 
266 
267 
268 
269 
270 
271 
272 template <class KEY, class VALUE>
273 SCI_MultiMap<KEY,VALUE>::SCI_MultiMap( const source & i_rSource  )
274     :   itRun(i_rSource.begin()),
275         itEnd(i_rSource.end())
276 {
277 }
278 
279 template <class KEY, class VALUE>
280 SCI_MultiMap<KEY,VALUE>::SCI_MultiMap( source_iterator i_begin,
281                                        source_iterator i_end )
282     :   itRun(i_begin),
283         itEnd(i_end)
284 {
285 }
286 
287 template <class KEY, class VALUE>
288 SCI_MultiMap<KEY,VALUE>::~SCI_MultiMap()
289 {
290 }
291 
292 template <class KEY, class VALUE>
293 void
294 SCI_MultiMap<KEY,VALUE>::do_Advance()
295 {
296     if (itRun != itEnd)
297         ++itRun;
298 }
299 
300 template <class KEY, class VALUE>
301 const typename std::multimap<KEY,VALUE>::value_type *
302 SCI_MultiMap<KEY,VALUE>::inq_CurElement() const
303 {
304     if (itRun != itEnd)
305         return &(*itRun);
306     return 0;
307 }
308 
309 
310 template <class KEY, class VALUE>
311 bool
312 SCI_MultiMap<KEY,VALUE>::inq_IsSorted() const
313 {
314     return true;
315 }
316 
317 
318 
319 
320 
321 
322 
323 
324 template <class ELEM>
325 SCI_Set<ELEM>::SCI_Set( const source & i_rSource  )
326     :   itRun(i_rSource.begin()),
327         itEnd(i_rSource.end())
328 {
329 }
330 
331 template <class ELEM>
332 SCI_Set<ELEM>::~SCI_Set()
333 {
334 }
335 
336 
337 template <class ELEM>
338 void
339 SCI_Set<ELEM>::do_Advance()
340 {
341     if (itRun != itEnd)
342         ++itRun;
343 }
344 
345 template <class ELEM>
346 const typename SCI_Set<ELEM>::element *
347 SCI_Set<ELEM>::inq_CurElement() const
348 {
349     if (itRun != itEnd)
350         return &(*itRun);
351     return 0;
352 }
353 
354 template <class ELEM>
355 bool
356 SCI_Set<ELEM>::inq_IsSorted() const
357 {
358     return true;
359 }
360 
361 
362 
363 
364 
365 
366 
367 template <class KEY, class VALUE>
368 SCI_DataInMap<KEY,VALUE>::SCI_DataInMap( const source & i_rSource  )
369     :   itRun(i_rSource.begin()),
370         itEnd(i_rSource.end())
371 {
372 }
373 
374 template <class KEY, class VALUE>
375 SCI_DataInMap<KEY,VALUE>::~SCI_DataInMap()
376 {
377 }
378 
379 template <class KEY, class VALUE>
380 void
381 SCI_DataInMap<KEY,VALUE>::do_Advance()
382 {
383     if (itRun != itEnd)
384         ++itRun;
385 }
386 
387 template <class KEY, class VALUE>
388 const VALUE *
389 SCI_DataInMap<KEY,VALUE>::inq_CurElement() const
390 {
391     if (itRun != itEnd)
392         return &(*itRun).second;
393     return 0;
394 }
395 
396 
397 template <class KEY, class VALUE>
398 bool
399 SCI_DataInMap<KEY,VALUE>::inq_IsSorted() const
400 {
401     return true;
402 }
403 
404 
405 
406 
407 
408 
409 
410 }   // namespace ary
411 
412 
413 #endif
414