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 #ifndef _TCollection_AsciiString_HeaderFile
18 #define _TCollection_AsciiString_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <Standard_PCharacter.hxx>
25 #include <Standard_Integer.hxx>
26 #include <Standard_CString.hxx>
27 #include <Standard_Character.hxx>
28 #include <Standard_Real.hxx>
29 #include <Standard_Boolean.hxx>
30 #include <Standard_OStream.hxx>
31 #include <Standard_IStream.hxx>
32 class Standard_NullObject;
33 class Standard_OutOfRange;
34 class Standard_NumericError;
35 class Standard_NegativeValue;
36 class TCollection_HAsciiString;
37 class TCollection_ExtendedString;
39 //! Class defines a variable-length sequence of 8-bit characters.
40 //! Despite class name (kept for historical reasons), it is intended to store UTF-8 string, not just ASCII characters.
41 //! However, multi-byte nature of UTF-8 is not considered by the following methods:
42 //! - Method ::Length() return the number of bytes, not the number of Unicode symbols.
43 //! - Methods taking/returning symbol index work with 8-bit code units, not true Unicode symbols,
44 //! including ::Remove(), ::SetValue(), ::Value(), ::Search(), ::Trunc() and others.
45 //! If application needs to process multi-byte Unicode symbols explicitly, NCollection_Utf8Iter class can be used
46 //! for iterating through Unicode string (UTF-32 code unit will be returned for each position).
48 //! Class provides editing operations with built-in memory management to make AsciiString objects easier to use than ordinary character arrays.
49 //! AsciiString objects follow value semantics; in other words, they are the actual strings,
50 //! not handles to strings, and are copied through assignment.
51 //! You may use HAsciiString objects to get handles to strings.
52 class TCollection_AsciiString
59 //! Initializes a AsciiString to an empty AsciiString.
60 Standard_EXPORT TCollection_AsciiString();
62 //! Initializes a AsciiString with a CString.
63 Standard_EXPORT TCollection_AsciiString(const Standard_CString message);
65 //! Initializes a AsciiString with a CString.
66 Standard_EXPORT TCollection_AsciiString(const Standard_CString message, const Standard_Integer aLen);
68 //! Initializes a AsciiString with a single character.
69 Standard_EXPORT TCollection_AsciiString(const Standard_Character aChar);
71 //! Initializes an AsciiString with <length> space allocated.
72 //! and filled with <filler>. This is usefull for buffers.
73 Standard_EXPORT TCollection_AsciiString(const Standard_Integer length, const Standard_Character filler);
75 //! Initializes an AsciiString with an integer value
76 Standard_EXPORT TCollection_AsciiString(const Standard_Integer value);
78 //! Initializes an AsciiString with a real value
79 Standard_EXPORT TCollection_AsciiString(const Standard_Real value);
81 //! Initializes a AsciiString with another AsciiString.
82 Standard_EXPORT TCollection_AsciiString(const TCollection_AsciiString& astring);
84 //! Initializes a AsciiString with copy of another AsciiString
85 //! concatenated with the message character.
86 Standard_EXPORT TCollection_AsciiString(const TCollection_AsciiString& astring, const Standard_Character message);
88 //! Initializes a AsciiString with copy of another AsciiString
89 //! concatenated with the message string.
90 Standard_EXPORT TCollection_AsciiString(const TCollection_AsciiString& astring, const Standard_CString message);
92 //! Initializes a AsciiString with copy of another AsciiString
93 //! concatenated with the message string.
94 Standard_EXPORT TCollection_AsciiString(const TCollection_AsciiString& astring, const TCollection_AsciiString& message);
96 //! Creation by converting an extended string to an ascii string.
97 //! If replaceNonAscii is non-null charecter, it will be used
98 //! in place of any non-ascii character found in the source string.
99 //! Otherwise, creates UTF-8 unicode string.
100 Standard_EXPORT TCollection_AsciiString(const TCollection_ExtendedString& astring, const Standard_Character replaceNonAscii = 0);
102 #if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
103 //! Initialize UTF-8 Unicode string from wide-char string considering it as Unicode string
104 //! (the size of wide char is a platform-dependent - e.g. on Windows wchar_t is UTF-16).
106 //! This constructor is unavailable if application is built with deprecated msvc option "-Zc:wchar_t-",
107 //! since OCCT itself is never built with this option.
108 Standard_EXPORT TCollection_AsciiString (const Standard_WideChar* theStringUtf);
111 //! Appends <other> to me. This is an unary operator.
112 Standard_EXPORT void AssignCat (const Standard_Character other);
113 void operator += (const Standard_Character other)
118 //! Appends <other> to me. This is an unary operator.
119 Standard_EXPORT void AssignCat (const Standard_Integer other);
120 void operator += (const Standard_Integer other)
125 //! Appends <other> to me. This is an unary operator.
126 Standard_EXPORT void AssignCat (const Standard_Real other);
127 void operator += (const Standard_Real other)
132 //! Appends <other> to me. This is an unary operator.
133 //! ex: aString += "Dummy"
134 //! To catenate more than one CString, you must put a
135 //! AsciiString before.
136 //! Example: aString += "Hello " + "Dolly" IS NOT VALID !
137 //! But astring += anotherString + "Hello " + "Dolly" is valid.
138 Standard_EXPORT void AssignCat (const Standard_CString other);
139 void operator += (const Standard_CString other)
144 //! Appends <other> to me. This is an unary operator.
145 //! Example: aString += anotherString
146 Standard_EXPORT void AssignCat (const TCollection_AsciiString& other);
147 void operator += (const TCollection_AsciiString& other)
152 //! Converts the first character into its corresponding
153 //! upper-case character and the other characters into lowercase
158 Standard_EXPORT void Capitalize();
160 //! Appends <other> to me.
162 //! aString = aString + "Dummy"
163 //! Example: aString contains "I say "
164 //! aString = aString + "Hello " + "Dolly"
165 //! gives "I say Hello Dolly"
166 //! To catenate more than one CString, you must put a String before.
167 //! So the following example is WRONG !
168 //! aString = "Hello " + "Dolly" THIS IS NOT ALLOWED
169 //! This rule is applicable to AssignCat (operator +=) too.
170 TCollection_AsciiString Cat (const Standard_Character other) const;
171 TCollection_AsciiString operator + (const Standard_Character other) const
176 //! Appends <other> to me.
178 //! aString = aString + 15;
179 //! Example: aString contains "I say "
181 //! To catenate more than one CString, you must put a String before.
182 //! So the following example is WRONG !
183 //! aString = "Hello " + "Dolly" THIS IS NOT ALLOWED
184 //! This rule is applicable to AssignCat (operator +=) too.
185 TCollection_AsciiString Cat (const Standard_Integer other) const;
186 TCollection_AsciiString operator + (const Standard_Integer other) const
191 //! Appends <other> to me.
193 //! aString = aString + 15.15;
194 //! Example: aString contains "I say "
195 //! gives "I say 15.15"
196 //! To catenate more than one CString, you must put a String before.
197 //! So the following example is WRONG !
198 //! aString = "Hello " + "Dolly" THIS IS NOT ALLOWED
199 //! This rule is applicable to AssignCat (operator +=) too.
200 TCollection_AsciiString Cat (const Standard_Real other) const;
201 TCollection_AsciiString operator + (const Standard_Real other) const
206 //! Appends <other> to me.
208 //! aString = aString + "Dummy"
209 //! Example: aString contains "I say "
210 //! aString = aString + "Hello " + "Dolly"
211 //! gives "I say Hello Dolly"
212 //! To catenate more than one CString, you must put a String before.
213 //! So the following example is WRONG !
214 //! aString = "Hello " + "Dolly" THIS IS NOT ALLOWED
215 //! This rule is applicable to AssignCat (operator +=) too.
216 TCollection_AsciiString Cat (const Standard_CString other) const;
217 TCollection_AsciiString operator + (const Standard_CString other) const
222 //! Appends <other> to me.
223 //! Example: aString = aString + anotherString
224 TCollection_AsciiString Cat (const TCollection_AsciiString& other) const;
225 TCollection_AsciiString operator + (const TCollection_AsciiString& other) const
230 //! Modifies this ASCII string so that its length
231 //! becomes equal to Width and the new characters
232 //! are equal to Filler. New characters are added
233 //! both at the beginning and at the end of this string.
234 //! If Width is less than the length of this ASCII string, nothing happens.
236 //! TCollection_AsciiString
237 //! myAlphabet("abcdef");
238 //! myAlphabet.Center(9,' ');
239 //! assert ( myAlphabet == "
241 Standard_EXPORT void Center (const Standard_Integer Width, const Standard_Character Filler);
243 //! Substitutes all the characters equal to aChar by NewChar
244 //! in the AsciiString <me>.
245 //! The substitution can be case sensitive.
246 //! If you don't use default case sensitive, no matter wether aChar
247 //! is uppercase or not.
248 //! Example: me = "Histake" -> ChangeAll('H','M',Standard_True)
249 //! gives me = "Mistake"
250 Standard_EXPORT void ChangeAll (const Standard_Character aChar, const Standard_Character NewChar, const Standard_Boolean CaseSensitive = Standard_True);
252 //! Removes all characters contained in <me>.
253 //! This produces an empty AsciiString.
254 Standard_EXPORT void Clear();
256 //! Copy <fromwhere> to <me>.
257 //! Used as operator =
258 //! Example: aString = anotherCString;
259 Standard_EXPORT void Copy (const Standard_CString fromwhere);
260 void operator = (const Standard_CString fromwhere)
265 //! Copy <fromwhere> to <me>.
266 //! Used as operator =
267 //! Example: aString = anotherString;
268 Standard_EXPORT void Copy (const TCollection_AsciiString& fromwhere);
269 void operator = (const TCollection_AsciiString& fromwhere)
274 //! Frees memory allocated by AsciiString.
275 Standard_EXPORT ~TCollection_AsciiString();
277 //! Returns the index of the first character of <me> that is
278 //! present in <Set>.
279 //! The search begins to the index FromIndex and ends to the
280 //! the index ToIndex.
281 //! Returns zero if failure.
282 //! Raises an exception if FromIndex or ToIndex is out of range.
284 //! me = "aabAcAa", S = "Aa", FromIndex = 1, Toindex = 7
289 Standard_EXPORT Standard_Integer FirstLocationInSet (const TCollection_AsciiString& Set, const Standard_Integer FromIndex, const Standard_Integer ToIndex) const;
291 //! Returns the index of the first character of <me>
292 //! that is not present in the set <Set>.
293 //! The search begins to the index FromIndex and ends to the
294 //! the index ToIndex in <me>.
295 //! Returns zero if failure.
296 //! Raises an exception if FromIndex or ToIndex is out of range.
298 //! me = "aabAcAa", S = "Aa", FromIndex = 1, Toindex = 7
303 Standard_EXPORT Standard_Integer FirstLocationNotInSet (const TCollection_AsciiString& Set, const Standard_Integer FromIndex, const Standard_Integer ToIndex) const;
305 //! Inserts a Character at position <where>.
307 //! aString contains "hy not ?"
308 //! aString.Insert(1,'W'); gives "Why not ?"
309 //! aString contains "Wh"
310 //! aString.Insert(3,'y'); gives "Why"
311 //! aString contains "Way"
312 //! aString.Insert(2,'h'); gives "Why"
313 Standard_EXPORT void Insert (const Standard_Integer where, const Standard_Character what);
315 //! Inserts a CString at position <where>.
317 //! aString contains "O more"
318 //! aString.Insert(2,"nce"); gives "Once more"
319 Standard_EXPORT void Insert (const Standard_Integer where, const Standard_CString what);
321 //! Inserts a AsciiString at position <where>.
322 Standard_EXPORT void Insert (const Standard_Integer where, const TCollection_AsciiString& what);
324 //! Pushing a string after a specific index in the string <me>.
325 //! Raises an exception if Index is out of bounds.
326 //! - less than 0 (InsertAfter), or less than 1 (InsertBefore), or
327 //! - greater than the number of characters in this ASCII string.
330 //! me = "cde" , Index = 0 , other = "ab"
332 //! me = "abcde" , other = "ab"
333 Standard_EXPORT void InsertAfter (const Standard_Integer Index, const TCollection_AsciiString& other);
335 //! Pushing a string before a specific index in the string <me>.
336 //! Raises an exception if Index is out of bounds.
337 //! - less than 0 (InsertAfter), or less than 1 (InsertBefore), or
338 //! - greater than the number of characters in this ASCII string.
341 //! me = "cde" , Index = 1 , other = "ab"
343 //! me = "abcde" , other = "ab"
344 Standard_EXPORT void InsertBefore (const Standard_Integer Index, const TCollection_AsciiString& other);
346 //! Returns True if the string <me> contains zero character.
347 Standard_Boolean IsEmpty() const { return mylength == 0; }
349 //! Returns true if the characters in this ASCII string
350 //! are identical to the characters in ASCII string other.
351 //! Note that this method is an alias of operator ==.
352 Standard_EXPORT Standard_Boolean IsEqual (const Standard_CString other) const;
353 Standard_Boolean operator == (const Standard_CString other) const
355 return IsEqual(other);
358 //! Returns true if the characters in this ASCII string
359 //! are identical to the characters in ASCII string other.
360 //! Note that this method is an alias of operator ==.
361 Standard_EXPORT Standard_Boolean IsEqual (const TCollection_AsciiString& other) const;
362 Standard_Boolean operator == (const TCollection_AsciiString& other) const
364 return IsEqual(other);
367 //! Returns true if there are differences between the
368 //! characters in this ASCII string and ASCII string other.
369 //! Note that this method is an alias of operator !=
370 Standard_EXPORT Standard_Boolean IsDifferent (const Standard_CString other) const;
371 Standard_Boolean operator != (const Standard_CString other) const
373 return IsDifferent(other);
376 //! Returns true if there are differences between the
377 //! characters in this ASCII string and ASCII string other.
378 //! Note that this method is an alias of operator !=
379 Standard_EXPORT Standard_Boolean IsDifferent (const TCollection_AsciiString& other) const;
380 Standard_Boolean operator != (const TCollection_AsciiString& other) const
382 return IsDifferent(other);
385 //! Returns TRUE if <me> is 'ASCII' less than <other>.
386 Standard_EXPORT Standard_Boolean IsLess (const Standard_CString other) const;
387 Standard_Boolean operator < (const Standard_CString other) const
389 return IsLess(other);
392 //! Returns TRUE if <me> is 'ASCII' less than <other>.
393 Standard_EXPORT Standard_Boolean IsLess (const TCollection_AsciiString& other) const;
394 Standard_Boolean operator < (const TCollection_AsciiString& other) const
396 return IsLess(other);
399 //! Returns TRUE if <me> is 'ASCII' greater than <other>.
400 Standard_EXPORT Standard_Boolean IsGreater (const Standard_CString other) const;
401 Standard_Boolean operator > (const Standard_CString other) const
403 return IsGreater(other);
406 //! Returns TRUE if <me> is 'ASCII' greater than <other>.
407 Standard_EXPORT Standard_Boolean IsGreater (const TCollection_AsciiString& other) const;
408 Standard_Boolean operator > (const TCollection_AsciiString& other) const
410 return IsGreater(other);
413 //! Determines whether the beginning of this string instance matches the specified string.
414 Standard_EXPORT Standard_Boolean StartsWith (const TCollection_AsciiString& theStartString) const;
416 //! Determines whether the end of this string instance matches the specified string.
417 Standard_EXPORT Standard_Boolean EndsWith (const TCollection_AsciiString& theEndString) const;
419 //! Converts a AsciiString containing a numeric expression to
421 //! Example: "215" returns 215.
422 Standard_EXPORT Standard_Integer IntegerValue() const;
424 //! Returns True if the AsciiString contains an integer value.
425 //! Note: an integer value is considered to be a real value as well.
426 Standard_EXPORT Standard_Boolean IsIntegerValue() const;
428 //! Returns True if the AsciiString contains a real value.
429 //! Note: an integer value is considered to be a real value as well.
430 Standard_EXPORT Standard_Boolean IsRealValue() const;
432 //! Returns True if the AsciiString contains only ASCII characters
433 //! between ' ' and '~'.
434 //! This means no control character and no extended ASCII code.
435 Standard_EXPORT Standard_Boolean IsAscii() const;
437 //! Removes all space characters in the begining of the string.
438 Standard_EXPORT void LeftAdjust();
441 //! Length becomes equal to Width and the new characters are
443 //! If Width < Length nothing happens.
444 //! Raises an exception if Width is less than zero.
447 //! me = "abcdef" , Width = 9 , Filler = ' '
450 Standard_EXPORT void LeftJustify (const Standard_Integer Width, const Standard_Character Filler);
452 //! Returns number of characters in <me>.
453 //! This is the same functionality as 'strlen' in C.
455 //! TCollection_AsciiString myAlphabet("abcdef");
456 //! assert ( myAlphabet.Length() == 6 );
457 //! - 1 is the position of the first character in this string.
458 //! - The length of this string gives the position of its last character.
459 //! - Positions less than or equal to zero, or
460 //! greater than the length of this string are
461 //! invalid in functions which identify a character
462 //! of this string by its position.
463 Standard_Integer Length() const;
465 //! Returns an index in the string <me> of the first occurence
466 //! of the string S in the string <me> from the starting index
467 //! FromIndex to the ending index ToIndex
468 //! returns zero if failure
469 //! Raises an exception if FromIndex or ToIndex is out of range.
472 //! me = "aabAaAa", S = "Aa", FromIndex = 1, ToIndex = 7
477 Standard_EXPORT Standard_Integer Location (const TCollection_AsciiString& other, const Standard_Integer FromIndex, const Standard_Integer ToIndex) const;
479 //! Returns the index of the nth occurence of the character C
480 //! in the string <me> from the starting index FromIndex to the
481 //! ending index ToIndex.
482 //! Returns zero if failure.
483 //! Raises an exception if FromIndex or ToIndex is out of range.
486 //! me = "aabAa", N = 3, C = 'a', FromIndex = 1, ToIndex = 5
491 Standard_EXPORT Standard_Integer Location (const Standard_Integer N, const Standard_Character C, const Standard_Integer FromIndex, const Standard_Integer ToIndex) const;
493 //! Converts <me> to its lower-case equivalent.
495 //! TCollection_AsciiString myString("Hello Dolly");
496 //! myString.UpperCase();
497 //! assert ( myString == "HELLO DOLLY" );
498 //! myString.LowerCase();
499 //! assert ( myString == "hello dolly" );
500 Standard_EXPORT void LowerCase();
502 //! Inserts the string other at the beginning of this ASCII string.
504 //! TCollection_AsciiString myAlphabet("cde");
505 //! TCollection_AsciiString myBegin("ab");
506 //! myAlphabet.Prepend(myBegin);
507 //! assert ( myAlphabet == "abcde" );
508 Standard_EXPORT void Prepend (const TCollection_AsciiString& other);
510 //! Displays <me> on a stream.
511 Standard_EXPORT void Print (Standard_OStream& astream) const;
512 friend Standard_EXPORT Standard_OStream& operator << (Standard_OStream& astream,const TCollection_AsciiString& astring);
514 //! Read <me> from a stream.
515 Standard_EXPORT void Read (Standard_IStream& astream);
516 friend Standard_EXPORT Standard_IStream& operator >> (Standard_IStream& astream, TCollection_AsciiString& astring);
518 //! Converts an AsciiString containing a numeric expression.
520 //! Example: ex: "215" returns 215.0.
521 //! ex: "3.14159267" returns 3.14159267.
522 Standard_EXPORT Standard_Real RealValue() const;
524 //! Remove all the occurences of the character C in the string.
527 //! me = "HellLLo", C = 'L' , CaseSensitive = True
530 Standard_EXPORT void RemoveAll (const Standard_Character C, const Standard_Boolean CaseSensitive);
532 //! Removes every <what> characters from <me>.
533 Standard_EXPORT void RemoveAll (const Standard_Character what);
535 //! Erases <ahowmany> characters from position <where>,
536 //! <where> included.
538 //! aString contains "Hello"
539 //! aString.Remove(2,2) erases 2 characters from position 2
540 //! This gives "Hlo".
541 Standard_EXPORT void Remove (const Standard_Integer where, const Standard_Integer ahowmany = 1);
543 //! Removes all space characters at the end of the string.
544 Standard_EXPORT void RightAdjust();
547 //! Length becomes equal to Width and the new characters are
549 //! if Width < Length nothing happens.
550 //! Raises an exception if Width is less than zero.
553 //! me = "abcdef" , Width = 9 , Filler = ' '
556 Standard_EXPORT void RightJustify (const Standard_Integer Width, const Standard_Character Filler);
558 //! Searches a CString in <me> from the beginning
559 //! and returns position of first item <what> matching.
560 //! it returns -1 if not found.
562 //! aString contains "Sample single test"
563 //! aString.Search("le") returns 5
564 Standard_EXPORT Standard_Integer Search (const Standard_CString what) const;
566 //! Searches an AsciiString in <me> from the beginning
567 //! and returns position of first item <what> matching.
568 //! It returns -1 if not found.
569 Standard_EXPORT Standard_Integer Search (const TCollection_AsciiString& what) const;
571 //! Searches a CString in a AsciiString from the end
572 //! and returns position of first item <what> matching.
573 //! It returns -1 if not found.
575 //! aString contains "Sample single test"
576 //! aString.SearchFromEnd("le") returns 12
577 Standard_EXPORT Standard_Integer SearchFromEnd (const Standard_CString what) const;
579 //! Searches a AsciiString in another AsciiString from the end
580 //! and returns position of first item <what> matching.
581 //! It returns -1 if not found.
582 Standard_EXPORT Standard_Integer SearchFromEnd (const TCollection_AsciiString& what) const;
584 //! Replaces one character in the AsciiString at position <where>.
585 //! If <where> is less than zero or greater than the length of <me>
586 //! an exception is raised.
588 //! aString contains "Garbake"
589 //! astring.Replace(6,'g') gives <me> = "Garbage"
590 Standard_EXPORT void SetValue (const Standard_Integer where, const Standard_Character what);
592 //! Replaces a part of <me> by a CString.
593 //! If <where> is less than zero or greater than the length of <me>
594 //! an exception is raised.
596 //! aString contains "abcde"
597 //! aString.SetValue(4,"1234567") gives <me> = "abc1234567"
598 Standard_EXPORT void SetValue (const Standard_Integer where, const Standard_CString what);
600 //! Replaces a part of <me> by another AsciiString.
601 Standard_EXPORT void SetValue (const Standard_Integer where, const TCollection_AsciiString& what);
603 //! Splits a AsciiString into two sub-strings.
605 //! aString contains "abcdefg"
606 //! aString.Split(3) gives <me> = "abc" and returns "defg"
607 Standard_EXPORT TCollection_AsciiString Split (const Standard_Integer where);
609 //! Creation of a sub-string of the string <me>.
610 //! The sub-string starts to the index Fromindex and ends
611 //! to the index ToIndex.
612 //! Raises an exception if ToIndex or FromIndex is out of bounds
615 //! me = "abcdefg", ToIndex=3, FromIndex=6
620 TCollection_AsciiString SubString (const Standard_Integer FromIndex, const Standard_Integer ToIndex) const;
622 //! Returns pointer to AsciiString (char *).
623 //! This is useful for some casual manipulations.
624 //! Warning: Because this "char *" is 'const', you can't modify its contents.
625 Standard_CString ToCString() const;
627 //! Extracts <whichone> token from <me>.
628 //! By default, the <separators> is set to space and tabulation.
629 //! By default, the token extracted is the first one (whichone = 1).
630 //! <separators> contains all separators you need.
631 //! If no token indexed by <whichone> is found, it returns empty AsciiString.
633 //! aString contains "This is a message"
634 //! aString.Token() returns "This"
635 //! aString.Token(" ",4) returns "message"
636 //! aString.Token(" ",2) returns "is"
637 //! aString.Token(" ",9) returns ""
638 //! Other separators than space character and tabulation are allowed :
639 //! aString contains "1234; test:message , value"
640 //! aString.Token("; :,",4) returns "value"
641 //! aString.Token("; :,",2) returns "test"
642 Standard_EXPORT TCollection_AsciiString Token (const Standard_CString separators = " \t", const Standard_Integer whichone = 1) const;
644 //! Truncates <me> to <ahowmany> characters.
645 //! Example: me = "Hello Dolly" -> Trunc(3) -> me = "Hel"
646 Standard_EXPORT void Trunc (const Standard_Integer ahowmany);
648 //! Converts <me> to its upper-case equivalent.
649 Standard_EXPORT void UpperCase();
651 //! Length of the string ignoring all spaces (' ') and the
652 //! control character at the end.
653 Standard_EXPORT Standard_Integer UsefullLength() const;
655 //! Returns character at position <where> in <me>.
656 //! If <where> is less than zero or greater than the lenght of <me>,
657 //! an exception is raised.
659 //! aString contains "Hello"
660 //! aString.Value(2) returns 'e'
661 Standard_EXPORT Standard_Character Value (const Standard_Integer where) const;
663 //! Hash function for AsciiString
664 //! (returns the same Integer value that the hash function for ExtendedString)
665 static Standard_Integer HashCode (const TCollection_AsciiString& astring, const Standard_Integer Upper);
667 //! Returns True when the two strings are the same.
668 //! (Just for HashCode for AsciiString)
669 static Standard_Boolean IsEqual (const TCollection_AsciiString& string1, const TCollection_AsciiString& string2);
671 //! Returns True when the two strings are the same.
672 //! (Just for HashCode for AsciiString)
673 static Standard_Boolean IsEqual (const TCollection_AsciiString& string1, const Standard_CString string2);
675 //! Returns True if the strings contain same characters.
676 Standard_EXPORT static Standard_Boolean IsSameString (const TCollection_AsciiString& theString1,
677 const TCollection_AsciiString& theString2,
678 const Standard_Boolean theIsCaseSensitive);
680 friend class TCollection_HAsciiString;
684 Standard_EXPORT void Split (const Standard_Integer where, TCollection_AsciiString& result);
686 Standard_EXPORT void SubString (const Standard_Integer FromIndex, const Standard_Integer ToIndex, TCollection_AsciiString& result) const;
688 Standard_EXPORT void Token (const Standard_CString separators, const Standard_Integer whichone, TCollection_AsciiString& result) const;
692 Standard_PCharacter mystring; //!< NULL-terminated string
693 Standard_Integer mylength; //!< length in bytes (excluding terminating NULL symbol)
697 #include <TCollection_AsciiString.lxx>
699 #endif // _TCollection_AsciiString_HeaderFile