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
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16 
17 #ifndef _TCollection_AsciiString_HeaderFile
18 #define _TCollection_AsciiString_HeaderFile
19 
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23 
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;
38 
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).
47 //!
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
53 {
54 public:
55 
56   DEFINE_STANDARD_ALLOC
57 
58 
59   //! Initializes a AsciiString to an empty AsciiString.
60   Standard_EXPORT TCollection_AsciiString();
61 
62   //! Initializes a AsciiString with a CString.
63   Standard_EXPORT TCollection_AsciiString(const Standard_CString message);
64 
65   //! Initializes a AsciiString with a CString.
66   Standard_EXPORT TCollection_AsciiString(const Standard_CString message, const Standard_Integer aLen);
67 
68   //! Initializes a AsciiString with a single character.
69   Standard_EXPORT TCollection_AsciiString(const Standard_Character aChar);
70 
71   //! Initializes an AsciiString with <length> space allocated.
72   //! and filled with <filler>. This is useful for buffers.
73   Standard_EXPORT TCollection_AsciiString(const Standard_Integer length, const Standard_Character filler);
74 
75   //! Initializes an AsciiString with an integer value
76   Standard_EXPORT TCollection_AsciiString(const Standard_Integer value);
77 
78   //! Initializes an AsciiString with a real value
79   Standard_EXPORT TCollection_AsciiString(const Standard_Real value);
80 
81   //! Initializes a AsciiString with another AsciiString.
82   Standard_EXPORT TCollection_AsciiString(const TCollection_AsciiString& astring);
83 
84 #ifndef OCCT_NO_RVALUE_REFERENCE
85   //! Move constructor
TCollection_AsciiString(TCollection_AsciiString && theOther)86   TCollection_AsciiString (TCollection_AsciiString&& theOther)
87   : mystring (theOther.mystring),
88     mylength (theOther.mylength)
89   {
90     theOther.mystring = NULL;
91     theOther.mylength = 0;
92   }
93 #endif
94 
95   //! Initializes a AsciiString with copy of another AsciiString
96   //! concatenated with the message character.
97   Standard_EXPORT TCollection_AsciiString(const TCollection_AsciiString& astring, const Standard_Character message);
98 
99   //! Initializes a AsciiString with copy of another AsciiString
100   //! concatenated with the message string.
101   Standard_EXPORT TCollection_AsciiString(const TCollection_AsciiString& astring, const Standard_CString message);
102 
103   //! Initializes a AsciiString with copy of another AsciiString
104   //! concatenated with the message string.
105   Standard_EXPORT TCollection_AsciiString(const TCollection_AsciiString& astring, const TCollection_AsciiString& message);
106 
107   //! Creation by converting an extended string to an ascii string.
108   //! If replaceNonAscii is non-null character, it will be used
109   //! in place of any non-ascii character found in the source string.
110   //! Otherwise, creates UTF-8 unicode string.
111   Standard_EXPORT TCollection_AsciiString(const TCollection_ExtendedString& astring, const Standard_Character replaceNonAscii = 0);
112 
113 #if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
114   //! Initialize UTF-8 Unicode string from wide-char string considering it as Unicode string
115   //! (the size of wide char is a platform-dependent - e.g. on Windows wchar_t is UTF-16).
116   //!
117   //! This constructor is unavailable if application is built with deprecated msvc option "-Zc:wchar_t-",
118   //! since OCCT itself is never built with this option.
119   Standard_EXPORT TCollection_AsciiString (const Standard_WideChar* theStringUtf);
120 #endif
121 
122   //! Appends <other>  to me. This is an unary operator.
123   Standard_EXPORT void AssignCat (const Standard_Character other);
operator +=(const Standard_Character other)124 void operator += (const Standard_Character other)
125 {
126   AssignCat(other);
127 }
128 
129   //! Appends <other>  to me. This is an unary operator.
130   Standard_EXPORT void AssignCat (const Standard_Integer other);
operator +=(const Standard_Integer other)131 void operator += (const Standard_Integer other)
132 {
133   AssignCat(other);
134 }
135 
136   //! Appends <other>  to me. This is an unary operator.
137   Standard_EXPORT void AssignCat (const Standard_Real other);
operator +=(const Standard_Real other)138 void operator += (const Standard_Real other)
139 {
140   AssignCat(other);
141 }
142 
143   //! Appends <other>  to me. This is an unary operator.
144   //! ex: aString += "Dummy"
145   //! To catenate more than one CString, you must put a
146   //! AsciiString before.
147   //! Example: aString += "Hello " + "Dolly"  IS NOT VALID !
148   //! But astring += anotherString + "Hello " + "Dolly" is valid.
149   Standard_EXPORT void AssignCat (const Standard_CString other);
operator +=(const Standard_CString other)150 void operator += (const Standard_CString other)
151 {
152   AssignCat(other);
153 }
154 
155   //! Appends <other> to me. This is an unary operator.
156   //! Example: aString += anotherString
157   Standard_EXPORT void AssignCat (const TCollection_AsciiString& other);
operator +=(const TCollection_AsciiString & other)158 void operator += (const TCollection_AsciiString& other)
159 {
160   AssignCat(other);
161 }
162 
163   //! Converts the first character into its corresponding
164   //! upper-case character and the other characters into lowercase
165   //! Example: before
166   //! me = "hellO "
167   //! after
168   //! me = "Hello "
169   Standard_EXPORT void Capitalize();
170 
171   //! Appends <other>  to me.
172   //! Syntax:
173   //! aString = aString + "Dummy"
174   //! Example: aString contains "I say "
175   //! aString = aString + "Hello " + "Dolly"
176   //! gives "I say Hello Dolly"
177   //! To catenate more than one CString, you must put a String before.
178   //! So the following example is WRONG !
179   //! aString = "Hello " + "Dolly"  THIS IS NOT ALLOWED
180   //! This rule is applicable to AssignCat (operator +=) too.
181     TCollection_AsciiString Cat (const Standard_Character other) const;
operator +(const Standard_Character other) const182   TCollection_AsciiString operator + (const Standard_Character other) const
183 {
184   return Cat(other);
185 }
186 
187   //! Appends <other>  to me.
188   //! Syntax:
189   //! aString = aString + 15;
190   //! Example: aString contains "I say "
191   //! gives "I say 15"
192   //! To catenate more than one CString, you must put a String before.
193   //! So the following example is WRONG !
194   //! aString = "Hello " + "Dolly"  THIS IS NOT ALLOWED
195   //! This rule is applicable to AssignCat (operator +=) too.
196     TCollection_AsciiString Cat (const Standard_Integer other) const;
operator +(const Standard_Integer other) const197   TCollection_AsciiString operator + (const Standard_Integer other) const
198 {
199   return Cat(other);
200 }
201 
202   //! Appends <other>  to me.
203   //! Syntax:
204   //! aString = aString + 15.15;
205   //! Example: aString contains "I say "
206   //! gives "I say 15.15"
207   //! To catenate more than one CString, you must put a String before.
208   //! So the following example is WRONG !
209   //! aString = "Hello " + "Dolly"  THIS IS NOT ALLOWED
210   //! This rule is applicable to AssignCat (operator +=) too.
211     TCollection_AsciiString Cat (const Standard_Real other) const;
operator +(const Standard_Real other) const212   TCollection_AsciiString operator + (const Standard_Real other) const
213 {
214   return Cat(other);
215 }
216 
217   //! Appends <other>  to me.
218   //! Syntax:
219   //! aString = aString + "Dummy"
220   //! Example: aString contains "I say "
221   //! aString = aString + "Hello " + "Dolly"
222   //! gives "I say Hello Dolly"
223   //! To catenate more than one CString, you must put a String before.
224   //! So the following example is WRONG !
225   //! aString = "Hello " + "Dolly"  THIS IS NOT ALLOWED
226   //! This rule is applicable to AssignCat (operator +=) too.
227     TCollection_AsciiString Cat (const Standard_CString other) const;
operator +(const Standard_CString other) const228   TCollection_AsciiString operator + (const Standard_CString other) const
229 {
230   return Cat(other);
231 }
232 
233   //! Appends <other> to me.
234   //! Example: aString = aString + anotherString
235     TCollection_AsciiString Cat (const TCollection_AsciiString& other) const;
operator +(const TCollection_AsciiString & other) const236   TCollection_AsciiString operator + (const TCollection_AsciiString& other) const
237 {
238   return Cat(other);
239 }
240 
241   //! Modifies this ASCII string so that its length
242   //! becomes equal to Width and the new characters
243   //! are equal to Filler. New characters are added
244   //! both at the beginning and at the end of this string.
245   //! If Width is less than the length of this ASCII string, nothing happens.
246   //! Example
247   //! TCollection_AsciiString
248   //! myAlphabet("abcdef");
249   //! myAlphabet.Center(9,' ');
250   //! assert ( myAlphabet == "
251   //! abcdef " );
252   Standard_EXPORT void Center (const Standard_Integer Width, const Standard_Character Filler);
253 
254   //! Substitutes all the characters equal to aChar by NewChar
255   //! in the AsciiString <me>.
256   //! The substitution can be case sensitive.
257   //! If you don't use default case sensitive, no matter whether aChar
258   //! is uppercase or not.
259   //! Example: me = "Histake" -> ChangeAll('H','M',Standard_True)
260   //! gives me = "Mistake"
261   Standard_EXPORT void ChangeAll (const Standard_Character aChar, const Standard_Character NewChar, const Standard_Boolean CaseSensitive = Standard_True);
262 
263   //! Removes all characters contained in <me>.
264   //! This produces an empty AsciiString.
265   Standard_EXPORT void Clear();
266 
267   //! Copy <fromwhere> to <me>.
268   //! Used as operator =
269   //! Example: aString = anotherCString;
270   Standard_EXPORT void Copy (const Standard_CString fromwhere);
operator =(const Standard_CString fromwhere)271 void operator = (const Standard_CString fromwhere)
272 {
273   Copy(fromwhere);
274 }
275 
276   //! Copy <fromwhere> to <me>.
277   //! Used as operator =
278   //! Example: aString = anotherString;
279   Standard_EXPORT void Copy (const TCollection_AsciiString& fromwhere);
operator =(const TCollection_AsciiString & fromwhere)280 void operator = (const TCollection_AsciiString& fromwhere)
281 {
282   Copy(fromwhere);
283 }
284 
285   //! Exchange the data of two strings (without reallocating memory).
286   Standard_EXPORT void Swap (TCollection_AsciiString& theOther);
287 
288 #ifndef OCCT_NO_RVALUE_REFERENCE
289   //! Move assignment operator
operator =(TCollection_AsciiString && theOther)290   TCollection_AsciiString& operator= (TCollection_AsciiString&& theOther) { Swap (theOther); return *this; }
291 #endif
292 
293   //! Frees memory allocated by AsciiString.
294   Standard_EXPORT ~TCollection_AsciiString();
295 
296   //! Returns the index of the first character of <me> that is
297   //! present in <Set>.
298   //! The search begins to the index FromIndex and ends to the
299   //! the index ToIndex.
300   //! Returns zero if failure.
301   //! Raises an exception if FromIndex or ToIndex is out of range.
302   //! Example: before
303   //! me = "aabAcAa", S = "Aa", FromIndex = 1, Toindex = 7
304   //! after
305   //! me = "aabAcAa"
306   //! returns
307   //! 1
308   Standard_EXPORT Standard_Integer FirstLocationInSet (const TCollection_AsciiString& Set, const Standard_Integer FromIndex, const Standard_Integer ToIndex) const;
309 
310   //! Returns the index of the first character of <me>
311   //! that is not present in the set <Set>.
312   //! The search begins to the index FromIndex and ends to the
313   //! the index ToIndex in <me>.
314   //! Returns zero if failure.
315   //! Raises an exception if FromIndex or ToIndex is out of range.
316   //! Example: before
317   //! me = "aabAcAa", S = "Aa", FromIndex = 1, Toindex = 7
318   //! after
319   //! me = "aabAcAa"
320   //! returns
321   //! 3
322   Standard_EXPORT Standard_Integer FirstLocationNotInSet (const TCollection_AsciiString& Set, const Standard_Integer FromIndex, const Standard_Integer ToIndex) const;
323 
324   //! Inserts a Character at position <where>.
325   //! Example:
326   //! aString contains "hy not ?"
327   //! aString.Insert(1,'W'); gives "Why not ?"
328   //! aString contains "Wh"
329   //! aString.Insert(3,'y'); gives "Why"
330   //! aString contains "Way"
331   //! aString.Insert(2,'h'); gives "Why"
332   Standard_EXPORT void Insert (const Standard_Integer where, const Standard_Character what);
333 
334   //! Inserts a CString at position <where>.
335   //! Example:
336   //! aString contains "O more"
337   //! aString.Insert(2,"nce");  gives "Once more"
338   Standard_EXPORT void Insert (const Standard_Integer where, const Standard_CString what);
339 
340   //! Inserts a AsciiString at position <where>.
341   Standard_EXPORT void Insert (const Standard_Integer where, const TCollection_AsciiString& what);
342 
343   //! Pushing a string after a specific index in the string <me>.
344   //! Raises an exception if Index is out of bounds.
345   //! -   less than 0 (InsertAfter), or less than 1 (InsertBefore), or
346   //! -   greater than the number of characters in this ASCII string.
347   //! Example:
348   //! before
349   //! me = "cde" , Index = 0 , other = "ab"
350   //! after
351   //! me = "abcde" , other = "ab"
352   Standard_EXPORT void InsertAfter (const Standard_Integer Index, const TCollection_AsciiString& other);
353 
354   //! Pushing a string before a specific index in the string <me>.
355   //! Raises an exception if Index is out of bounds.
356   //! -   less than 0 (InsertAfter), or less than 1 (InsertBefore), or
357   //! -   greater than the number of characters in this ASCII string.
358   //! Example:
359   //! before
360   //! me = "cde" , Index = 1 , other = "ab"
361   //! after
362   //! me = "abcde" , other = "ab"
363   Standard_EXPORT void InsertBefore (const Standard_Integer Index, const TCollection_AsciiString& other);
364 
365   //! Returns True if the string <me> contains zero character.
IsEmpty() const366   Standard_Boolean IsEmpty() const { return mylength == 0; }
367 
368   //! Returns true if the characters in this ASCII string
369   //! are identical to the characters in ASCII string other.
370   //! Note that this method is an alias of operator ==.
371   Standard_EXPORT Standard_Boolean IsEqual (const Standard_CString other) const;
operator ==(const Standard_CString other) const372 Standard_Boolean operator == (const Standard_CString other) const
373 {
374   return IsEqual(other);
375 }
376 
377   //! Returns true if the characters in this ASCII string
378   //! are identical to the characters in ASCII string other.
379   //! Note that this method is an alias of operator ==.
380   Standard_EXPORT Standard_Boolean IsEqual (const TCollection_AsciiString& other) const;
operator ==(const TCollection_AsciiString & other) const381 Standard_Boolean operator == (const TCollection_AsciiString& other) const
382 {
383   return IsEqual(other);
384 }
385 
386   //! Returns true if there are differences between the
387   //! characters in this ASCII string and ASCII string other.
388   //! Note that this method is an alias of operator !=
389   Standard_EXPORT Standard_Boolean IsDifferent (const Standard_CString other) const;
operator !=(const Standard_CString other) const390 Standard_Boolean operator != (const Standard_CString other) const
391 {
392   return IsDifferent(other);
393 }
394 
395   //! Returns true if there are differences between the
396   //! characters in this ASCII string and ASCII string other.
397   //! Note that this method is an alias of operator !=
398   Standard_EXPORT Standard_Boolean IsDifferent (const TCollection_AsciiString& other) const;
operator !=(const TCollection_AsciiString & other) const399 Standard_Boolean operator != (const TCollection_AsciiString& other) const
400 {
401   return IsDifferent(other);
402 }
403 
404   //! Returns TRUE if <me> is 'ASCII' less than <other>.
405   Standard_EXPORT Standard_Boolean IsLess (const Standard_CString other) const;
operator <(const Standard_CString other) const406 Standard_Boolean operator < (const Standard_CString other) const
407 {
408   return IsLess(other);
409 }
410 
411   //! Returns TRUE if <me> is 'ASCII' less than <other>.
412   Standard_EXPORT Standard_Boolean IsLess (const TCollection_AsciiString& other) const;
operator <(const TCollection_AsciiString & other) const413 Standard_Boolean operator < (const TCollection_AsciiString& other) const
414 {
415   return IsLess(other);
416 }
417 
418   //! Returns TRUE if <me> is 'ASCII' greater than <other>.
419   Standard_EXPORT Standard_Boolean IsGreater (const Standard_CString other) const;
operator >(const Standard_CString other) const420 Standard_Boolean operator > (const Standard_CString other) const
421 {
422   return IsGreater(other);
423 }
424 
425   //! Returns TRUE if <me> is 'ASCII' greater than <other>.
426   Standard_EXPORT Standard_Boolean IsGreater (const TCollection_AsciiString& other) const;
operator >(const TCollection_AsciiString & other) const427 Standard_Boolean operator > (const TCollection_AsciiString& other) const
428 {
429   return IsGreater(other);
430 }
431 
432   //! Determines whether the beginning of this string instance matches the specified string.
433   Standard_EXPORT Standard_Boolean StartsWith (const TCollection_AsciiString& theStartString) const;
434 
435   //! Determines whether the end of this string instance matches the specified string.
436   Standard_EXPORT Standard_Boolean EndsWith (const TCollection_AsciiString& theEndString) const;
437 
438   //! Converts a AsciiString containing a numeric expression to
439   //! an Integer.
440   //! Example: "215" returns 215.
441   Standard_EXPORT Standard_Integer IntegerValue() const;
442 
443   //! Returns True if the AsciiString contains an integer value.
444   //! Note: an integer value is considered to be a real value as well.
445   Standard_EXPORT Standard_Boolean IsIntegerValue() const;
446 
447   //! Returns True if the AsciiString starts with some characters that can be interpreted as integer or real value.
448   //! @param theToCheckFull [in] when TRUE, checks if entire string defines a real value;
449   //!                            otherwise checks if string starts with a real value
450   //! Note: an integer value is considered to be a real value as well.
451   Standard_EXPORT Standard_Boolean IsRealValue (Standard_Boolean theToCheckFull = Standard_False) const;
452 
453   //! Returns True if the AsciiString contains only ASCII characters
454   //! between ' ' and '~'.
455   //! This means no control character and no extended ASCII code.
456   Standard_EXPORT Standard_Boolean IsAscii() const;
457 
458   //! Removes all space characters in the beginning of the string.
459   Standard_EXPORT void LeftAdjust();
460 
461   //! left justify
462   //! Length becomes equal to Width and the new characters are
463   //! equal to Filler.
464   //! If Width < Length nothing happens.
465   //! Raises an exception if Width is less than zero.
466   //! Example:
467   //! before
468   //! me = "abcdef" , Width = 9 , Filler = ' '
469   //! after
470   //! me = "abcdef   "
471   Standard_EXPORT void LeftJustify (const Standard_Integer Width, const Standard_Character Filler);
472 
473   //! Returns number of characters in <me>.
474   //! This is the same functionality as 'strlen' in C.
475   //! Example
476   //! TCollection_AsciiString myAlphabet("abcdef");
477   //! assert ( myAlphabet.Length() == 6 );
478   //! -   1 is the position of the first character in this string.
479   //! -   The length of this string gives the position of its last character.
480   //! -   Positions less than or equal to zero, or
481   //! greater than the length of this string are
482   //! invalid in functions which identify a character
483   //! of this string by its position.
484     Standard_Integer Length() const;
485 
486   //! Returns an index in the string <me> of the first occurrence
487   //! of the string S in the string <me> from the starting index
488   //! FromIndex to the ending index ToIndex
489   //! returns zero if failure
490   //! Raises an exception if FromIndex or ToIndex is out of range.
491   //! Example:
492   //! before
493   //! me = "aabAaAa", S = "Aa", FromIndex = 1, ToIndex = 7
494   //! after
495   //! me = "aabAaAa"
496   //! returns
497   //! 4
498   Standard_EXPORT Standard_Integer Location (const TCollection_AsciiString& other, const Standard_Integer FromIndex, const Standard_Integer ToIndex) const;
499 
500   //! Returns the index of the nth occurrence of the character C
501   //! in the string <me> from the starting index FromIndex to the
502   //! ending index ToIndex.
503   //! Returns zero if failure.
504   //! Raises an exception if FromIndex or ToIndex is out of range.
505   //! Example:
506   //! before
507   //! me = "aabAa", N = 3, C = 'a', FromIndex = 1, ToIndex = 5
508   //! after
509   //! me = "aabAa"
510   //! returns
511   //! 5
512   Standard_EXPORT Standard_Integer Location (const Standard_Integer N, const Standard_Character C, const Standard_Integer FromIndex, const Standard_Integer ToIndex) const;
513 
514   //! Converts <me> to its lower-case equivalent.
515   //! Example
516   //! TCollection_AsciiString myString("Hello Dolly");
517   //! myString.UpperCase();
518   //! assert ( myString == "HELLO DOLLY" );
519   //! myString.LowerCase();
520   //! assert ( myString == "hello dolly" );
521   Standard_EXPORT void LowerCase();
522 
523   //! Inserts the string other at the beginning of this ASCII string.
524   //! Example
525   //! TCollection_AsciiString myAlphabet("cde");
526   //! TCollection_AsciiString myBegin("ab");
527   //! myAlphabet.Prepend(myBegin);
528   //! assert ( myAlphabet == "abcde" );
529   Standard_EXPORT void Prepend (const TCollection_AsciiString& other);
530 
531   //! Displays <me> on a stream.
532   Standard_EXPORT void Print (Standard_OStream& astream) const;
533 friend Standard_EXPORT Standard_OStream& operator << (Standard_OStream& astream,const TCollection_AsciiString& astring);
534 
535   //! Read <me> from a stream.
536   Standard_EXPORT void Read (Standard_IStream& astream);
537 friend Standard_EXPORT Standard_IStream& operator >> (Standard_IStream& astream, TCollection_AsciiString& astring);
538 
539   //! Converts an AsciiString containing a numeric expression.
540   //! to a Real.
541   //! Example: ex: "215" returns 215.0.
542   //! ex: "3.14159267" returns 3.14159267.
543   Standard_EXPORT Standard_Real RealValue() const;
544 
545   //! Remove all the occurrences of the character C in the string.
546   //! Example:
547   //! before
548   //! me = "HellLLo", C = 'L' , CaseSensitive = True
549   //! after
550   //! me = "Hello"
551   Standard_EXPORT void RemoveAll (const Standard_Character C, const Standard_Boolean CaseSensitive);
552 
553   //! Removes every <what> characters from <me>.
554   Standard_EXPORT void RemoveAll (const Standard_Character what);
555 
556   //! Erases <ahowmany> characters from position <where>,
557   //! <where> included.
558   //! Example:
559   //! aString contains "Hello"
560   //! aString.Remove(2,2) erases 2 characters from position 2
561   //! This gives "Hlo".
562   Standard_EXPORT void Remove (const Standard_Integer where, const Standard_Integer ahowmany = 1);
563 
564   //! Removes all space characters at the end of the string.
565   Standard_EXPORT void RightAdjust();
566 
567   //! Right justify.
568   //! Length becomes equal to Width and the new characters are
569   //! equal to Filler.
570   //! if Width < Length nothing happens.
571   //! Raises an exception if Width is less than zero.
572   //! Example:
573   //! before
574   //! me = "abcdef" , Width = 9 , Filler = ' '
575   //! after
576   //! me = "   abcdef"
577   Standard_EXPORT void RightJustify (const Standard_Integer Width, const Standard_Character Filler);
578 
579   //! Searches a CString in <me> from the beginning
580   //! and returns position of first item <what> matching.
581   //! it returns -1 if not found.
582   //! Example:
583   //! aString contains "Sample single test"
584   //! aString.Search("le") returns 5
585   Standard_EXPORT Standard_Integer Search (const Standard_CString what) const;
586 
587   //! Searches an AsciiString in <me> from the beginning
588   //! and returns position of first item <what> matching.
589   //! It returns -1 if not found.
590   Standard_EXPORT Standard_Integer Search (const TCollection_AsciiString& what) const;
591 
592   //! Searches a CString in a AsciiString from the end
593   //! and returns position of first item <what> matching.
594   //! It returns -1 if not found.
595   //! Example:
596   //! aString contains "Sample single test"
597   //! aString.SearchFromEnd("le") returns 12
598   Standard_EXPORT Standard_Integer SearchFromEnd (const Standard_CString what) const;
599 
600   //! Searches a AsciiString in another AsciiString from the end
601   //! and returns position of first item <what> matching.
602   //! It returns -1 if not found.
603   Standard_EXPORT Standard_Integer SearchFromEnd (const TCollection_AsciiString& what) const;
604 
605   //! Replaces one character in the AsciiString at position <where>.
606   //! If <where> is less than zero or greater than the length of <me>
607   //! an exception is raised.
608   //! Example:
609   //! aString contains "Garbake"
610   //! astring.Replace(6,'g')  gives <me> = "Garbage"
611   Standard_EXPORT void SetValue (const Standard_Integer where, const Standard_Character what);
612 
613   //! Replaces a part of <me> by a CString.
614   //! If <where> is less than zero or greater than the length of <me>
615   //! an exception is raised.
616   //! Example:
617   //! aString contains "abcde"
618   //! aString.SetValue(4,"1234567") gives <me> = "abc1234567"
619   Standard_EXPORT void SetValue (const Standard_Integer where, const Standard_CString what);
620 
621   //! Replaces a part of <me> by another AsciiString.
622   Standard_EXPORT void SetValue (const Standard_Integer where, const TCollection_AsciiString& what);
623 
624   //! Splits a AsciiString into two sub-strings.
625   //! Example:
626   //! aString contains "abcdefg"
627   //! aString.Split(3) gives <me> = "abc" and returns "defg"
628   Standard_EXPORT TCollection_AsciiString Split (const Standard_Integer where);
629 
630   //! Creation of a sub-string of the string <me>.
631   //! The sub-string starts to the index Fromindex and ends
632   //! to the index ToIndex.
633   //! Raises an exception if ToIndex or FromIndex is out of bounds
634   //! Example:
635   //! before
636   //! me = "abcdefg", ToIndex=3, FromIndex=6
637   //! after
638   //! me = "abcdefg"
639   //! returns
640   //! "cdef"
641     TCollection_AsciiString SubString (const Standard_Integer FromIndex, const Standard_Integer ToIndex) const;
642 
643   //! Returns pointer to AsciiString (char *).
644   //! This is useful for some casual manipulations.
645   //! Warning: Because this "char *" is 'const', you can't modify its contents.
646     Standard_CString ToCString() const;
647 
648   //! Extracts <whichone> token from <me>.
649   //! By default, the <separators> is set to space and tabulation.
650   //! By default, the token extracted is the first one (whichone = 1).
651   //! <separators> contains all separators you need.
652   //! If no token indexed by <whichone> is found, it returns empty AsciiString.
653   //! Example:
654   //! aString contains "This is a     message"
655   //! aString.Token()  returns "This"
656   //! aString.Token(" ",4) returns "message"
657   //! aString.Token(" ",2) returns "is"
658   //! aString.Token(" ",9) returns ""
659   //! Other separators than space character and tabulation are allowed :
660   //! aString contains "1234; test:message   , value"
661   //! aString.Token("; :,",4) returns "value"
662   //! aString.Token("; :,",2) returns "test"
663   Standard_EXPORT TCollection_AsciiString Token (const Standard_CString separators = " \t", const Standard_Integer whichone = 1) const;
664 
665   //! Truncates <me> to <ahowmany> characters.
666   //! Example:  me = "Hello Dolly" -> Trunc(3) -> me = "Hel"
667   Standard_EXPORT void Trunc (const Standard_Integer ahowmany);
668 
669   //! Converts <me> to its upper-case equivalent.
670   Standard_EXPORT void UpperCase();
671 
672   //! Length of the string ignoring all spaces (' ') and the
673   //! control character at the end.
674   Standard_EXPORT Standard_Integer UsefullLength() const;
675 
676   //! Returns character at position <where> in <me>.
677   //! If <where> is less than zero or greater than the length of <me>,
678   //! an exception is raised.
679   //! Example:
680   //! aString contains "Hello"
681   //! aString.Value(2) returns 'e'
682   Standard_EXPORT Standard_Character Value (const Standard_Integer where) const;
683 
684   //! Computes a hash code for the given ASCII string, in the range [1, theUpperBound].
685   //! Returns the same integer value as the hash function for TCollection_ExtendedString
686   //! @param theAsciiString the ASCII string which hash code is to be computed
687   //! @param theUpperBound the upper bound of the range a computing hash code must be within
688   //! @return a computed hash code, in the range [1, theUpperBound]
689   static Standard_Integer HashCode (const TCollection_AsciiString& theAsciiString, Standard_Integer theUpperBound);
690 
691   //! Returns True  when the two  strings are the same.
692   //! (Just for HashCode for AsciiString)
693     static Standard_Boolean IsEqual (const TCollection_AsciiString& string1, const TCollection_AsciiString& string2);
694 
695   //! Returns True  when the two  strings are the same.
696   //! (Just for HashCode for AsciiString)
697     static Standard_Boolean IsEqual (const TCollection_AsciiString& string1, const Standard_CString string2);
698 
699   //! Returns True if the strings contain same characters.
700   Standard_EXPORT static Standard_Boolean IsSameString (const TCollection_AsciiString& theString1,
701                                                         const TCollection_AsciiString& theString2,
702                                                         const Standard_Boolean theIsCaseSensitive);
703 
704 friend class TCollection_HAsciiString;
705 
706 private:
707 
708   Standard_EXPORT void Split (const Standard_Integer where, TCollection_AsciiString& result);
709 
710   Standard_EXPORT void SubString (const Standard_Integer FromIndex, const Standard_Integer ToIndex, TCollection_AsciiString& result) const;
711 
712   Standard_EXPORT void Token (const Standard_CString separators, const Standard_Integer whichone, TCollection_AsciiString& result) const;
713 
714 private:
715 
716   Standard_PCharacter mystring; //!< NULL-terminated string
717   Standard_Integer    mylength; //!< length in bytes (excluding terminating NULL symbol)
718 
719 };
720 
721 #include <TCollection_AsciiString.lxx>
722 
723 #endif // _TCollection_AsciiString_HeaderFile
724