equal
deleted
inserted
replaced
8 be provided or otherwise made available to, or used by, any |
8 be provided or otherwise made available to, or used by, any |
9 other person. No title to or ownership of the software is |
9 other person. No title to or ownership of the software is |
10 hereby transferred. |
10 hereby transferred. |
11 " |
11 " |
12 |
12 |
13 ArrayedCollection subclass:#VariableString |
13 nil subclass:#VariableString |
14 instanceVariableNames:'contents' |
14 instanceVariableNames:'contents' |
15 classVariableNames:'' |
15 classVariableNames:'' |
16 poolDictionaries:'' |
16 poolDictionaries:'' |
17 category:'Collections-Text' |
17 category:'Collections-Text' |
18 ! |
18 ! |
19 |
19 |
20 !VariableString class methodsFor:'documentation'! |
20 !VariableString class methodsFor:'documentation'! |
21 |
21 |
22 copyright |
22 copyright |
31 other person. No title to or ownership of the software is |
31 other person. No title to or ownership of the software is |
32 hereby transferred. |
32 hereby transferred. |
33 " |
33 " |
34 ! |
34 ! |
35 |
35 |
36 version |
|
37 ^ '$Header: /cvs/stx/stx/libbasic2/VariableString.st,v 1.13 1995-11-11 15:22:01 cg Exp $' |
|
38 ! |
|
39 |
|
40 documentation |
36 documentation |
41 " |
37 " |
42 VariableStrings can grow and shrink - in contrast to Strings which are |
38 VariableStrings can grow and shrink - in contrast to Strings which are |
43 fixed in size - this may change in the future. |
39 fixed in size - this may change in the future. |
44 |
40 |
45 WARNING: This class is a historic leftover and will vanish soon. |
41 WARNING: This class is a historic leftover and will vanish soon. |
46 Dont use it. |
42 Dont use it. |
47 " |
43 " |
|
44 ! |
|
45 |
|
46 version |
|
47 ^ '$Header: /cvs/stx/stx/libbasic2/VariableString.st,v 1.14 1995-11-23 01:22:07 cg Exp $' |
48 ! ! |
48 ! ! |
49 |
49 |
50 !VariableString class methodsFor:'initialization'! |
50 !VariableString class methodsFor:'initialization'! |
51 |
51 |
52 initialize |
52 initialize |
55 self setSuperclass: nil |
55 self setSuperclass: nil |
56 ! ! |
56 ! ! |
57 |
57 |
58 !VariableString class methodsFor:'instance creation'! |
58 !VariableString class methodsFor:'instance creation'! |
59 |
59 |
|
60 copyFrom:aString |
|
61 "return a new VariableString with contents copied from the argument" |
|
62 |
|
63 ^ self basicNew setContents:(String copyFrom:aString) |
|
64 ! |
|
65 |
60 new |
66 new |
61 "return a new VariableString - with size 0" |
67 "return a new VariableString - with size 0" |
62 |
68 |
63 ^ self new:0 |
69 ^ self new:0 |
64 ! |
70 ! |
65 |
71 |
66 new:size |
72 new:size |
67 "return a new VariableString" |
73 "return a new VariableString" |
68 |
74 |
69 ^ (self basicNew) setContents:(String new:size) |
75 ^ (self basicNew) setContents:(String new:size) |
70 ! |
|
71 |
|
72 copyFrom:aString |
|
73 "return a new VariableString with contents copied from the argument" |
|
74 |
|
75 ^ self basicNew setContents:(String copyFrom:aString) |
|
76 ! ! |
76 ! ! |
77 |
77 |
78 !VariableString methodsFor:'accessing'! |
78 !VariableString methodsFor:'accessing'! |
79 |
79 |
80 at:index |
80 at:index |
87 "set the element at index" |
87 "set the element at index" |
88 |
88 |
89 ^ contents at:index put:anObject |
89 ^ contents at:index put:anObject |
90 ! ! |
90 ! ! |
91 |
91 |
92 !VariableString methodsFor:'queries'! |
92 !VariableString methodsFor:'converting'! |
93 |
93 |
94 size |
94 asStringCollection |
95 ^ contents size |
95 ^ contents asStringCollection |
96 ! |
96 ! ! |
97 |
97 |
98 isFixedSize |
98 !VariableString methodsFor:'copying'! |
99 "return true if the receiver cannot grow - this will vanish once |
|
100 Arrays and Strings learn how to grow ..." |
|
101 |
99 |
102 ^ false |
100 postCopy |
|
101 contents := contents copy |
|
102 ! ! |
|
103 |
|
104 !VariableString methodsFor:'error handling'! |
|
105 |
|
106 doesNotUnderstand:aMessage |
|
107 "this is funny: all message we do not understand, are passed |
|
108 on to the string - so we do not have to care for all |
|
109 possible messages ...(thanks to the Message class)" |
|
110 |
|
111 ^ contents perform:(aMessage selector) |
|
112 withArguments:(aMessage arguments) |
103 ! ! |
113 ! ! |
104 |
114 |
105 !VariableString methodsFor:'filling & replacing'! |
115 !VariableString methodsFor:'filling & replacing'! |
106 |
116 |
107 replaceFrom:start to:stop with:aCollection startingAt:repStart |
117 replaceFrom:start to:stop with:aCollection startingAt:repStart |
124 ] |
134 ] |
125 ]. |
135 ]. |
126 ^ super replaceFrom:start to:stop with:aCollection startingAt:repStart |
136 ^ super replaceFrom:start to:stop with:aCollection startingAt:repStart |
127 ! ! |
137 ! ! |
128 |
138 |
129 !VariableString methodsFor:'converting'! |
|
130 |
|
131 asStringCollection |
|
132 ^ contents asStringCollection |
|
133 ! ! |
|
134 |
|
135 !VariableString methodsFor:'copying'! |
|
136 |
|
137 postCopy |
|
138 contents := contents copy |
|
139 ! ! |
|
140 |
|
141 !VariableString methodsFor:'private'! |
|
142 |
|
143 getContents |
|
144 "return the contents array" |
|
145 |
|
146 ^ contents |
|
147 ! |
|
148 |
|
149 setContents:aString |
|
150 "set the contents" |
|
151 |
|
152 contents := aString |
|
153 ! ! |
|
154 |
|
155 !VariableString methodsFor:'error handling'! |
|
156 |
|
157 doesNotUnderstand:aMessage |
|
158 "this is funny: all message we do not understand, are passed |
|
159 on to the string - so we do not have to care for all |
|
160 possible messages ...(thanks to the Message class)" |
|
161 |
|
162 ^ contents perform:(aMessage selector) |
|
163 withArguments:(aMessage arguments) |
|
164 ! ! |
|
165 |
|
166 !VariableString methodsFor:'grow & shrink'! |
139 !VariableString methodsFor:'grow & shrink'! |
167 |
140 |
168 grow:newSize |
141 grow:newSize |
169 |old oldSize| |
142 |old oldSize| |
170 |
143 |
182 contents replaceFrom:1 to:oldSize |
155 contents replaceFrom:1 to:oldSize |
183 with:old startingAt:1 |
156 with:old startingAt:1 |
184 ] |
157 ] |
185 ] |
158 ] |
186 ! ! |
159 ! ! |
|
160 |
|
161 !VariableString methodsFor:'private'! |
|
162 |
|
163 getContents |
|
164 "return the contents array" |
|
165 |
|
166 ^ contents |
|
167 ! |
|
168 |
|
169 setContents:aString |
|
170 "set the contents" |
|
171 |
|
172 contents := aString |
|
173 ! ! |
|
174 |
|
175 !VariableString methodsFor:'queries'! |
|
176 |
|
177 isFixedSize |
|
178 "return true if the receiver cannot grow - this will vanish once |
|
179 Arrays and Strings learn how to grow ..." |
|
180 |
|
181 ^ false |
|
182 ! |
|
183 |
|
184 size |
|
185 ^ contents size |
|
186 ! ! |
|
187 |
|
188 VariableString initialize! |