7fd59977 |
1 | -- File: TCollection_ExtendedString.cdl |
2 | -- Created: Mon Feb 22 16:58:21 1993 |
3 | -- Author: Mireille MERCIEN |
4 | -- <mip@sdsun4> |
5 | ---Copyright: Matra Datavision 1993 |
6 | |
7 | class ExtendedString from TCollection |
8 | ---Purpose: A variable-length sequence of "extended" |
9 | -- (UNICODE) characters (16-bit character type). It |
10 | -- provides editing operations with built-in memory |
11 | -- management to make ExtendedString objects |
12 | -- easier to use than ordinary extended character arrays. |
13 | -- ExtendedString objects follow "value |
14 | -- semantics", that is, they are the actual strings, |
15 | -- not handles to strings, and are copied through |
16 | -- assignment. You may use HExtendedString |
17 | -- objects to get handles to strings. |
18 | |
19 | uses AsciiString from TCollection |
20 | |
21 | raises |
22 | NullObject, |
23 | OutOfRange, |
24 | NumericError, |
25 | NegativeValue |
26 | |
27 | is |
28 | Create returns ExtendedString from TCollection; |
29 | ---Purpose: Initializes a ExtendedString to an empty ExtendedString. |
30 | |
31 | Create( astring : CString; isMultiByte : Boolean = Standard_False) |
32 | returns ExtendedString from TCollection |
33 | raises NullObject; |
34 | ---Purpose: Creation by converting a CString to an extended string. |
35 | |
36 | Create( astring : ExtString) |
37 | returns ExtendedString from TCollection |
38 | raises NullObject; |
39 | ---Purpose: Creation by converting an ExtString to an extended string. |
40 | |
41 | Create ( aChar : Character) returns ExtendedString from TCollection; |
42 | ---Purpose: Initializes a AsciiString with a single character. |
43 | |
44 | Create ( aChar : ExtCharacter) returns ExtendedString from TCollection; |
45 | ---Purpose: Initializes a ExtendedString with a single character. |
46 | |
47 | Create ( length : Integer; filler : ExtCharacter) |
48 | returns ExtendedString from TCollection; |
49 | ---Purpose: Initializes a ExtendedString with <length> space allocated. |
50 | -- and filled with <filler>.This is useful for buffers. |
51 | |
52 | Create ( value : Integer ) returns ExtendedString from TCollection |
53 | ---Purpose: Initializes an ExtendedString with an integer value |
54 | raises NullObject; |
55 | |
56 | Create ( value : Real ) returns ExtendedString from TCollection |
57 | ---Purpose: Initializes an ExtendedString with a real value |
58 | raises NullObject; |
59 | |
60 | Create ( astring : ExtendedString from TCollection ) |
61 | returns ExtendedString from TCollection; |
62 | ---Purpose: Initializes a ExtendedString with another ExtendedString. |
63 | |
64 | Create( astring : AsciiString from TCollection) |
65 | returns ExtendedString from TCollection; |
66 | ---Purpose: Creation by converting a normal Ascii string to an extended string. |
67 | |
68 | AssignCat (me : out ; other : ExtendedString from TCollection) |
69 | is static; |
70 | ---Purpose: Appends the other extended string to this extended string. |
71 | -- Note that this method is an alias of operator +=. |
72 | -- Example: aString += anotherString |
73 | ---C++: alias operator += |
74 | |
75 | Cat (me ; other : ExtendedString from TCollection) |
76 | returns ExtendedString from TCollection |
77 | is static; |
78 | ---Level: Public |
79 | ---Purpose: Appends <other> to me. |
80 | ---Example: aString = aString + anotherString |
81 | ---C++: alias operator + |
82 | |
83 | ChangeAll(me : out; aChar, NewChar : ExtCharacter) |
84 | is static; |
85 | ---Level: Public |
86 | ---Purpose: Substitutes all the characters equal to aChar by NewChar |
87 | -- in the ExtendedString <me>. |
88 | -- The substitution can be case sensitive. |
89 | -- If you don't use default case sensitive, no matter wether aChar |
90 | -- is uppercase or not. |
91 | ---Example: |
92 | -- me = "Histake" -> ChangeAll('H','M',Standard_True) |
93 | -- gives me = "Mistake" |
94 | |
95 | Clear (me : out) |
96 | is static; |
97 | ---Level: Public |
98 | ---Purpose: Removes all characters contained in <me>. |
99 | -- This produces an empty ExtendedString. |
100 | |
101 | Copy (me : out ; fromwhere : ExtendedString from TCollection) |
102 | is static; |
103 | ---Level: Public |
104 | ---Purpose: Copy <fromwhere> to <me>. |
105 | -- Used as operator = |
106 | ---Example: aString = anotherString; |
107 | ---C++: alias operator = |
108 | |
109 | Destroy (me : in out) |
110 | is static; |
111 | ---Level: Public |
112 | ---Purpose: Frees memory allocated by ExtendedString. |
113 | ---C++: alias ~ |
114 | |
115 | Insert (me : out; where : Integer; what : ExtCharacter) |
116 | ---Level: Public |
117 | ---Purpose: Insert a Character at position <where>. |
118 | ---Example: |
119 | -- aString contains "hy not ?" |
120 | -- aString.Insert(1,'W'); gives "Why not ?" |
121 | -- aString contains "Wh" |
122 | -- aString.Insert(3,'y'); gives "Why" |
123 | -- aString contains "Way" |
124 | -- aString.Insert(2,'h'); gives "Why" |
125 | raises OutOfRange from Standard |
126 | is static; |
127 | |
128 | Insert (me : out; where : Integer; what : ExtendedString from TCollection) |
129 | ---Level: Public |
130 | ---Purpose: Insert a ExtendedString at position <where>. |
131 | raises OutOfRange from Standard |
132 | is static; |
133 | |
134 | IsEqual (me ; other : ExtString ) |
135 | returns Boolean from Standard |
136 | is static; |
137 | ---Level: Public |
138 | ---Purpose: Returns true if the characters in this extended |
139 | -- string are identical to the characters in the other extended string. |
140 | -- Note that this method is an alias of operator == |
141 | ---C++: alias operator == |
142 | |
143 | IsEqual (me ; other : ExtendedString from TCollection) |
144 | returns Boolean from Standard |
145 | is static; |
146 | ---Purpose: Returns true if the characters in this extended |
147 | -- string are identical to the characters in the other extended string. |
148 | -- Note that this method is an alias of operator == |
149 | ---C++: alias operator == |
150 | |
151 | IsDifferent (me ; other : ExtString ) |
152 | returns Boolean from Standard |
153 | is static; |
154 | ---Purpose: Returns true if there are differences between the |
155 | -- characters in this extended string and the other extended string. |
156 | -- Note that this method is an alias of operator !=. |
157 | ---C++: alias operator != |
158 | |
159 | IsDifferent (me ; other : ExtendedString from TCollection) |
160 | returns Boolean from Standard |
161 | is static; |
162 | ---Purpose: Returns true if there are differences between the |
163 | -- characters in this extended string and the other extended string. |
164 | -- Note that this method is an alias of operator !=. |
165 | ---C++: alias operator != |
166 | |
167 | IsLess (me ; other : ExtString ) |
168 | returns Boolean from Standard |
169 | is static; |
170 | ---Level: Public |
171 | ---Purpose: Returns TRUE if <me> is less than <other>. |
172 | ---C++: alias operator < |
173 | |
174 | IsLess (me ; other : ExtendedString from TCollection) |
175 | returns Boolean from Standard |
176 | is static; |
177 | ---Level: Public |
178 | ---Purpose: Returns TRUE if <me> is less than <other>. |
179 | ---C++: alias operator < |
180 | |
181 | IsGreater (me ; other : ExtString ) |
182 | returns Boolean from Standard |
183 | is static; |
184 | ---Level: Public |
185 | ---Purpose: Returns TRUE if <me> is greater than <other>. |
186 | ---C++: alias operator > |
187 | |
188 | IsGreater (me ; other : ExtendedString from TCollection) |
189 | returns Boolean from Standard |
190 | is static; |
191 | ---Level: Public |
192 | ---Purpose: Returns TRUE if <me> is greater than <other>. |
193 | ---C++: alias operator > |
194 | |
195 | IsAscii(me) |
196 | returns Boolean from Standard |
197 | is static; |
198 | ---Level: Public |
199 | ---Purpose: Returns True if the ExtendedString contains only |
200 | -- "Ascii Range" characters . |
201 | |
202 | Length (me) returns Integer from Standard |
203 | is static; |
204 | ---Level: Public |
205 | ---Purpose: Returns number of characters in <me>. |
206 | -- This is the same functionality as 'strlen' in C. |
207 | |
208 | Print (me ; astream : out OStream) |
209 | is static; |
210 | ---Level: Public |
211 | ---Purpose: Displays <me> . |
212 | ---C++: alias "friend Standard_EXPORT Standard_OStream& operator << (Standard_OStream& astream,const TCollection_ExtendedString& astring);" |
213 | |
214 | RemoveAll(me : out; what : ExtCharacter) |
215 | is static; |
216 | ---Level: Public |
217 | ---Purpose: Removes every <what> characters from <me>. |
218 | |
219 | Remove (me : out ; where : Integer ; ahowmany : Integer=1) |
220 | ---Level: Public |
221 | ---Purpose: Erases <ahowmany> characters from position <where>,<where> included. |
222 | ---Example: |
223 | -- aString contains "Hello" |
224 | -- aString.Erase(2,2) erases 2 characters from position 1 |
225 | -- This gives "Hlo". |
226 | raises OutOfRange from Standard |
227 | is static; |
228 | |
229 | |
230 | Search (me ; what : ExtendedString from TCollection) |
231 | returns Integer from Standard |
232 | is static; |
233 | ---Level: Public |
234 | ---Purpose: Searches a ExtendedString in <me> from the beginning |
235 | -- and returns position of first item <what> matching. |
236 | -- it returns -1 if not found. |
237 | |
238 | SearchFromEnd (me ; what : ExtendedString from TCollection) |
239 | returns Integer from Standard |
240 | is static; |
241 | ---Level: Public |
242 | ---Purpose: Searches a ExtendedString in another ExtendedString from the |
243 | -- end and returns position of first item <what> matching. |
244 | -- it returns -1 if not found. |
245 | |
246 | SetValue(me : out; where : Integer; what : ExtCharacter) |
247 | ---Level: Public |
248 | ---Purpose: Replaces one character in the ExtendedString at position <where>. |
249 | -- If <where> is less than zero or greater than the length of <me> |
250 | -- an exception is raised. |
251 | ---Example: |
252 | -- aString contains "Garbake" |
253 | -- astring.Replace(6,'g') gives <me> = "Garbage" |
254 | raises OutOfRange from Standard |
255 | is static; |
256 | |
257 | SetValue(me : out; where : Integer; what : ExtendedString from TCollection) |
258 | ---Level: Public |
259 | ---Purpose: Replaces a part of <me> by another ExtendedString see above. |
260 | raises OutOfRange from Standard |
261 | is static; |
262 | |
263 | Split(me : out; where : Integer) returns ExtendedString from TCollection |
264 | ---Purpose: Splits this extended string into two sub-strings at position where. |
265 | -- - The second sub-string (from position |
266 | -- where + 1 of this string to the end) is |
267 | -- returned in a new extended string. |
268 | -- - this extended string is modified: its last |
269 | -- characters are removed, it becomes equal to |
270 | -- the first sub-string (from the first character to position where). |
271 | -- Example: |
272 | -- aString contains "abcdefg" |
273 | -- aString.Split(3) gives <me> = "abc" and returns "defg" |
274 | raises OutOfRange from Standard |
275 | is static; |
276 | |
277 | Token (me ; separators : ExtString; whichone : Integer=1) |
278 | returns ExtendedString from TCollection |
279 | ---Purpose: Extracts <whichone> token from <me>. |
280 | -- By default, the <separators> is set to space and tabulation. |
281 | -- By default, the token extracted is the first one (whichone = 1). |
282 | -- <separators> contains all separators you need. |
283 | -- If no token indexed by <whichone> is found, it returns an empty AsciiString. |
284 | -- Example: |
285 | -- aString contains "This is a message" |
286 | -- aString.Token() returns "This" |
287 | -- aString.Token(" ",4) returns "message" |
288 | -- aString.Token(" ",2) returns "is" |
289 | -- aString.Token(" ",9) returns "" |
290 | -- Other separators than space character and tabulation are allowed : |
291 | -- aString contains "1234; test:message , value" |
292 | -- aString.Token("; :,",4) returns "value" |
293 | -- aString.Token("; :,",2) returns "test" |
294 | raises NullObject from Standard |
295 | is static; |
296 | |
297 | ToExtString(me) returns ExtString |
298 | ---Level: Public |
299 | ---Purpose: Returns pointer to ExtString |
300 | ---C++: return const |
301 | is static; |
302 | |
303 | Trunc (me : out ; ahowmany : Integer) |
304 | ---Purpose: Truncates <me> to <ahowmany> characters. |
305 | -- Example: me = "Hello Dolly" -> Trunc(3) -> me = "Hel" |
306 | -- Exceptions |
307 | -- Standard_OutOfRange if ahowmany is greater |
308 | -- than the length of this string. |
309 | raises OutOfRange from Standard |
310 | is static; |
311 | |
312 | Value(me ; where : Integer) returns ExtCharacter |
313 | ---Purpose: Returns character at position <where> in <me>. |
314 | -- If <where> is less than zero or greater than the lenght of |
315 | -- <me>, an exception is raised. |
316 | -- Example: |
317 | -- aString contains "Hello" |
318 | -- aString.Value(2) returns 'e' |
319 | -- Exceptions |
320 | -- Standard_OutOfRange if where lies outside |
321 | -- the bounds of this extended string. |
322 | raises OutOfRange from Standard |
323 | is static; |
324 | |
325 | HashCode(myclass ; astring : ExtendedString from TCollection; Upper : Integer) |
326 | returns Integer; |
327 | ---Purpose: Returns a hashed value for the extended string |
328 | -- astring within the range 1..Upper. |
329 | -- Note: if astring is ASCII, the computed value is |
330 | -- the same as the value computed with the HashCode function on a |
331 | -- TCollection_AsciiString string composed with equivalent ASCII characters |
332 | |
333 | IsEqual(myclass ; string1 : ExtendedString from TCollection; |
334 | string2 : ExtendedString from TCollection) |
335 | returns Boolean; |
336 | ---Purpose: Returns true if the characters in this extended |
337 | -- string are identical to the characters in the other extended string. |
338 | -- Note that this method is an alias of operator ==. |
339 | |
340 | ToUTF8CString(me; theCString : out PCharacter from Standard) |
341 | returns Integer from Standard; |
342 | ---Purpose: Converts the internal <mystring> to UTF8 coding and |
343 | -- returns length of the out CString. A memory for the |
344 | -- <theCString> should be allocated before call! |
345 | |
346 | LengthOfCString(me) |
347 | returns Integer from Standard; |
348 | ---Purpose: Returns expected CString length in UTF8 coding. |
349 | -- It can be used for memory calculation before converting |
350 | -- to CString containing symbols in UTF8 coding. |
351 | |
352 | ConvertToUnicode(me : out; astring : CString) |
353 | returns Boolean is private; |
354 | ---Purpose: Returns true if the input CString was successfuly converted |
355 | -- to UTF8 coding |
356 | fields |
357 | mystring : PExtCharacter from Standard; |
358 | mylength : Integer from Standard; |
359 | |
360 | |
361 | end ExtendedString from TCollection; |
362 | |
363 | |