1 -- Created on: 1993-02-22
2 -- Created by: Mireille MERCIEN
3 -- Copyright (c) 1993-1999 Matra Datavision
4 -- Copyright (c) 1999-2014 OPEN CASCADE SAS
6 -- This file is part of Open CASCADE Technology software library.
8 -- This library is free software; you can redistribute it and/or modify it under
9 -- the terms of the GNU Lesser General Public License version 2.1 as published
10 -- by the Free Software Foundation, with special exception defined in the file
11 -- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 -- distribution for complete text of the license and disclaimer of any warranty.
14 -- Alternatively, this file may be used under the terms of Open CASCADE
15 -- commercial license or contractual agreement.
17 class ExtendedString from TCollection
18 ---Purpose: A variable-length sequence of "extended"
19 -- (UNICODE) characters (16-bit character type). It
20 -- provides editing operations with built-in memory
21 -- management to make ExtendedString objects
22 -- easier to use than ordinary extended character arrays.
23 -- ExtendedString objects follow "value
24 -- semantics", that is, they are the actual strings,
25 -- not handles to strings, and are copied through
26 -- assignment. You may use HExtendedString
27 -- objects to get handles to strings.
29 uses AsciiString from TCollection
38 Create returns ExtendedString from TCollection;
39 ---Purpose: Initializes a ExtendedString to an empty ExtendedString.
41 Create( astring : CString; isMultiByte : Boolean = Standard_False)
42 returns ExtendedString from TCollection
44 ---Purpose: Creation by converting a CString to an extended
45 -- string. If <isMultiByte> is true then the string is
46 -- treated as having UTF-8 coding. If it is not a UTF-8
47 -- then <isMultiByte> is ignored and each character is
48 -- copied to ExtCharacter.
51 Create( astring : ExtString)
52 returns ExtendedString from TCollection
54 ---Purpose: Creation by converting an ExtString to an extended string.
56 Create ( aChar : Character) returns ExtendedString from TCollection;
57 ---Purpose: Initializes a AsciiString with a single character.
59 Create ( aChar : ExtCharacter) returns ExtendedString from TCollection;
60 ---Purpose: Initializes a ExtendedString with a single character.
62 Create ( length : Integer; filler : ExtCharacter)
63 returns ExtendedString from TCollection;
64 ---Purpose: Initializes a ExtendedString with <length> space allocated.
65 -- and filled with <filler>.This is useful for buffers.
67 Create ( value : Integer ) returns ExtendedString from TCollection
68 ---Purpose: Initializes an ExtendedString with an integer value
71 Create ( value : Real ) returns ExtendedString from TCollection
72 ---Purpose: Initializes an ExtendedString with a real value
75 Create ( astring : ExtendedString from TCollection )
76 returns ExtendedString from TCollection;
77 ---Purpose: Initializes a ExtendedString with another ExtendedString.
79 Create( astring : AsciiString from TCollection)
80 returns ExtendedString from TCollection;
81 ---Purpose: Creation by converting an Ascii string to an extended
82 -- string. The string is treated as having UTF-8 coding.
83 -- If it is not a UTF-8 then each character is copied to ExtCharacter.
85 AssignCat (me : out ; other : ExtendedString from TCollection)
87 ---Purpose: Appends the other extended string to this extended string.
88 -- Note that this method is an alias of operator +=.
89 -- Example: aString += anotherString
90 ---C++: alias operator +=
92 Cat (me ; other : ExtendedString from TCollection)
93 returns ExtendedString from TCollection
96 ---Purpose: Appends <other> to me.
97 ---Example: aString = aString + anotherString
98 ---C++: alias operator +
100 ChangeAll(me : out; aChar, NewChar : ExtCharacter)
103 ---Purpose: Substitutes all the characters equal to aChar by NewChar
104 -- in the ExtendedString <me>.
105 -- The substitution can be case sensitive.
106 -- If you don't use default case sensitive, no matter wether aChar
107 -- is uppercase or not.
109 -- me = "Histake" -> ChangeAll('H','M',Standard_True)
110 -- gives me = "Mistake"
115 ---Purpose: Removes all characters contained in <me>.
116 -- This produces an empty ExtendedString.
118 Copy (me : out ; fromwhere : ExtendedString from TCollection)
121 ---Purpose: Copy <fromwhere> to <me>.
122 -- Used as operator =
123 ---Example: aString = anotherString;
124 ---C++: alias operator =
126 Destroy (me : in out)
129 ---Purpose: Frees memory allocated by ExtendedString.
132 Insert (me : out; where : Integer; what : ExtCharacter)
134 ---Purpose: Insert a Character at position <where>.
136 -- aString contains "hy not ?"
137 -- aString.Insert(1,'W'); gives "Why not ?"
138 -- aString contains "Wh"
139 -- aString.Insert(3,'y'); gives "Why"
140 -- aString contains "Way"
141 -- aString.Insert(2,'h'); gives "Why"
142 raises OutOfRange from Standard
145 Insert (me : out; where : Integer; what : ExtendedString from TCollection)
147 ---Purpose: Insert a ExtendedString at position <where>.
148 raises OutOfRange from Standard
151 IsEmpty(me) returns Boolean from Standard
155 ---Purpose: Returns True if this string contains no characters.
157 IsEqual (me ; other : ExtString )
158 returns Boolean from Standard
161 ---Purpose: Returns true if the characters in this extended
162 -- string are identical to the characters in the other extended string.
163 -- Note that this method is an alias of operator ==
164 ---C++: alias operator ==
166 IsEqual (me ; other : ExtendedString from TCollection)
167 returns Boolean from Standard
169 ---Purpose: Returns true if the characters in this extended
170 -- string are identical to the characters in the other extended string.
171 -- Note that this method is an alias of operator ==
172 ---C++: alias operator ==
174 IsDifferent (me ; other : ExtString )
175 returns Boolean from Standard
177 ---Purpose: Returns true if there are differences between the
178 -- characters in this extended string and the other extended string.
179 -- Note that this method is an alias of operator !=.
180 ---C++: alias operator !=
182 IsDifferent (me ; other : ExtendedString from TCollection)
183 returns Boolean from Standard
185 ---Purpose: Returns true if there are differences between the
186 -- characters in this extended string and the other extended string.
187 -- Note that this method is an alias of operator !=.
188 ---C++: alias operator !=
190 IsLess (me ; other : ExtString )
191 returns Boolean from Standard
194 ---Purpose: Returns TRUE if <me> is less than <other>.
195 ---C++: alias operator <
197 IsLess (me ; other : ExtendedString from TCollection)
198 returns Boolean from Standard
201 ---Purpose: Returns TRUE if <me> is less than <other>.
202 ---C++: alias operator <
204 IsGreater (me ; other : ExtString )
205 returns Boolean from Standard
208 ---Purpose: Returns TRUE if <me> is greater than <other>.
209 ---C++: alias operator >
211 IsGreater (me ; other : ExtendedString from TCollection)
212 returns Boolean from Standard
215 ---Purpose: Returns TRUE if <me> is greater than <other>.
216 ---C++: alias operator >
219 returns Boolean from Standard
222 ---Purpose: Returns True if the ExtendedString contains only
223 -- "Ascii Range" characters .
225 Length (me) returns Integer from Standard
228 ---Purpose: Returns number of characters in <me>.
229 -- This is the same functionality as 'strlen' in C.
231 Print (me ; astream : out OStream)
234 ---Purpose: Displays <me> .
235 ---C++: alias "friend Standard_EXPORT Standard_OStream& operator << (Standard_OStream& astream,const TCollection_ExtendedString& astring);"
237 RemoveAll(me : out; what : ExtCharacter)
240 ---Purpose: Removes every <what> characters from <me>.
242 Remove (me : out ; where : Integer ; ahowmany : Integer=1)
244 ---Purpose: Erases <ahowmany> characters from position <where>,<where> included.
246 -- aString contains "Hello"
247 -- aString.Erase(2,2) erases 2 characters from position 1
249 raises OutOfRange from Standard
253 Search (me ; what : ExtendedString from TCollection)
254 returns Integer from Standard
257 ---Purpose: Searches a ExtendedString in <me> from the beginning
258 -- and returns position of first item <what> matching.
259 -- it returns -1 if not found.
261 SearchFromEnd (me ; what : ExtendedString from TCollection)
262 returns Integer from Standard
265 ---Purpose: Searches a ExtendedString in another ExtendedString from the
266 -- end and returns position of first item <what> matching.
267 -- it returns -1 if not found.
269 SetValue(me : out; where : Integer; what : ExtCharacter)
271 ---Purpose: Replaces one character in the ExtendedString at position <where>.
272 -- If <where> is less than zero or greater than the length of <me>
273 -- an exception is raised.
275 -- aString contains "Garbake"
276 -- astring.Replace(6,'g') gives <me> = "Garbage"
277 raises OutOfRange from Standard
280 SetValue(me : out; where : Integer; what : ExtendedString from TCollection)
282 ---Purpose: Replaces a part of <me> by another ExtendedString see above.
283 raises OutOfRange from Standard
286 Split(me : out; where : Integer) returns ExtendedString from TCollection
287 ---Purpose: Splits this extended string into two sub-strings at position where.
288 -- - The second sub-string (from position
289 -- where + 1 of this string to the end) is
290 -- returned in a new extended string.
291 -- - this extended string is modified: its last
292 -- characters are removed, it becomes equal to
293 -- the first sub-string (from the first character to position where).
295 -- aString contains "abcdefg"
296 -- aString.Split(3) gives <me> = "abc" and returns "defg"
297 raises OutOfRange from Standard
300 Token (me ; separators : ExtString; whichone : Integer=1)
301 returns ExtendedString from TCollection
302 ---Purpose: Extracts <whichone> token from <me>.
303 -- By default, the <separators> is set to space and tabulation.
304 -- By default, the token extracted is the first one (whichone = 1).
305 -- <separators> contains all separators you need.
306 -- If no token indexed by <whichone> is found, it returns an empty AsciiString.
308 -- aString contains "This is a message"
309 -- aString.Token() returns "This"
310 -- aString.Token(" ",4) returns "message"
311 -- aString.Token(" ",2) returns "is"
312 -- aString.Token(" ",9) returns ""
313 -- Other separators than space character and tabulation are allowed :
314 -- aString contains "1234; test:message , value"
315 -- aString.Token("; :,",4) returns "value"
316 -- aString.Token("; :,",2) returns "test"
317 raises NullObject from Standard
320 ToExtString(me) returns ExtString
322 ---Purpose: Returns pointer to ExtString
326 Trunc (me : out ; ahowmany : Integer)
327 ---Purpose: Truncates <me> to <ahowmany> characters.
328 -- Example: me = "Hello Dolly" -> Trunc(3) -> me = "Hel"
330 -- Standard_OutOfRange if ahowmany is greater
331 -- than the length of this string.
332 raises OutOfRange from Standard
335 Value(me ; where : Integer) returns ExtCharacter
336 ---Purpose: Returns character at position <where> in <me>.
337 -- If <where> is less than zero or greater than the lenght of
338 -- <me>, an exception is raised.
340 -- aString contains "Hello"
341 -- aString.Value(2) returns 'e'
343 -- Standard_OutOfRange if where lies outside
344 -- the bounds of this extended string.
345 raises OutOfRange from Standard
348 HashCode(myclass ; astring : ExtendedString from TCollection; Upper : Integer)
351 ---Purpose: Returns a hashed value for the extended string
352 -- astring within the range 1..Upper.
353 -- Note: if astring is ASCII, the computed value is
354 -- the same as the value computed with the HashCode function on a
355 -- TCollection_AsciiString string composed with equivalent ASCII characters
358 IsEqual(myclass ; string1 : ExtendedString from TCollection;
359 string2 : ExtendedString from TCollection)
361 ---Purpose: Returns true if the characters in this extended
362 -- string are identical to the characters in the other extended string.
363 -- Note that this method is an alias of operator ==.
366 ToUTF8CString(me; theCString : out PCharacter from Standard)
367 returns Integer from Standard;
368 ---Purpose: Converts the internal <mystring> to UTF8 coding and
369 -- returns length of the out CString. A memory for the
370 -- <theCString> should be allocated before call!
373 returns Integer from Standard;
374 ---Purpose: Returns expected CString length in UTF8 coding.
375 -- It can be used for memory calculation before converting
376 -- to CString containing symbols in UTF8 coding.
378 ConvertToUnicode(me : out; astring : CString)
379 returns Boolean is private;
380 ---Purpose: Returns true if the input CString was successfuly converted
383 mystring : PExtCharacter from Standard;
384 mylength : Integer from Standard;
387 end ExtendedString from TCollection;