/[eiffelstudio]/FreeELKS/trunk/library/support/class_name_translations.e
ViewVC logotype

Contents of /FreeELKS/trunk/library/support/class_name_translations.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 91469 - (show annotations)
Tue Feb 21 14:54:50 2006 UTC (13 years, 11 months ago) by ericb
File size: 4267 byte(s)
Synchronized with ISE 5.7.0414.
Implemented BOOL_STRING in pure Eiffel.

1 indexing
2
3 description: "[
4 Translations of class names between a storing and a retrieving
5 system. Values in this table are names of classes in the retrieving
6 system, indexed by names of generating classes in the storing
7 system (i.e. with no generic arguments). Values may have generic
8 arguments (e.g. "MY_CLASS [DOUBLE]"), thus allowing a very simple
9 conversion of a non-generic class into a generic class. The
10 presence of entries in this table affects all retrieve operations
11 for objects stored using `independent_store'.
12 ]"
13 library: "Free implementation of ELKS library"
14 copyright: "Copyright (c) 2005, Eiffel Software and others"
15 license: "Eiffel Forum License v2 (see forum.txt)"
16 date: "$Date$"
17 revision: "$Revision$"
18
19 class CLASS_NAME_TRANSLATIONS
20
21 inherit
22
23 HASH_TABLE [STRING, STRING]
24 export
25 {NONE} replace_key, remove
26 redefine
27 default_create,
28 put, force, extend, replace,
29 clear_all,
30 out
31 end
32
33 create
34
35 default_create
36
37 feature -- Initialization
38
39 default_create is
40 -- Make table with current translations
41 local
42 i, cnt: INTEGER
43 o, n: STRING
44 do
45 cnt := class_translation_count
46 make (cnt)
47 from i := 0 until i = cnt loop
48 create o.make_from_c (class_translation_old (i))
49 create n.make_from_c (class_translation_new (i))
50 put (n, o)
51 i := i + 1
52 end
53 end
54
55 feature -- Element change
56
57 put (new: STRING; key: STRING) is
58 -- Insert `new' with `key' if there is no other item
59 -- associated with the same key.
60 -- Set `inserted' if and only if an insertion has
61 -- been made (i.e. `key' was not present).
62 -- If so, set `position' to the insertion position.
63 -- If not, set `conflict'.
64 -- In either case, set `found_item' to the item
65 -- now associated with `key' (previous item if
66 -- there was one, `new' otherwise).
67 do
68 Precursor (new, key)
69 if inserted then add_translation (new, key) end
70 end
71
72 force (new: STRING; key: STRING) is
73 -- Update table so that `new' will be the item associated
74 -- with `key'.
75 -- If there was an item for that key, set `found'
76 -- and set `found_item' to that item.
77 -- If there was none, set `not_found' and set
78 -- `found_item' to the default value.
79 do
80 Precursor (new, key)
81 add_translation (new, key)
82 end
83
84 extend (new: STRING; key: STRING) is
85 -- Assuming there is no item of key `key',
86 -- insert `new' with `key'.
87 -- Set `inserted'.
88 do
89 Precursor (new, key)
90 add_translation (new, key)
91 end
92
93 replace (new: STRING; key: STRING) is
94 -- Replace item at `key', if present,
95 -- with `new'; do not change associated key.
96 -- Set `replaced' if and only if a replacement has been made
97 -- (i.e. `key' was present); otherwise set `not_found'.
98 -- Set `found_item' to the item previously associated
99 -- with `key' (default value if there was none).
100 do
101 if has (key) then
102 Precursor (new, key)
103 add_translation (new, key)
104 end
105 end
106
107 feature -- Removal
108
109 clear_all is
110 -- Reset all items to default values; reset status.
111 do
112 Precursor
113 class_translation_clear
114 end
115
116 feature -- Output
117
118 out: STRING is
119 -- Printable representation of translations
120 do
121 from
122 create Result.make (25 + count * 40)
123 Result.append ("Class name translations:%N")
124 start
125 until
126 after
127 loop
128 Result.append (key_for_iteration)
129 Result.append (" -> ")
130 Result.append (item_for_iteration)
131 Result.append_character ('%N')
132 forth
133 end
134 end
135
136 feature {NONE} -- Implementation
137
138 add_translation (new_name, old_name: STRING) is
139 -- Add a translation entry mapping class `old_name' in the
140 -- storing system to class `new_name' in the retrieving system.
141 local
142 n, o: ANY
143 do
144 n := new_name.to_c
145 o := old_name.to_c
146 class_translation_put ($n, $o)
147 end
148
149 feature {NONE} -- Externals
150
151 class_translation_put (new_name, old_name: POINTER) is
152 external
153 "C use %"eif_retrieve.h%""
154 end
155
156 class_translation_clear is
157 external
158 "C use %"eif_retrieve.h%""
159 end
160
161 class_translation_count: INTEGER is
162 external
163 "C use %"eif_retrieve.h%""
164 end
165
166 class_translation_old (i: INTEGER): POINTER is
167 external
168 "C use %"eif_retrieve.h%""
169 end
170
171 class_translation_new (i: INTEGER): POINTER is
172 external
173 "C use %"eif_retrieve.h%""
174 end
175
176 end

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23