merge the formfield patch from ooo-build
[ooovba.git] / autodoc / source / ary / inc / sci_impl.hxx
bloba62ae81bc113dca03e56ec977ad6a8b24a567762
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: sci_impl.hxx,v $
10 * $Revision: 1.5 $
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 ARY_SCI_IMPL_HXX
32 #define ARY_SCI_IMPL_HXX
36 // USED SERVICES
37 // BASE CLASSES
38 #include <ary/stdconstiter.hxx>
39 // COMPONENTS
40 // PARAMETERS
43 namespace ary
47 //************************* SCI_Vector **********************************//
49 template <class ELEM>
50 class SCI_Vector : public StdConstIterator<ELEM>
52 public:
53 typedef std::vector<ELEM> source;
54 typedef typename source::const_iterator source_iterator;
56 SCI_Vector(
57 const source & i_rSource );
58 virtual ~SCI_Vector();
60 private:
61 // Interface StdConstIterator<>:
62 virtual void do_Advance();
63 virtual const ELEM *
64 inq_CurElement() const;
65 virtual bool inq_IsSorted() const;
67 // DATA
68 source_iterator itRun;
69 source_iterator itEnd;
74 //************************* SCI_Map **********************************//
76 template <class KEY, class VALUE>
77 class SCI_Map : public StdConstIterator< typename std::map<KEY,VALUE>::value_type >
79 public:
80 typedef std::map<KEY,VALUE> source;
81 typedef typename source::const_iterator source_iterator;
83 SCI_Map(
84 const source & i_rSource );
85 virtual ~SCI_Map();
87 private:
88 // Interface StdConstIterator<>:
89 virtual void do_Advance();
90 virtual const typename std::map<KEY,VALUE>::value_type *
91 inq_CurElement() const;
92 virtual bool inq_IsSorted() const;
94 // DATA
95 source_iterator itRun;
96 source_iterator itEnd;
100 //************************* SCI_MultiMap **********************************//
102 template <class KEY, class VALUE>
103 class SCI_MultiMap : public StdConstIterator< typename std::multimap<KEY,VALUE>::value_type >
105 public:
106 typedef std::multimap<KEY,VALUE> source;
107 typedef typename source::const_iterator source_iterator;
109 SCI_MultiMap(
110 const source & i_rSource );
111 SCI_MultiMap(
112 source_iterator i_begin,
113 source_iterator i_end );
114 virtual ~SCI_MultiMap();
116 private:
117 // Interface StdConstIterator<>:
118 virtual void do_Advance();
119 virtual const typename std::multimap<KEY,VALUE>::value_type *
120 inq_CurElement() const;
121 virtual bool inq_IsSorted() const;
123 // DATA
124 source_iterator itRun;
125 source_iterator itEnd;
130 //************************* SCI_Set **********************************//
133 template <class TYPES>
134 class SCI_Set : public StdConstIterator<typename TYPES::element_type>
136 public:
137 typedef typename TYPES::element_type element;
138 typedef typename TYPES::sort_type sorter;
139 typedef std::set<element, sorter> source;
140 typedef typename source::const_iterator source_iterator;
142 SCI_Set(
143 const source & i_rSource );
144 virtual ~SCI_Set();
146 private:
147 // Interface StdConstIterator<>:
148 virtual void do_Advance();
149 virtual const element *
150 inq_CurElement() const;
151 virtual bool inq_IsSorted() const;
153 // DATA
154 source_iterator itRun;
155 source_iterator itEnd;
158 //************************* SCI_DataInMap **********************************//
160 template <class KEY, class VALUE>
161 class SCI_DataInMap : public StdConstIterator<VALUE>
163 public:
164 typedef std::map<KEY,VALUE> source;
165 typedef typename source::const_iterator source_iterator;
167 SCI_DataInMap(
168 const source & i_rSource );
169 virtual ~SCI_DataInMap();
171 private:
172 // Interface StdConstIterator<>:
173 virtual void do_Advance();
174 virtual const VALUE *
175 inq_CurElement() const;
176 virtual bool inq_IsSorted() const;
178 // DATA
179 source_iterator itRun;
180 source_iterator itEnd;
187 //********************************************************************//
190 // IMPLEMENTATION
192 template <class ELEM>
193 SCI_Vector<ELEM>::SCI_Vector( const source & i_rSource )
194 : itRun(i_rSource.begin()),
195 itEnd(i_rSource.end())
199 template <class ELEM>
200 SCI_Vector<ELEM>::~SCI_Vector()
205 template <class ELEM>
206 void
207 SCI_Vector<ELEM>::do_Advance()
209 if (itRun != itEnd)
210 ++itRun;
213 template <class ELEM>
214 const ELEM *
215 SCI_Vector<ELEM>::inq_CurElement() const
217 if (itRun != itEnd)
218 return &(*itRun);
219 return 0;
222 template <class ELEM>
223 bool
224 SCI_Vector<ELEM>::inq_IsSorted() const
226 return false;
232 template <class KEY, class VALUE>
233 SCI_Map<KEY,VALUE>::SCI_Map( const source & i_rSource )
234 : itRun(i_rSource.begin()),
235 itEnd(i_rSource.end())
239 template <class KEY, class VALUE>
240 SCI_Map<KEY,VALUE>::~SCI_Map()
244 template <class KEY, class VALUE>
245 void
246 SCI_Map<KEY,VALUE>::do_Advance()
248 if (itRun != itEnd)
249 ++itRun;
252 template <class KEY, class VALUE>
253 const typename std::map<KEY,VALUE>::value_type *
254 SCI_Map<KEY,VALUE>::inq_CurElement() const
256 if (itRun != itEnd)
257 return &(*itRun);
258 return 0;
262 template <class KEY, class VALUE>
263 bool
264 SCI_Map<KEY,VALUE>::inq_IsSorted() const
266 return true;
275 template <class KEY, class VALUE>
276 SCI_MultiMap<KEY,VALUE>::SCI_MultiMap( const source & i_rSource )
277 : itRun(i_rSource.begin()),
278 itEnd(i_rSource.end())
282 template <class KEY, class VALUE>
283 SCI_MultiMap<KEY,VALUE>::SCI_MultiMap( source_iterator i_begin,
284 source_iterator i_end )
285 : itRun(i_begin),
286 itEnd(i_end)
290 template <class KEY, class VALUE>
291 SCI_MultiMap<KEY,VALUE>::~SCI_MultiMap()
295 template <class KEY, class VALUE>
296 void
297 SCI_MultiMap<KEY,VALUE>::do_Advance()
299 if (itRun != itEnd)
300 ++itRun;
303 template <class KEY, class VALUE>
304 const typename std::multimap<KEY,VALUE>::value_type *
305 SCI_MultiMap<KEY,VALUE>::inq_CurElement() const
307 if (itRun != itEnd)
308 return &(*itRun);
309 return 0;
313 template <class KEY, class VALUE>
314 bool
315 SCI_MultiMap<KEY,VALUE>::inq_IsSorted() const
317 return true;
327 template <class ELEM>
328 SCI_Set<ELEM>::SCI_Set( const source & i_rSource )
329 : itRun(i_rSource.begin()),
330 itEnd(i_rSource.end())
334 template <class ELEM>
335 SCI_Set<ELEM>::~SCI_Set()
340 template <class ELEM>
341 void
342 SCI_Set<ELEM>::do_Advance()
344 if (itRun != itEnd)
345 ++itRun;
348 template <class ELEM>
349 const typename SCI_Set<ELEM>::element *
350 SCI_Set<ELEM>::inq_CurElement() const
352 if (itRun != itEnd)
353 return &(*itRun);
354 return 0;
357 template <class ELEM>
358 bool
359 SCI_Set<ELEM>::inq_IsSorted() const
361 return true;
370 template <class KEY, class VALUE>
371 SCI_DataInMap<KEY,VALUE>::SCI_DataInMap( const source & i_rSource )
372 : itRun(i_rSource.begin()),
373 itEnd(i_rSource.end())
377 template <class KEY, class VALUE>
378 SCI_DataInMap<KEY,VALUE>::~SCI_DataInMap()
382 template <class KEY, class VALUE>
383 void
384 SCI_DataInMap<KEY,VALUE>::do_Advance()
386 if (itRun != itEnd)
387 ++itRun;
390 template <class KEY, class VALUE>
391 const VALUE *
392 SCI_DataInMap<KEY,VALUE>::inq_CurElement() const
394 if (itRun != itEnd)
395 return &(*itRun).second;
396 return 0;
400 template <class KEY, class VALUE>
401 bool
402 SCI_DataInMap<KEY,VALUE>::inq_IsSorted() const
404 return true;
413 } // namespace ary
416 #endif