PageRenderTime 33ms CodeModel.GetById 29ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/src/wrappers/glib/partially-implemented/iterator_on_g_list_string.e

http://github.com/tybor/Liberty
Specman e | 68 lines | 57 code | 11 blank | 0 comment | 4 complexity | 568d72546b135b8541bbf271a94389e7 MD5 | raw file
 1indexing
 2	description: "Iterator for G_SLIST_STRING."
 3	copyright: "[
 4					Copyright (C) 2006 Paolo Redaelli
 5					
 6					This library is free software; you can redistribute it and/or
 7					modify it under the terms of the GNU Lesser General Public License
 8					as published by the Free Software Foundation; either version 2.1 of
 9					the License, or (at your option) any later version.
10					
11					This library is distributed in the hope that it will be useful, but
12					WITHOUT ANY WARRANTY; without even the implied warranty of
13					MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14					Lesser General Public License for more details.
15
16					You should have received a copy of the GNU Lesser General Public
17					License along with this library; if not, write to the Free Software
18					Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19					02110-1301 USA
20			]"
21
22class ITERATOR_ON_G_LIST_STRING 
23inherit
24	ITERATOR [STRING]
25	WRAPPER_HANDLER
26insert
27	GLIST_EXTERNALS
28	GLIST_STRUCT
29
30creation make
31	
32feature {} -- Creation
33	make (a_list: G_LIST_STRING) is
34		require valid_list: a_list/=Void
35		do
36			list := a_list
37		end
38	
39feature {} -- Implementation
40	list: G_LIST_STRING
41	current_element: POINTER
42
43feature -- Iterator's features
44	start is
45		do
46			current_element := list.handle
47		end
48	
49	is_off: BOOLEAN is
50		do
51			Result:=(current_element.is_null)
52		end
53	
54	item: STRING is
55		local cstr: POINTER
56		do
57			cstr := glist_struct_get_data(current_element)
58			if cstr.is_not_null then 
59				create Result.from_external_copy(cstr)
60			end
61		ensure result_not_void: Result /= Void
62		end
63	
64	next is
65		do
66			current_element := glist_struct_get_next (current_element)
67		end
68end