2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 // $XConsortium: collectionIterator.cc /main/4 1996/06/11 17:28:28 cde-hal $
25 #include "oliasdb/collectionIterator.h"
26 #include "oliasdb/olias_consts.h"
27 #include "oliasdb/node_hd.h"
28 #include "oliasdb/stylesheet_hd.h"
29 #include "oliasdb/graphic_hd.h"
30 #include "oliasdb/locator_hd.h"
32 collectionIterator::collectionIterator(info_base* base, int position) :
33 f_set_ptr(base -> get_set(position)), f_base(base), f_index(-1)
36 throw(stringException("can't find set"));
39 collectionIterator::~collectionIterator()
43 unsigned int collectionIterator::operator++()
45 if ( f_index == -1 ) {
50 if ( f_index == -2 ) {
51 MESSAGE(cerr, "can't advance iterator any more");
55 if ( (*f_set_ptr) -> count() - 1 == f_index ) {
64 oid_t collectionIterator::get_oid(int index)
66 c_index_handler* x = (*f_set_ptr) -> get_index_ptr(index);
69 throw(stringException("bad internal index"));
71 return (*x) -> first_of_invlist(f_index);
74 nodeCollectionIterator::nodeCollectionIterator(info_base* base) :
75 collectionIterator(base, NODE_SET_POS)
79 nodeCollectionIterator::~nodeCollectionIterator()
83 const char* nodeCollectionIterator::get_locator()
85 oid_t id = get_oid(1);
86 node_smart_ptr node(f_base, id);
87 return node.locator();
90 stylesheetCollectionIterator::stylesheetCollectionIterator(info_base* base) :
91 collectionIterator(base, STYLESHEET_SET_POS)
95 stylesheetCollectionIterator::~stylesheetCollectionIterator()
100 const char* stylesheetCollectionIterator::get_locator()
102 oid_t id = get_oid(1);
103 stylesheet_smart_ptr ss(f_base, id);
107 graphicCollectionIterator::graphicCollectionIterator(info_base* base) :
108 collectionIterator(base, GRAPHIC_SET_POS)
112 graphicCollectionIterator::~graphicCollectionIterator()
117 const char* graphicCollectionIterator::get_locator()
119 oid_t id = get_oid(1);
120 graphic_smart_ptr gr(f_base, id);
124 locatorCollectionIterator::locatorCollectionIterator(info_base* base) :
125 collectionIterator(base, LOCATOR_SET_POS)
129 locatorCollectionIterator::~locatorCollectionIterator()
134 const char* locatorCollectionIterator::get_locator()
136 oid_t id = get_oid(1);
137 locator_smart_ptr lc(f_base, id);
138 return lc.inside_node_locator_str();