Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-15 09:49:04

0001 // Created on: 1993-02-22
0002 // Created by: Mireille MERCIEN
0003 // Copyright (c) 1993-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _TCollection_AsciiString_HeaderFile
0018 #define _TCollection_AsciiString_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <Standard_PCharacter.hxx>
0025 #include <Standard_CString.hxx>
0026 #include <Standard_Real.hxx>
0027 #include <Standard_OStream.hxx>
0028 #include <Standard_IStream.hxx>
0029 #include <Standard_Macro.hxx>
0030 class TCollection_ExtendedString;
0031 
0032 //! Class defines a variable-length sequence of 8-bit characters.
0033 //! Despite class name (kept for historical reasons), it is intended to store UTF-8 string, not just ASCII characters.
0034 //! However, multi-byte nature of UTF-8 is not considered by the following methods:
0035 //! - Method ::Length() return the number of bytes, not the number of Unicode symbols.
0036 //! - Methods taking/returning symbol index work with 8-bit code units, not true Unicode symbols,
0037 //!   including ::Remove(), ::SetValue(), ::Value(), ::Search(), ::Trunc() and others.
0038 //! If application needs to process multi-byte Unicode symbols explicitly, NCollection_Utf8Iter class can be used
0039 //! for iterating through Unicode string (UTF-32 code unit will be returned for each position).
0040 //!
0041 //! Class provides editing operations with built-in memory management to make AsciiString objects easier to use than ordinary character arrays.
0042 //! AsciiString objects follow value semantics; in other words, they are the actual strings,
0043 //! not handles to strings, and are copied through assignment.
0044 //! You may use HAsciiString objects to get handles to strings.
0045 class TCollection_AsciiString 
0046 {
0047 public:
0048 
0049   DEFINE_STANDARD_ALLOC
0050 
0051   
0052   //! Initializes a AsciiString to an empty AsciiString.
0053   Standard_EXPORT TCollection_AsciiString();
0054   
0055   //! Initializes a AsciiString with a CString.
0056   Standard_EXPORT TCollection_AsciiString(const Standard_CString message);
0057   
0058   //! Initializes a AsciiString with a CString.
0059   Standard_EXPORT TCollection_AsciiString(const Standard_CString message, const Standard_Integer aLen);
0060   
0061   //! Initializes a AsciiString with a single character.
0062   Standard_EXPORT TCollection_AsciiString(const Standard_Character aChar);
0063   
0064   //! Initializes an AsciiString with <length> space allocated.
0065   //! and filled with <filler>. This is useful for buffers.
0066   Standard_EXPORT TCollection_AsciiString(const Standard_Integer length, const Standard_Character filler);
0067   
0068   //! Initializes an AsciiString with an integer value
0069   Standard_EXPORT TCollection_AsciiString(const Standard_Integer value);
0070   
0071   //! Initializes an AsciiString with a real value
0072   Standard_EXPORT TCollection_AsciiString(const Standard_Real value);
0073   
0074   //! Initializes a AsciiString with another AsciiString.
0075   Standard_EXPORT TCollection_AsciiString(const TCollection_AsciiString& astring);
0076 
0077   //! Move constructor
0078   TCollection_AsciiString (TCollection_AsciiString&& theOther) Standard_Noexcept
0079   : mystring (theOther.mystring),
0080     mylength (theOther.mylength)
0081   {
0082     theOther.mystring = NULL;
0083     theOther.mylength = 0;
0084   }
0085   
0086   //! Initializes a AsciiString with copy of another AsciiString
0087   //! concatenated with the message character.
0088   Standard_EXPORT TCollection_AsciiString(const TCollection_AsciiString& astring, const Standard_Character message);
0089   
0090   //! Initializes a AsciiString with copy of another AsciiString
0091   //! concatenated with the message string.
0092   Standard_EXPORT TCollection_AsciiString(const TCollection_AsciiString& astring, const Standard_CString message);
0093   
0094   //! Initializes a AsciiString with copy of another AsciiString
0095   //! concatenated with the message string.
0096   Standard_EXPORT TCollection_AsciiString(const TCollection_AsciiString& astring, const TCollection_AsciiString& message);
0097   
0098   //! Creation by converting an extended string to an ascii string.
0099   //! If replaceNonAscii is non-null character, it will be used
0100   //! in place of any non-ascii character found in the source string.
0101   //! Otherwise, creates UTF-8 unicode string.
0102   Standard_EXPORT TCollection_AsciiString(const TCollection_ExtendedString& astring, const Standard_Character replaceNonAscii = 0);
0103 
0104 #if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
0105   //! Initialize UTF-8 Unicode string from wide-char string considering it as Unicode string
0106   //! (the size of wide char is a platform-dependent - e.g. on Windows wchar_t is UTF-16).
0107   //!
0108   //! This constructor is unavailable if application is built with deprecated msvc option "-Zc:wchar_t-",
0109   //! since OCCT itself is never built with this option.
0110   Standard_EXPORT TCollection_AsciiString (const Standard_WideChar* theStringUtf);
0111 #endif
0112 
0113   //! Appends <other>  to me. This is an unary operator.
0114   Standard_EXPORT void AssignCat (const Standard_Character other);
0115 void operator += (const Standard_Character other)
0116 {
0117   AssignCat(other);
0118 }
0119   
0120   //! Appends <other>  to me. This is an unary operator.
0121   Standard_EXPORT void AssignCat (const Standard_Integer other);
0122 void operator += (const Standard_Integer other)
0123 {
0124   AssignCat(other);
0125 }
0126   
0127   //! Appends <other>  to me. This is an unary operator.
0128   Standard_EXPORT void AssignCat (const Standard_Real other);
0129 void operator += (const Standard_Real other)
0130 {
0131   AssignCat(other);
0132 }
0133   
0134   //! Appends <other>  to me. This is an unary operator.
0135   //! ex: aString += "Dummy"
0136   //! To catenate more than one CString, you must put a
0137   //! AsciiString before.
0138   //! Example: aString += "Hello " + "Dolly"  IS NOT VALID !
0139   //! But astring += anotherString + "Hello " + "Dolly" is valid.
0140   Standard_EXPORT void AssignCat (const Standard_CString other);
0141 void operator += (const Standard_CString other)
0142 {
0143   AssignCat(other);
0144 }
0145   
0146   //! Appends <other> to me. This is an unary operator.
0147   //! Example: aString += anotherString
0148   Standard_EXPORT void AssignCat (const TCollection_AsciiString& other);
0149 void operator += (const TCollection_AsciiString& other)
0150 {
0151   AssignCat(other);
0152 }
0153   
0154   //! Converts the first character into its corresponding
0155   //! upper-case character and the other characters into lowercase
0156   //! Example: before
0157   //! me = "hellO "
0158   //! after
0159   //! me = "Hello "
0160   Standard_EXPORT void Capitalize();
0161   
0162   //! Appends <other>  to me.
0163   //! Syntax:
0164   //! aString = aString + "Dummy"
0165   //! Example: aString contains "I say "
0166   //! aString = aString + "Hello " + "Dolly"
0167   //! gives "I say Hello Dolly"
0168   //! To catenate more than one CString, you must put a String before.
0169   //! So the following example is WRONG !
0170   //! aString = "Hello " + "Dolly"  THIS IS NOT ALLOWED
0171   //! This rule is applicable to AssignCat (operator +=) too.
0172     TCollection_AsciiString Cat (const Standard_Character other) const;
0173   TCollection_AsciiString operator + (const Standard_Character other) const
0174 {
0175   return Cat(other);
0176 }
0177   
0178   //! Appends <other>  to me.
0179   //! Syntax:
0180   //! aString = aString + 15;
0181   //! Example: aString contains "I say "
0182   //! gives "I say 15"
0183   //! To catenate more than one CString, you must put a String before.
0184   //! So the following example is WRONG !
0185   //! aString = "Hello " + "Dolly"  THIS IS NOT ALLOWED
0186   //! This rule is applicable to AssignCat (operator +=) too.
0187     TCollection_AsciiString Cat (const Standard_Integer other) const;
0188   TCollection_AsciiString operator + (const Standard_Integer other) const
0189 {
0190   return Cat(other);
0191 }
0192   
0193   //! Appends <other>  to me.
0194   //! Syntax:
0195   //! aString = aString + 15.15;
0196   //! Example: aString contains "I say "
0197   //! gives "I say 15.15"
0198   //! To catenate more than one CString, you must put a String before.
0199   //! So the following example is WRONG !
0200   //! aString = "Hello " + "Dolly"  THIS IS NOT ALLOWED
0201   //! This rule is applicable to AssignCat (operator +=) too.
0202     TCollection_AsciiString Cat (const Standard_Real other) const;
0203   TCollection_AsciiString operator + (const Standard_Real other) const
0204 {
0205   return Cat(other);
0206 }
0207   
0208   //! Appends <other>  to me.
0209   //! Syntax:
0210   //! aString = aString + "Dummy"
0211   //! Example: aString contains "I say "
0212   //! aString = aString + "Hello " + "Dolly"
0213   //! gives "I say Hello Dolly"
0214   //! To catenate more than one CString, you must put a String before.
0215   //! So the following example is WRONG !
0216   //! aString = "Hello " + "Dolly"  THIS IS NOT ALLOWED
0217   //! This rule is applicable to AssignCat (operator +=) too.
0218     TCollection_AsciiString Cat (const Standard_CString other) const;
0219   TCollection_AsciiString operator + (const Standard_CString other) const
0220 {
0221   return Cat(other);
0222 }
0223   
0224   //! Appends <other> to me.
0225   //! Example: aString = aString + anotherString
0226     TCollection_AsciiString Cat (const TCollection_AsciiString& other) const;
0227   TCollection_AsciiString operator + (const TCollection_AsciiString& other) const
0228 {
0229   return Cat(other);
0230 }
0231   
0232   //! Modifies this ASCII string so that its length
0233   //! becomes equal to Width and the new characters
0234   //! are equal to Filler. New characters are added
0235   //! both at the beginning and at the end of this string.
0236   //! If Width is less than the length of this ASCII string, nothing happens.
0237   //! Example
0238   //! TCollection_AsciiString
0239   //! myAlphabet("abcdef");
0240   //! myAlphabet.Center(9,' ');
0241   //! assert ( myAlphabet == "
0242   //! abcdef " );
0243   Standard_EXPORT void Center (const Standard_Integer Width, const Standard_Character Filler);
0244   
0245   //! Substitutes all the characters equal to aChar by NewChar
0246   //! in the AsciiString <me>.
0247   //! The substitution can be case sensitive.
0248   //! If you don't use default case sensitive, no matter whether aChar
0249   //! is uppercase or not.
0250   //! Example: me = "Histake" -> ChangeAll('H','M',Standard_True)
0251   //! gives me = "Mistake"
0252   Standard_EXPORT void ChangeAll (const Standard_Character aChar, const Standard_Character NewChar, const Standard_Boolean CaseSensitive = Standard_True);
0253   
0254   //! Removes all characters contained in <me>.
0255   //! This produces an empty AsciiString.
0256   Standard_EXPORT void Clear();
0257   
0258   //! Copy <fromwhere> to <me>.
0259   //! Used as operator =
0260   //! Example: aString = anotherCString;
0261   Standard_EXPORT void Copy (const Standard_CString fromwhere);
0262 void operator = (const Standard_CString fromwhere)
0263 {
0264   Copy(fromwhere);
0265 }
0266   
0267   //! Copy <fromwhere> to <me>.
0268   //! Used as operator =
0269   //! Example: aString = anotherString;
0270   Standard_EXPORT void Copy (const TCollection_AsciiString& fromwhere);
0271 void operator = (const TCollection_AsciiString& fromwhere)
0272 {
0273   Copy(fromwhere);
0274 }
0275 
0276   //! Exchange the data of two strings (without reallocating memory).
0277   Standard_EXPORT void Swap (TCollection_AsciiString& theOther);
0278 
0279   //! Move assignment operator
0280   TCollection_AsciiString& operator= (TCollection_AsciiString&& theOther) Standard_Noexcept { Swap (theOther); return *this; }
0281 
0282   //! Frees memory allocated by AsciiString.
0283   Standard_EXPORT ~TCollection_AsciiString();
0284   
0285   //! Returns the index of the first character of <me> that is
0286   //! present in <Set>.
0287   //! The search begins to the index FromIndex and ends to the
0288   //! the index ToIndex.
0289   //! Returns zero if failure.
0290   //! Raises an exception if FromIndex or ToIndex is out of range.
0291   //! Example: before
0292   //! me = "aabAcAa", S = "Aa", FromIndex = 1, Toindex = 7
0293   //! after
0294   //! me = "aabAcAa"
0295   //! returns
0296   //! 1
0297   Standard_EXPORT Standard_Integer FirstLocationInSet (const TCollection_AsciiString& Set, const Standard_Integer FromIndex, const Standard_Integer ToIndex) const;
0298   
0299   //! Returns the index of the first character of <me>
0300   //! that is not present in the set <Set>.
0301   //! The search begins to the index FromIndex and ends to the
0302   //! the index ToIndex in <me>.
0303   //! Returns zero if failure.
0304   //! Raises an exception if FromIndex or ToIndex is out of range.
0305   //! Example: before
0306   //! me = "aabAcAa", S = "Aa", FromIndex = 1, Toindex = 7
0307   //! after
0308   //! me = "aabAcAa"
0309   //! returns
0310   //! 3
0311   Standard_EXPORT Standard_Integer FirstLocationNotInSet (const TCollection_AsciiString& Set, const Standard_Integer FromIndex, const Standard_Integer ToIndex) const;
0312   
0313   //! Inserts a Character at position <where>.
0314   //! Example:
0315   //! aString contains "hy not ?"
0316   //! aString.Insert(1,'W'); gives "Why not ?"
0317   //! aString contains "Wh"
0318   //! aString.Insert(3,'y'); gives "Why"
0319   //! aString contains "Way"
0320   //! aString.Insert(2,'h'); gives "Why"
0321   Standard_EXPORT void Insert (const Standard_Integer where, const Standard_Character what);
0322   
0323   //! Inserts a CString at position <where>.
0324   //! Example:
0325   //! aString contains "O more"
0326   //! aString.Insert(2,"nce");  gives "Once more"
0327   Standard_EXPORT void Insert (const Standard_Integer where, const Standard_CString what);
0328   
0329   //! Inserts a AsciiString at position <where>.
0330   Standard_EXPORT void Insert (const Standard_Integer where, const TCollection_AsciiString& what);
0331   
0332   //! Pushing a string after a specific index in the string <me>.
0333   //! Raises an exception if Index is out of bounds.
0334   //! -   less than 0 (InsertAfter), or less than 1 (InsertBefore), or
0335   //! -   greater than the number of characters in this ASCII string.
0336   //! Example:
0337   //! before
0338   //! me = "cde" , Index = 0 , other = "ab"
0339   //! after
0340   //! me = "abcde" , other = "ab"
0341   Standard_EXPORT void InsertAfter (const Standard_Integer Index, const TCollection_AsciiString& other);
0342   
0343   //! Pushing a string before a specific index in the string <me>.
0344   //! Raises an exception if Index is out of bounds.
0345   //! -   less than 0 (InsertAfter), or less than 1 (InsertBefore), or
0346   //! -   greater than the number of characters in this ASCII string.
0347   //! Example:
0348   //! before
0349   //! me = "cde" , Index = 1 , other = "ab"
0350   //! after
0351   //! me = "abcde" , other = "ab"
0352   Standard_EXPORT void InsertBefore (const Standard_Integer Index, const TCollection_AsciiString& other);
0353   
0354   //! Returns True if the string <me> contains zero character.
0355   Standard_Boolean IsEmpty() const { return mylength == 0; }
0356 
0357   //! Returns true if the characters in this ASCII string
0358   //! are identical to the characters in ASCII string other.
0359   //! Note that this method is an alias of operator ==.
0360   Standard_EXPORT Standard_Boolean IsEqual (const Standard_CString other) const;
0361 Standard_Boolean operator == (const Standard_CString other) const
0362 {
0363   return IsEqual(other);
0364 }
0365   
0366   //! Returns true if the characters in this ASCII string
0367   //! are identical to the characters in ASCII string other.
0368   //! Note that this method is an alias of operator ==.
0369   Standard_EXPORT Standard_Boolean IsEqual (const TCollection_AsciiString& other) const;
0370 Standard_Boolean operator == (const TCollection_AsciiString& other) const
0371 {
0372   return IsEqual(other);
0373 }
0374   
0375   //! Returns true if there are differences between the
0376   //! characters in this ASCII string and ASCII string other.
0377   //! Note that this method is an alias of operator !=
0378   Standard_EXPORT Standard_Boolean IsDifferent (const Standard_CString other) const;
0379 Standard_Boolean operator != (const Standard_CString other) const
0380 {
0381   return IsDifferent(other);
0382 }
0383   
0384   //! Returns true if there are differences between the
0385   //! characters in this ASCII string and ASCII string other.
0386   //! Note that this method is an alias of operator !=
0387   Standard_EXPORT Standard_Boolean IsDifferent (const TCollection_AsciiString& other) const;
0388 Standard_Boolean operator != (const TCollection_AsciiString& other) const
0389 {
0390   return IsDifferent(other);
0391 }
0392   
0393   //! Returns TRUE if <me> is 'ASCII' less than <other>.
0394   Standard_EXPORT Standard_Boolean IsLess (const Standard_CString other) const;
0395 Standard_Boolean operator < (const Standard_CString other) const
0396 {
0397   return IsLess(other);
0398 }
0399   
0400   //! Returns TRUE if <me> is 'ASCII' less than <other>.
0401   Standard_EXPORT Standard_Boolean IsLess (const TCollection_AsciiString& other) const;
0402 Standard_Boolean operator < (const TCollection_AsciiString& other) const
0403 {
0404   return IsLess(other);
0405 }
0406   
0407   //! Returns TRUE if <me> is 'ASCII' greater than <other>.
0408   Standard_EXPORT Standard_Boolean IsGreater (const Standard_CString other) const;
0409 Standard_Boolean operator > (const Standard_CString other) const
0410 {
0411   return IsGreater(other);
0412 }
0413   
0414   //! Returns TRUE if <me> is 'ASCII' greater than <other>.
0415   Standard_EXPORT Standard_Boolean IsGreater (const TCollection_AsciiString& other) const;
0416 Standard_Boolean operator > (const TCollection_AsciiString& other) const
0417 {
0418   return IsGreater(other);
0419 }
0420 
0421   //! Determines whether the beginning of this string instance matches the specified string.
0422   Standard_EXPORT Standard_Boolean StartsWith (const TCollection_AsciiString& theStartString) const;
0423 
0424   //! Determines whether the end of this string instance matches the specified string.
0425   Standard_EXPORT Standard_Boolean EndsWith (const TCollection_AsciiString& theEndString) const;
0426 
0427   //! Converts a AsciiString containing a numeric expression to
0428   //! an Integer.
0429   //! Example: "215" returns 215.
0430   Standard_EXPORT Standard_Integer IntegerValue() const;
0431   
0432   //! Returns True if the AsciiString contains an integer value.
0433   //! Note: an integer value is considered to be a real value as well.
0434   Standard_EXPORT Standard_Boolean IsIntegerValue() const;
0435   
0436   //! Returns True if the AsciiString starts with some characters that can be interpreted as integer or real value.
0437   //! @param theToCheckFull [in] when TRUE, checks if entire string defines a real value;
0438   //!                            otherwise checks if string starts with a real value
0439   //! Note: an integer value is considered to be a real value as well.
0440   Standard_EXPORT Standard_Boolean IsRealValue (Standard_Boolean theToCheckFull = Standard_False) const;
0441   
0442   //! Returns True if the AsciiString contains only ASCII characters
0443   //! between ' ' and '~'.
0444   //! This means no control character and no extended ASCII code.
0445   Standard_EXPORT Standard_Boolean IsAscii() const;
0446   
0447   //! Removes all space characters in the beginning of the string.
0448   Standard_EXPORT void LeftAdjust();
0449   
0450   //! left justify
0451   //! Length becomes equal to Width and the new characters are
0452   //! equal to Filler.
0453   //! If Width < Length nothing happens.
0454   //! Raises an exception if Width is less than zero.
0455   //! Example:
0456   //! before
0457   //! me = "abcdef" , Width = 9 , Filler = ' '
0458   //! after
0459   //! me = "abcdef   "
0460   Standard_EXPORT void LeftJustify (const Standard_Integer Width, const Standard_Character Filler);
0461   
0462   //! Returns number of characters in <me>.
0463   //! This is the same functionality as 'strlen' in C.
0464   //! Example
0465   //! TCollection_AsciiString myAlphabet("abcdef");
0466   //! assert ( myAlphabet.Length() == 6 );
0467   //! -   1 is the position of the first character in this string.
0468   //! -   The length of this string gives the position of its last character.
0469   //! -   Positions less than or equal to zero, or
0470   //! greater than the length of this string are
0471   //! invalid in functions which identify a character
0472   //! of this string by its position.
0473     Standard_Integer Length() const;
0474   
0475   //! Returns an index in the string <me> of the first occurrence
0476   //! of the string S in the string <me> from the starting index
0477   //! FromIndex to the ending index ToIndex
0478   //! returns zero if failure
0479   //! Raises an exception if FromIndex or ToIndex is out of range.
0480   //! Example:
0481   //! before
0482   //! me = "aabAaAa", S = "Aa", FromIndex = 1, ToIndex = 7
0483   //! after
0484   //! me = "aabAaAa"
0485   //! returns
0486   //! 4
0487   Standard_EXPORT Standard_Integer Location (const TCollection_AsciiString& other, const Standard_Integer FromIndex, const Standard_Integer ToIndex) const;
0488   
0489   //! Returns the index of the nth occurrence of the character C
0490   //! in the string <me> from the starting index FromIndex to the
0491   //! ending index ToIndex.
0492   //! Returns zero if failure.
0493   //! Raises an exception if FromIndex or ToIndex is out of range.
0494   //! Example:
0495   //! before
0496   //! me = "aabAa", N = 3, C = 'a', FromIndex = 1, ToIndex = 5
0497   //! after
0498   //! me = "aabAa"
0499   //! returns
0500   //! 5
0501   Standard_EXPORT Standard_Integer Location (const Standard_Integer N, const Standard_Character C, const Standard_Integer FromIndex, const Standard_Integer ToIndex) const;
0502   
0503   //! Converts <me> to its lower-case equivalent.
0504   //! Example
0505   //! TCollection_AsciiString myString("Hello Dolly");
0506   //! myString.UpperCase();
0507   //! assert ( myString == "HELLO DOLLY" );
0508   //! myString.LowerCase();
0509   //! assert ( myString == "hello dolly" );
0510   Standard_EXPORT void LowerCase();
0511   
0512   //! Inserts the string other at the beginning of this ASCII string.
0513   //! Example
0514   //! TCollection_AsciiString myAlphabet("cde");
0515   //! TCollection_AsciiString myBegin("ab");
0516   //! myAlphabet.Prepend(myBegin);
0517   //! assert ( myAlphabet == "abcde" );
0518   Standard_EXPORT void Prepend (const TCollection_AsciiString& other);
0519   
0520   //! Displays <me> on a stream.
0521   Standard_EXPORT void Print (Standard_OStream& astream) const;
0522 friend Standard_EXPORT Standard_OStream& operator << (Standard_OStream& astream,const TCollection_AsciiString& astring);
0523   
0524   //! Read <me> from a stream.
0525   Standard_EXPORT void Read (Standard_IStream& astream);
0526 friend Standard_EXPORT Standard_IStream& operator >> (Standard_IStream& astream, TCollection_AsciiString& astring);
0527   
0528   //! Converts an AsciiString containing a numeric expression.
0529   //! to a Real.
0530   //! Example: ex: "215" returns 215.0.
0531   //! ex: "3.14159267" returns 3.14159267.
0532   Standard_EXPORT Standard_Real RealValue() const;
0533   
0534   //! Remove all the occurrences of the character C in the string.
0535   //! Example:
0536   //! before
0537   //! me = "HellLLo", C = 'L' , CaseSensitive = True
0538   //! after
0539   //! me = "Hello"
0540   Standard_EXPORT void RemoveAll (const Standard_Character C, const Standard_Boolean CaseSensitive);
0541   
0542   //! Removes every <what> characters from <me>.
0543   Standard_EXPORT void RemoveAll (const Standard_Character what);
0544   
0545   //! Erases <ahowmany> characters from position <where>,
0546   //! <where> included.
0547   //! Example:
0548   //! aString contains "Hello"
0549   //! aString.Remove(2,2) erases 2 characters from position 2
0550   //! This gives "Hlo".
0551   Standard_EXPORT void Remove (const Standard_Integer where, const Standard_Integer ahowmany = 1);
0552   
0553   //! Removes all space characters at the end of the string.
0554   Standard_EXPORT void RightAdjust();
0555   
0556   //! Right justify.
0557   //! Length becomes equal to Width and the new characters are
0558   //! equal to Filler.
0559   //! if Width < Length nothing happens.
0560   //! Raises an exception if Width is less than zero.
0561   //! Example:
0562   //! before
0563   //! me = "abcdef" , Width = 9 , Filler = ' '
0564   //! after
0565   //! me = "   abcdef"
0566   Standard_EXPORT void RightJustify (const Standard_Integer Width, const Standard_Character Filler);
0567   
0568   //! Searches a CString in <me> from the beginning
0569   //! and returns position of first item <what> matching.
0570   //! it returns -1 if not found.
0571   //! Example:
0572   //! aString contains "Sample single test"
0573   //! aString.Search("le") returns 5
0574   Standard_EXPORT Standard_Integer Search (const Standard_CString what) const;
0575   
0576   //! Searches an AsciiString in <me> from the beginning
0577   //! and returns position of first item <what> matching.
0578   //! It returns -1 if not found.
0579   Standard_EXPORT Standard_Integer Search (const TCollection_AsciiString& what) const;
0580   
0581   //! Searches a CString in a AsciiString from the end
0582   //! and returns position of first item <what> matching.
0583   //! It returns -1 if not found.
0584   //! Example:
0585   //! aString contains "Sample single test"
0586   //! aString.SearchFromEnd("le") returns 12
0587   Standard_EXPORT Standard_Integer SearchFromEnd (const Standard_CString what) const;
0588   
0589   //! Searches a AsciiString in another AsciiString from the end
0590   //! and returns position of first item <what> matching.
0591   //! It returns -1 if not found.
0592   Standard_EXPORT Standard_Integer SearchFromEnd (const TCollection_AsciiString& what) const;
0593   
0594   //! Replaces one character in the AsciiString at position <where>.
0595   //! If <where> is less than zero or greater than the length of <me>
0596   //! an exception is raised.
0597   //! Example:
0598   //! aString contains "Garbake"
0599   //! astring.Replace(6,'g')  gives <me> = "Garbage"
0600   Standard_EXPORT void SetValue (const Standard_Integer where, const Standard_Character what);
0601   
0602   //! Replaces a part of <me> by a CString.
0603   //! If <where> is less than zero or greater than the length of <me>
0604   //! an exception is raised.
0605   //! Example:
0606   //! aString contains "abcde"
0607   //! aString.SetValue(4,"1234567") gives <me> = "abc1234567"
0608   Standard_EXPORT void SetValue (const Standard_Integer where, const Standard_CString what);
0609   
0610   //! Replaces a part of <me> by another AsciiString.
0611   Standard_EXPORT void SetValue (const Standard_Integer where, const TCollection_AsciiString& what);
0612   
0613   //! Splits a AsciiString into two sub-strings.
0614   //! Example:
0615   //! aString contains "abcdefg"
0616   //! aString.Split(3) gives <me> = "abc" and returns "defg"
0617   Standard_EXPORT TCollection_AsciiString Split (const Standard_Integer where);
0618   
0619   //! Creation of a sub-string of the string <me>.
0620   //! The sub-string starts to the index Fromindex and ends
0621   //! to the index ToIndex.
0622   //! Raises an exception if ToIndex or FromIndex is out of bounds
0623   //! Example:
0624   //! before
0625   //! me = "abcdefg", ToIndex=3, FromIndex=6
0626   //! after
0627   //! me = "abcdefg"
0628   //! returns
0629   //! "cdef"
0630     TCollection_AsciiString SubString (const Standard_Integer FromIndex, const Standard_Integer ToIndex) const;
0631   
0632   //! Returns pointer to AsciiString (char *).
0633   //! This is useful for some casual manipulations.
0634   //! Warning: Because this "char *" is 'const', you can't modify its contents.
0635     Standard_CString ToCString() const;
0636   
0637   //! Extracts <whichone> token from <me>.
0638   //! By default, the <separators> is set to space and tabulation.
0639   //! By default, the token extracted is the first one (whichone = 1).
0640   //! <separators> contains all separators you need.
0641   //! If no token indexed by <whichone> is found, it returns empty AsciiString.
0642   //! Example:
0643   //! aString contains "This is a     message"
0644   //! aString.Token()  returns "This"
0645   //! aString.Token(" ",4) returns "message"
0646   //! aString.Token(" ",2) returns "is"
0647   //! aString.Token(" ",9) returns ""
0648   //! Other separators than space character and tabulation are allowed :
0649   //! aString contains "1234; test:message   , value"
0650   //! aString.Token("; :,",4) returns "value"
0651   //! aString.Token("; :,",2) returns "test"
0652   Standard_EXPORT TCollection_AsciiString Token (const Standard_CString separators = " \t", const Standard_Integer whichone = 1) const;
0653   
0654   //! Truncates <me> to <ahowmany> characters.
0655   //! Example:  me = "Hello Dolly" -> Trunc(3) -> me = "Hel"
0656   Standard_EXPORT void Trunc (const Standard_Integer ahowmany);
0657   
0658   //! Converts <me> to its upper-case equivalent.
0659   Standard_EXPORT void UpperCase();
0660   
0661   //! Length of the string ignoring all spaces (' ') and the
0662   //! control character at the end.
0663   Standard_EXPORT Standard_Integer UsefullLength() const;
0664   
0665   //! Returns character at position <where> in <me>.
0666   //! If <where> is less than zero or greater than the length of <me>,
0667   //! an exception is raised.
0668   //! Example:
0669   //! aString contains "Hello"
0670   //! aString.Value(2) returns 'e'
0671   Standard_EXPORT Standard_Character Value (const Standard_Integer where) const;
0672   
0673   //! Computes a hash code for the given ASCII string, in the range [1, theUpperBound].
0674   //! Returns the same integer value as the hash function for TCollection_ExtendedString
0675   //! @param theAsciiString the ASCII string which hash code is to be computed
0676   //! @param theUpperBound the upper bound of the range a computing hash code must be within
0677   //! @return a computed hash code, in the range [1, theUpperBound]
0678   static Standard_Integer HashCode (const TCollection_AsciiString& theAsciiString, Standard_Integer theUpperBound);
0679 
0680   //! Returns True  when the two  strings are the same.
0681   //! (Just for HashCode for AsciiString)
0682     static Standard_Boolean IsEqual (const TCollection_AsciiString& string1, const TCollection_AsciiString& string2);
0683   
0684   //! Returns True  when the two  strings are the same.
0685   //! (Just for HashCode for AsciiString)
0686     static Standard_Boolean IsEqual (const TCollection_AsciiString& string1, const Standard_CString string2);
0687 
0688   //! Returns True if the strings contain same characters.
0689   Standard_EXPORT static Standard_Boolean IsSameString (const TCollection_AsciiString& theString1,
0690                                                         const TCollection_AsciiString& theString2,
0691                                                         const Standard_Boolean theIsCaseSensitive);
0692 
0693 friend class TCollection_HAsciiString;
0694 
0695 private:
0696 
0697   Standard_EXPORT void Split (const Standard_Integer where, TCollection_AsciiString& result);
0698   
0699   Standard_EXPORT void SubString (const Standard_Integer FromIndex, const Standard_Integer ToIndex, TCollection_AsciiString& result) const;
0700   
0701   Standard_EXPORT void Token (const Standard_CString separators, const Standard_Integer whichone, TCollection_AsciiString& result) const;
0702 
0703 private:
0704 
0705   Standard_PCharacter mystring; //!< NULL-terminated string
0706   Standard_Integer    mylength; //!< length in bytes (excluding terminating NULL symbol)
0707 
0708 };
0709 
0710 #include <TCollection_AsciiString.lxx>
0711 
0712 #endif // _TCollection_AsciiString_HeaderFile