PageRenderTime 13ms CodeModel.GetById 7ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/src/wrappers/glib/examples/key_file_example.e

http://github.com/tybor/Liberty
Specman e | 44 lines | 37 code | 7 blank | 0 comment | 1 complexity | 7dc25f8d9a929b5c8d7449c0bf78203e MD5 | raw file
 1class KEY_FILE_EXAMPLE
 2insert
 3	FILE_TOOLS rename file_exists as obsolete_file_exists end
 4	G_KEY_FILE_FLAGS
 5
 6creation make
 7feature
 8	make is
 9		local
10			group, key: STRING
11			groups_iterator, keys_iterator: ITERATOR[STRING]
12		do
13			if is_readable(file) then
14				create keyfile.load_from_file
15				(file, g_key_file_keep_comments | g_key_file_keep_translations)
16			else
17				create keyfile.make
18			end
19
20			groups_iterator := keyfile.groups.get_new_iterator
21			from groups_iterator.start until groups_iterator.is_off loop
22				group:=groups_iterator.item
23				std_output.put_string(group_label)
24				std_output.put_string(group); std_output.put_new_line
25				
26				keys_iterator:=keyfile.keys_of(group).get_new_iterator
27				from keys_iterator.start until keys_iterator.is_off loop
28					key:=keys_iterator.item
29					std_output.put_string(key) ':'.print_on(std_output)
30					std_output.put_string(keyfile.value(group,key))
31					std_output.put_new_line
32					keys_iterator.next
33				end
34				
35				groups_iterator.next
36			end
37		end
38
39	
40	keyfile: G_KEY_FILE
41
42	file: STRING is "test.ini"
43	group_label: STRING is "Group: "
44end