Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-02 09:14:12

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 
0031 #if Standard_CPP17_OR_HIGHER
0032   #include <string_view>
0033 #endif
0034 
0035 class TCollection_ExtendedString;
0036 
0037 //! Class defines a variable-length sequence of 8-bit characters.
0038 //! Despite class name (kept for historical reasons), it is intended to store UTF-8 string, not just
0039 //! ASCII characters. However, multi-byte nature of UTF-8 is not considered by the following
0040 //! methods:
0041 //! - Method ::Length() return the number of bytes, not the number of Unicode symbols.
0042 //! - Methods taking/returning symbol index work with 8-bit code units, not true Unicode symbols,
0043 //!   including ::Remove(), ::SetValue(), ::Value(), ::Search(), ::Trunc() and others.
0044 //! If application needs to process multi-byte Unicode symbols explicitly,
0045 //! NCollection_UtfIterator<char> class can be used for iterating through Unicode string (UTF-32
0046 //! code unit will be returned for each position).
0047 //!
0048 //! Class provides editing operations with built-in memory management to make AsciiString objects
0049 //! easier to use than ordinary character arrays. AsciiString objects follow value semantics; in
0050 //! other words, they are the actual strings, not handles to strings, and are copied through
0051 //! assignment. You may use HAsciiString objects to get handles to strings.
0052 class TCollection_AsciiString
0053 {
0054 public:
0055   DEFINE_STANDARD_ALLOC
0056 
0057   //! Initializes a AsciiString to an empty AsciiString.
0058   Standard_EXPORT TCollection_AsciiString() noexcept;
0059 
0060 #if Standard_CPP17_OR_HIGHER
0061   //! Initializes a AsciiString with a string_view.
0062   //! @param[in] theStringView the string view to initialize from
0063   explicit inline TCollection_AsciiString(const std::string_view& theStringView);
0064 #endif
0065 
0066   //! Initializes a AsciiString with a CString (null-terminated).
0067   //! @param[in] theMessage the C string to initialize from
0068   inline TCollection_AsciiString(const char* const theMessage);
0069 
0070   //! Initializes a AsciiString with a CString and explicit length.
0071   //! @param[in] theMessage the C string to initialize from
0072   //! @param[in] theLength the length of the string
0073   Standard_EXPORT TCollection_AsciiString(const char* const theMessage, const int theLength);
0074 
0075   //! Initializes a AsciiString with a single character.
0076   //! @param[in] theChar the character to initialize from
0077   Standard_EXPORT TCollection_AsciiString(const char theChar);
0078 
0079   //! Initializes an AsciiString with specified length space allocated
0080   //! and filled with filler character. This is useful for buffers.
0081   //! @param[in] theLength the length to allocate
0082   //! @param[in] theFiller the character to fill with
0083   Standard_EXPORT TCollection_AsciiString(const int theLength, const char theFiller);
0084 
0085   //! Initializes an AsciiString with an integer value
0086   //! @param[in] theValue the integer value to convert to string
0087   Standard_EXPORT TCollection_AsciiString(const int theValue);
0088 
0089   //! Initializes an AsciiString with a real value
0090   //! @param[in] theValue the real value to convert to string
0091   Standard_EXPORT TCollection_AsciiString(const double theValue);
0092 
0093   //! Initializes a AsciiString with another AsciiString.
0094   //! @param[in] theString the string to copy from
0095   Standard_EXPORT TCollection_AsciiString(const TCollection_AsciiString& theString);
0096 
0097   //! Move constructor
0098   //! @param[in] theOther the string to move from
0099   Standard_EXPORT TCollection_AsciiString(TCollection_AsciiString&& theOther) noexcept;
0100 
0101   //! Initializes a AsciiString with copy of another AsciiString
0102   //! concatenated with the message character.
0103   //! @param[in] theString the string to copy
0104   //! @param[in] theChar the character to append
0105   Standard_EXPORT TCollection_AsciiString(const TCollection_AsciiString& theString,
0106                                           const char                     theChar);
0107 
0108   //! Initializes a AsciiString with copy of another AsciiString
0109   //! concatenated with the message string.
0110   //! @param[in] theString the string to copy
0111   //! @param[in] theMessage the C string to append
0112   Standard_EXPORT TCollection_AsciiString(const TCollection_AsciiString& theString,
0113                                           const char* const              theMessage);
0114 
0115   //! Initializes a AsciiString with copy of another AsciiString
0116   //! concatenated with the message string.
0117   //! @param[in] theString the string to copy
0118   //! @param[in] theOtherString the string to append
0119   Standard_EXPORT TCollection_AsciiString(const TCollection_AsciiString& theString,
0120                                           const TCollection_AsciiString& theOtherString);
0121 
0122   //! Creation by converting an extended string to an ascii string.
0123   //! If replaceNonAscii is non-null character, it will be used
0124   //! in place of any non-ascii character found in the source string.
0125   //! Otherwise, creates UTF-8 unicode string.
0126   //! @param[in] theExtendedString the extended string to convert
0127   //! @param[in] theReplaceNonAscii replacement character for non-ASCII characters
0128   Standard_EXPORT TCollection_AsciiString(const TCollection_ExtendedString& theExtendedString,
0129                                           const char                        theReplaceNonAscii = 0);
0130 
0131 #if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
0132   //! Initialize UTF-8 Unicode string from wide-char string considering it as Unicode string
0133   //! (the size of wide char is a platform-dependent - e.g. on Windows wchar_t is UTF-16).
0134   //!
0135   //! This constructor is unavailable if application is built with deprecated msvc option
0136   //! "-Zc:wchar_t-", since OCCT itself is never built with this option.
0137   //! @param[in] theStringUtf the wide character string to convert
0138   Standard_EXPORT TCollection_AsciiString(const wchar_t* theStringUtf);
0139 #endif
0140 
0141   //! Template constructor for string literals or char arrays.
0142   //! @param[in] theLiteral the string literal or char array
0143   template <std::size_t N>
0144   inline TCollection_AsciiString(const char (&theLiteral)[N]);
0145 
0146   //! Appends other character to this string. This is an unary operator.
0147   //! @param[in] theOther the character to append
0148   Standard_EXPORT void AssignCat(const char theOther);
0149 
0150   void operator+=(const char theOther) { AssignCat(theOther); }
0151 
0152   //! Appends other integer to this string. This is an unary operator.
0153   //! @param[in] theOther the integer to append
0154   Standard_EXPORT void AssignCat(const int theOther);
0155 
0156   void operator+=(const int theOther) { AssignCat(theOther); }
0157 
0158   //! Appends other real number to this string. This is an unary operator.
0159   //! @param[in] theOther the real number to append
0160   Standard_EXPORT void AssignCat(const double theOther);
0161 
0162   void operator+=(const double theOther) { AssignCat(theOther); }
0163 
0164   //! Appends an extended string to this ASCII string.
0165   //! If theReplaceNonAscii is non-null character, it will be used
0166   //! in place of any non-ASCII character found in the source string.
0167   //! Otherwise, appends UTF-8 representation of the source string.
0168   //! @param[in] theOther the extended string to append
0169   //! @param[in] theReplaceNonAscii replacement character for non-ASCII characters
0170   Standard_EXPORT void AssignCat(const TCollection_ExtendedString& theOther,
0171                                  const char                        theReplaceNonAscii = 0);
0172 
0173   void operator+=(const TCollection_ExtendedString& theOther) { AssignCat(theOther); }
0174 
0175 #if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
0176   //! Appends wide-char string converted to UTF-8 representation.
0177   //! @param[in] theStringUtf the wide character string to append
0178   Standard_EXPORT void AssignCat(const wchar_t* theStringUtf);
0179 
0180   void operator+=(const wchar_t* theStringUtf) { AssignCat(theStringUtf); }
0181 #endif
0182 
0183   //! Core implementation: Appends string (pointer and length) to this ASCII string.
0184   //! This is the primary implementation that all other AssignCat overloads redirect to.
0185   //! @param[in] theString pointer to the string to append
0186   //! @param[in] theLength length of the string to append
0187   Standard_EXPORT void AssignCat(const char* const theString, const int theLength);
0188 
0189   //! Appends other string to this string. This is an unary operator.
0190   //!
0191   //! Example:
0192   //! ```cpp
0193   //! TCollection_AsciiString aString("Hello");
0194   //! TCollection_AsciiString anotherString(" World");
0195   //! aString += anotherString;
0196   //! // Result: aString == "Hello World"
0197   //! ```
0198   //! @param[in] theOther the string to append
0199   inline void AssignCat(const TCollection_AsciiString& theOther);
0200 
0201   void operator+=(const TCollection_AsciiString& theOther) { AssignCat(theOther); }
0202 
0203   //! Appends C string to this ASCII string.
0204   //! @param[in] theCString the C string to append
0205   inline void AssignCat(const char* const theCString);
0206 
0207   void operator+=(const char* const theCString) { AssignCat(theCString); }
0208 
0209 #if Standard_CPP17_OR_HIGHER
0210   //! Appends string view to this ASCII string. This is an unary operator.
0211   //! @param[in] theStringView the string view to append
0212   inline void AssignCat(const std::string_view& theStringView);
0213 
0214   void operator+=(const std::string_view& theStringView) { AssignCat(theStringView); }
0215 #endif
0216 
0217   //! Template method for appending string literals or char arrays.
0218   //! For true string literals (const char[N] in code), the size is known at compile time.
0219   //! For char arrays (like sprintf buffers), we need to call strlen to get actual length.
0220   //!
0221   //! Example:
0222   //! ```cpp
0223   //! TCollection_AsciiString aString("Hello");
0224   //! aString += " World";  // Size known at compile time for string literal
0225   //! char buffer[50]; sprintf(buffer, "test");
0226   //! aString += buffer;    // Uses strlen for actual length
0227   //! ```
0228   //! @param[in] theLiteral the string literal or char array to append
0229   template <std::size_t N>
0230   inline void AssignCat(const char (&theLiteral)[N]);
0231 
0232   template <std::size_t N>
0233   inline void operator+=(const char (&theLiteral)[N]);
0234 
0235   //! Converts the first character into its corresponding
0236   //! upper-case character and the other characters into lowercase
0237   //!
0238   //! Example:
0239   //! ```cpp
0240   //! TCollection_AsciiString aString("hellO ");
0241   //! aString.Capitalize();
0242   //! // Result: aString == "Hello "
0243   //! ```
0244   Standard_EXPORT void Capitalize();
0245 
0246   //! Core implementation: Appends string (pointer and length) to this ASCII string and returns
0247   //! a new string. This is the primary implementation that all other Cat overloads redirect to.
0248   //! @param[in] theString pointer to the string to append
0249   //! @param[in] theLength length of the string to append
0250   //! @return new string with the string appended
0251   Standard_EXPORT TCollection_AsciiString Cat(const char* const theString,
0252                                               const int         theLength) const;
0253 
0254   //! Appends other character to this string.
0255   //!
0256   //! Example:
0257   //! ```cpp
0258   //! TCollection_AsciiString aString("I say ");
0259   //! TCollection_AsciiString aResult = aString + '!';
0260   //! // Result: aResult == "I say !"
0261   //!
0262   //! // To catenate more, you must put a String before.
0263   //! // "Hello " + "Dolly" // THIS IS NOT ALLOWED
0264   //! // This rule is applicable to AssignCat (operator +=) too.
0265   //! ```
0266   //! @param[in] theOther the character to append
0267   //! @return new string with character appended
0268   TCollection_AsciiString Cat(const char theOther) const { return Cat(&theOther, 1); }
0269 
0270   inline TCollection_AsciiString operator+(const char theOther) const;
0271 
0272   //! Appends other integer to this string.
0273   //!
0274   //! Example:
0275   //! ```cpp
0276   //! TCollection_AsciiString aString("I say ");
0277   //! TCollection_AsciiString aResult = aString + 15;
0278   //! // Result: aResult == "I say 15"
0279   //! ```
0280   //! @param[in] theOther the integer to append
0281   //! @return new string with integer appended
0282   Standard_EXPORT TCollection_AsciiString Cat(const int theOther) const;
0283 
0284   TCollection_AsciiString operator+(const int theOther) const { return Cat(theOther); }
0285 
0286   //! Appends other real number to this string.
0287   //!
0288   //! Example:
0289   //! ```cpp
0290   //! TCollection_AsciiString aString("I say ");
0291   //! TCollection_AsciiString aResult = aString + 15.15;
0292   //! // Result: aResult == "I say 15.15"
0293   //! ```
0294   //! @param[in] theOther the real number to append
0295   //! @return new string with real number appended
0296   Standard_EXPORT TCollection_AsciiString Cat(const double theOther) const;
0297 
0298   TCollection_AsciiString operator+(const double theOther) const { return Cat(theOther); }
0299 
0300   //! Appends extended string to this string.
0301   //! If theReplaceNonAscii is non-null character, it will be used
0302   //! in place of any non-ASCII character found in the source string.
0303   //! Otherwise, concatenates UTF-8 representation of the source string.
0304   //! @param[in] theOther the extended string to append
0305   //! @param[in] theReplaceNonAscii replacement character for non-ASCII characters
0306   //! @return new string with extended string appended
0307   Standard_EXPORT TCollection_AsciiString Cat(const TCollection_ExtendedString& theOther,
0308                                               const char theReplaceNonAscii = 0) const;
0309 
0310   TCollection_AsciiString operator+(const TCollection_ExtendedString& theOther) const
0311   {
0312     return Cat(theOther);
0313   }
0314 
0315 #if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
0316   //! Appends wide-char string converted to UTF-8 representation.
0317   //! @param[in] theStringUtf the wide character string to append
0318   //! @return new string with wide-char string appended
0319   Standard_EXPORT TCollection_AsciiString Cat(const wchar_t* theStringUtf) const;
0320 
0321   TCollection_AsciiString operator+(const wchar_t* theStringUtf) const { return Cat(theStringUtf); }
0322 #endif
0323 
0324   //! Appends other string to this string.
0325   //!
0326   //! Example:
0327   //! ```cpp
0328   //! TCollection_AsciiString aString("Hello");
0329   //! TCollection_AsciiString anotherString(" World");
0330   //! TCollection_AsciiString aResult = aString + anotherString;
0331   //! // Result: aResult == "Hello World"
0332   //! ```
0333   //! @param[in] theOther the string to append
0334   //! @return new string with other string appended
0335   inline TCollection_AsciiString Cat(const TCollection_AsciiString& theOther) const;
0336 
0337   inline TCollection_AsciiString operator+(const TCollection_AsciiString& theOther) const;
0338 
0339   //! Appends C string to this ASCII string.
0340   //! @param[in] theCString the C string to append
0341   //! @return new string with C string appended
0342   inline TCollection_AsciiString Cat(const char* const theCString) const;
0343 
0344   inline TCollection_AsciiString operator+(const char* const theCString) const;
0345 
0346 #if Standard_CPP17_OR_HIGHER
0347   //! Appends string view to this ASCII string.
0348   //! @param[in] theStringView the string view to append
0349   //! @return new string with string view appended
0350   inline TCollection_AsciiString Cat(const std::string_view& theStringView) const;
0351 
0352   inline TCollection_AsciiString operator+(const std::string_view& theStringView) const;
0353 #endif
0354 
0355   //! Template method for concatenating string literals or char arrays.
0356   //! For safety, uses strlen to get actual string length.
0357   //!
0358   //! Example:
0359   //! ```cpp
0360   //! TCollection_AsciiString aString("Hello");
0361   //! TCollection_AsciiString aResult = aString + " World";  // String literal
0362   //! char buffer[50]; sprintf(buffer, "test");
0363   //! aResult = aString + buffer;  // Char array - uses strlen
0364   //! // Result: aResult == "Hello test"
0365   //! ```
0366   //! @param[in] theLiteral the string literal or char array to concatenate
0367   //! @return new string with literal appended
0368   template <std::size_t N>
0369   inline TCollection_AsciiString Cat(const char (&theLiteral)[N]) const;
0370 
0371   template <std::size_t N>
0372   inline TCollection_AsciiString operator+(const char (&theLiteral)[N]) const;
0373 
0374   //! Modifies this ASCII string so that its length
0375   //! becomes equal to Width and the new characters
0376   //! are equal to Filler. New characters are added
0377   //! both at the beginning and at the end of this string.
0378   //! If Width is less than the length of this ASCII string, nothing happens.
0379   //!
0380   //! Example:
0381   //! ```cpp
0382   //! TCollection_AsciiString anAlphabet("abcdef");
0383   //! anAlphabet.Center(9, ' ');
0384   //! // Result: anAlphabet == " abcdef "
0385   //! ```
0386   //! @param[in] theWidth the desired width
0387   //! @param[in] theFiller the character to fill with
0388   Standard_EXPORT void Center(const int theWidth, const char theFiller);
0389 
0390   //! Substitutes all the characters equal to aChar by NewChar
0391   //! in this AsciiString.
0392   //! The substitution can be case sensitive.
0393   //! If you don't use default case sensitive, no matter whether aChar
0394   //! is uppercase or not.
0395   //!
0396   //! Example:
0397   //! ```cpp
0398   //! TCollection_AsciiString aString("Histake");
0399   //! aString.ChangeAll('H', 'M', true);
0400   //! // Result: aString == "Mistake"
0401   //! ```
0402   //! @param[in] theChar the character to replace
0403   //! @param[in] theNewChar the replacement character
0404   //! @param[in] theCaseSensitive flag indicating case sensitivity
0405   Standard_EXPORT void ChangeAll(const char theChar,
0406                                  const char theNewChar,
0407                                  const bool theCaseSensitive = true);
0408 
0409   //! Removes all characters contained in this string.
0410   //! This produces an empty AsciiString.
0411   Standard_EXPORT void Clear();
0412 
0413   //! Core implementation: Copy string (pointer and length) to this ASCII string.
0414   //! This is the primary implementation that all other Copy overloads redirect to.
0415   //! Used as operator =
0416   //! @param[in] theString pointer to the string to copy from
0417   //! @param[in] theLength length of the string to copy
0418   Standard_EXPORT void Copy(const char* const theString, const int theLength);
0419 
0420   //! Copy C string to this ASCII string.
0421   //! Used as operator =
0422   //! @param[in] theCString the C string to copy from
0423   inline void Copy(const char* const theCString);
0424 
0425   void operator=(const char* const theCString) { Copy(theCString); }
0426 
0427 #if Standard_CPP17_OR_HIGHER
0428   //! Copy string view to this ASCII string.
0429   //! Used as operator =
0430   //! @param[in] theStringView the string view to copy from
0431   inline void Copy(const std::string_view& theStringView);
0432 
0433   void operator=(const std::string_view& theStringView) { Copy(theStringView); }
0434 #endif
0435 
0436   //! Template method for copying string literals or char arrays.
0437   //! For safety, uses strlen to get actual string length.
0438   //!
0439   //! Example:
0440   //! ```cpp
0441   //! TCollection_AsciiString aString;
0442   //! aString = "Hello World";  // String literal
0443   //! char buffer[50]; sprintf(buffer, "test");
0444   //! aString = buffer;  // Char array - uses strlen
0445   //! // Result: aString == "test"
0446   //! ```
0447   //! @param[in] theLiteral the string literal or char array to copy from
0448   template <std::size_t N>
0449   inline void Copy(const char (&theLiteral)[N]);
0450 
0451   template <std::size_t N>
0452   inline void operator=(const char (&theLiteral)[N]);
0453 
0454   //! Copy fromwhere to this string.
0455   //! Used as operator =
0456   //!
0457   //! Example:
0458   //! ```cpp
0459   //! TCollection_AsciiString aString;
0460   //! TCollection_AsciiString anotherString("Hello World");
0461   //! aString = anotherString;  // operator=
0462   //! // Result: aString == "Hello World"
0463   //! ```
0464   inline void Copy(const TCollection_AsciiString& theFromWhere);
0465 
0466   //! Copy assignment operator
0467   inline TCollection_AsciiString& operator=(const TCollection_AsciiString& theOther);
0468 
0469   //! Moves string without reallocations
0470   //! @param[in] theOther the string to move from
0471   Standard_EXPORT void Move(TCollection_AsciiString&& theOther);
0472 
0473   //! Move assignment operator
0474   inline TCollection_AsciiString& operator=(TCollection_AsciiString&& theOther) noexcept;
0475 
0476   //! Exchange the data of two strings (without reallocating memory).
0477   //! @param[in,out] theOther the string to exchange data with
0478   Standard_EXPORT void Swap(TCollection_AsciiString& theOther);
0479 
0480   //! Frees memory allocated by AsciiString.
0481   Standard_EXPORT ~TCollection_AsciiString();
0482 
0483   //! Core implementation: Returns the index of the first character of this string that is
0484   //! present in the given character set (pointer and length).
0485   //! The search begins at index FromIndex and ends at index ToIndex.
0486   //! Returns zero if failure.
0487   //! Raises an exception if FromIndex or ToIndex is out of range.
0488   //! @param[in] theSet pointer to the set of characters to search for
0489   //! @param[in] theSetLength length of the set
0490   //! @param[in] theFromIndex the starting index for search
0491   //! @param[in] theToIndex the ending index for search
0492   //! @return the index of first character found in set, or 0 if not found
0493   Standard_EXPORT int FirstLocationInSet(const char* const theSet,
0494                                          const int         theSetLength,
0495                                          const int         theFromIndex,
0496                                          const int         theToIndex) const;
0497 
0498   //! Returns the index of the first character of this string that is
0499   //! present in Set.
0500   //! The search begins to the index FromIndex and ends to the
0501   //! the index ToIndex.
0502   //! Returns zero if failure.
0503   //! Raises an exception if FromIndex or ToIndex is out of range.
0504   //!
0505   //! Example:
0506   //! ```cpp
0507   //! TCollection_AsciiString aString("aabAcAa");
0508   //! TCollection_AsciiString aSet("Aa");
0509   //! int anIndex = aString.FirstLocationInSet(aSet, 1, 7);
0510   //! // Result: anIndex == 1
0511   //! ```
0512   //! @param[in] theSet the set of characters to search for
0513   //! @param[in] theFromIndex the starting index for search
0514   //! @param[in] theToIndex the ending index for search
0515   //! @return the index of first character found in set, or 0 if not found
0516   inline int FirstLocationInSet(const TCollection_AsciiString& theSet,
0517                                 const int                      theFromIndex,
0518                                 const int                      theToIndex) const;
0519 
0520 #if Standard_CPP17_OR_HIGHER
0521   //! Returns the index of the first character of this string that is present in string_view.
0522   //! @param[in] theSet the string view of characters to search for
0523   //! @param[in] theFromIndex the starting index for search
0524   //! @param[in] theToIndex the ending index for search
0525   //! @return the index of first character found in set, or 0 if not found
0526   inline int FirstLocationInSet(const std::string_view& theSet,
0527                                 const int               theFromIndex,
0528                                 const int               theToIndex) const;
0529 #endif
0530 
0531   //! Template method for FirstLocationInSet with string literals.
0532   //! @param[in] theLiteral the string literal of characters to search for
0533   //! @param[in] theFromIndex the starting index for search
0534   //! @param[in] theToIndex the ending index for search
0535   //! @return the index of first character found in set, or 0 if not found
0536   template <std::size_t N>
0537   inline int FirstLocationInSet(const char (&theLiteral)[N],
0538                                 const int theFromIndex,
0539                                 const int theToIndex) const;
0540 
0541   //! Core implementation: Returns the index of the first character of this string
0542   //! that is not present in the given character set (pointer and length).
0543   //! The search begins at index FromIndex and ends at index ToIndex.
0544   //! Returns zero if failure.
0545   //! Raises an exception if FromIndex or ToIndex is out of range.
0546   //! @param[in] theSet pointer to the set of characters to check against
0547   //! @param[in] theSetLength length of the set
0548   //! @param[in] theFromIndex the starting index for search
0549   //! @param[in] theToIndex the ending index for search
0550   //! @return the index of first character not in set, or 0 if not found
0551   Standard_EXPORT int FirstLocationNotInSet(const char* const theSet,
0552                                             const int         theSetLength,
0553                                             const int         theFromIndex,
0554                                             const int         theToIndex) const;
0555 
0556   //! Returns the index of the first character of this string
0557   //! that is not present in the set Set.
0558   //! The search begins to the index FromIndex and ends to the
0559   //! the index ToIndex in this string.
0560   //! Returns zero if failure.
0561   //! Raises an exception if FromIndex or ToIndex is out of range.
0562   //!
0563   //! Example:
0564   //! ```cpp
0565   //! TCollection_AsciiString aString("aabAcAa");
0566   //! TCollection_AsciiString aSet("Aa");
0567   //! int anIndex = aString.FirstLocationNotInSet(aSet, 1, 7);
0568   //! // Result: anIndex == 3
0569   //! ```
0570   //! @param[in] theSet the set of characters to check against
0571   //! @param[in] theFromIndex the starting index for search
0572   //! @param[in] theToIndex the ending index for search
0573   //! @return the index of first character not in set, or 0 if not found
0574   inline int FirstLocationNotInSet(const TCollection_AsciiString& theSet,
0575                                    const int                      theFromIndex,
0576                                    const int                      theToIndex) const;
0577 
0578 #if Standard_CPP17_OR_HIGHER
0579   //! Returns the index of the first character of this string that is not present in string_view.
0580   //! @param[in] theSet the string view of characters to check against
0581   //! @param[in] theFromIndex the starting index for search
0582   //! @param[in] theToIndex the ending index for search
0583   //! @return the index of first character not in set, or 0 if not found
0584   inline int FirstLocationNotInSet(const std::string_view& theSet,
0585                                    const int               theFromIndex,
0586                                    const int               theToIndex) const;
0587 #endif
0588 
0589   //! Template method for FirstLocationNotInSet with string literals.
0590   //! @param[in] theLiteral the string literal of characters to check against
0591   //! @param[in] theFromIndex the starting index for search
0592   //! @param[in] theToIndex the ending index for search
0593   //! @return the index of first character not in set, or 0 if not found
0594   template <std::size_t N>
0595   inline int FirstLocationNotInSet(const char (&theLiteral)[N],
0596                                    const int theFromIndex,
0597                                    const int theToIndex) const;
0598 
0599   //! Inserts a Character at position where.
0600   //!
0601   //! Example:
0602   //! ```cpp
0603   //! TCollection_AsciiString aString("hy not ?");
0604   //! aString.Insert(1, 'W');
0605   //! // Result: aString == "Why not ?"
0606   //!
0607   //! TCollection_AsciiString bString("Wh");
0608   //! bString.Insert(3, 'y');
0609   //! // Result: bString == "Why"
0610   //! ```
0611   //! @param[in] theWhere the position to insert at
0612   //! @param[in] theWhat the character to insert
0613   Standard_EXPORT void Insert(const int theWhere, const char theWhat);
0614 
0615   //! Core implementation: Inserts a string (pointer and length) at position theWhere.
0616   //! This is the primary implementation that all other Insert overloads redirect to.
0617   //! @param[in] theWhere position to insert at
0618   //! @param[in] theString pointer to the string to insert
0619   //! @param[in] theLength length of the string to insert
0620   Standard_EXPORT void Insert(const int theWhere, const char* const theString, const int theLength);
0621 
0622   //! Inserts a AsciiString at position where.
0623   //! @param[in] theWhere the position to insert at
0624   //! @param[in] theWhat the ASCII string to insert
0625   inline void Insert(const int theWhere, const TCollection_AsciiString& theWhat);
0626 
0627   //! Inserts a C string at position theWhere.
0628   //! @param[in] theWhere position to insert at
0629   //! @param[in] theCString the C string to insert
0630   inline void Insert(const int theWhere, const char* const theCString);
0631 
0632 #if Standard_CPP17_OR_HIGHER
0633   //! Inserts a string_view at position theWhere.
0634   //! @param[in] theWhere position to insert at
0635   //! @param[in] theStringView the string view to insert
0636   inline void Insert(const int theWhere, const std::string_view& theStringView);
0637 #endif
0638 
0639   //! Template method for inserting string literals with compile-time size deduction.
0640   //! This optimization avoids runtime strlen() calls and unnecessary conversions.
0641   //!
0642   //! Example:
0643   //! ```cpp
0644   //! TCollection_AsciiString aString("O more");
0645   //! aString.Insert(2, "nce");  // Size known at compile time
0646   //! // Result: aString == "Once more"
0647   //! ```
0648   //! @param[in] theWhere the position to insert at
0649   //! @param[in] theLiteral the string literal or char array to insert
0650   template <std::size_t N>
0651   inline void Insert(const int theWhere, const char (&theLiteral)[N]);
0652 
0653   //! Core implementation: Inserts string (pointer and length) after a specific index in this
0654   //! string. This is the primary implementation that all other InsertAfter overloads redirect to.
0655   //! Raises an exception if index is out of bounds (less than 0 or greater than the length).
0656   //! @param[in] theIndex the index to insert after
0657   //! @param[in] theString pointer to the string to insert
0658   //! @param[in] theLength length of the string to insert
0659   Standard_EXPORT void InsertAfter(const int         theIndex,
0660                                    const char* const theString,
0661                                    const int         theLength);
0662 
0663   //! Inserts an ASCII string after a specific index in this string.
0664   //! Raises an exception if index is out of bounds.
0665   //! @param[in] theIndex the index to insert after
0666   //! @param[in] theOther the string to insert
0667   inline void InsertAfter(const int theIndex, const TCollection_AsciiString& theOther);
0668 
0669   //! Inserts a C string after a specific index in this string.
0670   //! Raises an exception if index is out of bounds.
0671   //! @param[in] theIndex the index to insert after
0672   //! @param[in] theCString the C string to insert
0673   inline void InsertAfter(const int theIndex, const char* const theCString);
0674 
0675 #if Standard_CPP17_OR_HIGHER
0676   //! Inserts a string_view after a specific index in this string.
0677   //! Raises an exception if index is out of bounds.
0678   //! @param[in] theIndex the index to insert after
0679   //! @param[in] theStringView the string view to insert
0680   inline void InsertAfter(const int theIndex, const std::string_view& theStringView);
0681 #endif
0682 
0683   //! Template method for inserting string literals or char arrays after a specific index.
0684   //! @param[in] theIndex the index to insert after
0685   //! @param[in] theLiteral the string literal or char array to insert
0686   template <std::size_t N>
0687   inline void InsertAfter(const int theIndex, const char (&theLiteral)[N]);
0688 
0689   //! Core implementation: Inserts string (pointer and length) before a specific index in this
0690   //! string. This is the primary implementation that all other InsertBefore overloads redirect to.
0691   //! Raises an exception if index is out of bounds (less than 1 or greater than the length).
0692   //! @param[in] theIndex the index to insert before
0693   //! @param[in] theString pointer to the string to insert
0694   //! @param[in] theLength length of the string to insert
0695   Standard_EXPORT void InsertBefore(const int         theIndex,
0696                                     const char* const theString,
0697                                     const int         theLength);
0698 
0699   //! Inserts an ASCII string before a specific index in this string.
0700   //! Raises an exception if index is out of bounds.
0701   //! @param[in] theIndex the index to insert before
0702   //! @param[in] theOther the string to insert
0703   inline void InsertBefore(const int theIndex, const TCollection_AsciiString& theOther);
0704 
0705   //! Inserts a C string before a specific index in this string.
0706   //! Raises an exception if index is out of bounds.
0707   //! @param[in] theIndex the index to insert before
0708   //! @param[in] theCString the C string to insert
0709   inline void InsertBefore(const int theIndex, const char* const theCString);
0710 
0711 #if Standard_CPP17_OR_HIGHER
0712   //! Inserts a string_view before a specific index in this string.
0713   //! Raises an exception if index is out of bounds.
0714   //! @param[in] theIndex the index to insert before
0715   //! @param[in] theStringView the string view to insert
0716   inline void InsertBefore(const int theIndex, const std::string_view& theStringView);
0717 #endif
0718 
0719   //! Template method for inserting string literals or char arrays before a specific index.
0720   //! @param[in] theIndex the index to insert before
0721   //! @param[in] theLiteral the string literal or char array to insert
0722   template <std::size_t N>
0723   inline void InsertBefore(const int theIndex, const char (&theLiteral)[N]);
0724 
0725   //! Returns True if this string contains zero character.
0726   bool IsEmpty() const { return myLength == 0; }
0727 
0728   //! Returns true if the characters in this ASCII string
0729   //! are identical to the characters in ASCII string other.
0730   //! Note that this method is an alias of operator ==.
0731   //! @param[in] theOther the ASCII string to compare with
0732   //! @return true if strings are equal, false otherwise
0733   inline bool IsEqual(const TCollection_AsciiString& theOther) const;
0734 
0735   inline bool operator==(const TCollection_AsciiString& theOther) const;
0736 
0737   //! Core implementation: Returns true if the characters in this ASCII string
0738   //! are identical to the string (pointer and length).
0739   //! This is the primary implementation that string_view and CString overloads redirect to.
0740   //! @param[in] theString pointer to the string to compare with
0741   //! @param[in] theLength length of the string to compare with
0742   //! @return true if strings are equal, false otherwise
0743   Standard_EXPORT bool IsEqual(const char* const theString, const int theLength) const;
0744 
0745   //! Returns true if the characters in this ASCII string are identical to the C string.
0746   //! @param[in] theCString the C string to compare with
0747   //! @return true if strings are equal, false otherwise
0748   inline bool IsEqual(const char* const theCString) const;
0749 
0750   inline bool operator==(const char* const theCString) const;
0751 
0752 #if Standard_CPP17_OR_HIGHER
0753   //! Returns true if the characters in this ASCII string
0754   //! are identical to the characters in string_view.
0755   //! @param[in] theStringView the string view to compare with
0756   //! @return true if strings are equal, false otherwise
0757   inline bool IsEqual(const std::string_view& theStringView) const;
0758 
0759   inline bool operator==(const std::string_view& theStringView) const;
0760 #endif
0761 
0762   //! Template method for comparing with string literals with compile-time optimization.
0763   //! This optimization avoids runtime strlen() calls and unnecessary conversions.
0764   //!
0765   //! Example:
0766   //! ```cpp
0767   //! TCollection_AsciiString aString("Hello");
0768   //! bool isEqual = aString.IsEqual("Hello");  // Size known at compile time
0769   //! bool isEqual2 = (aString == "Hello");     // Same optimization
0770   //! ```
0771   //! @param[in] theLiteral the string literal or char array to compare with
0772   //! @return true if strings are equal, false otherwise
0773   template <std::size_t N>
0774   inline bool IsEqual(const char (&theLiteral)[N]) const;
0775 
0776   template <std::size_t N>
0777   inline bool operator==(const char (&theLiteral)[N]) const;
0778 
0779   //! Returns true if there are differences between the
0780   //! characters in this ASCII string and ASCII string other.
0781   //! Note that this method is an alias of operator !=
0782   //! @param[in] theOther the ASCII string to compare with
0783   //! @return true if strings are different, false otherwise
0784   inline bool IsDifferent(const TCollection_AsciiString& theOther) const;
0785 
0786   inline bool operator!=(const TCollection_AsciiString& theOther) const;
0787 
0788   //! Core implementation: Returns true if there are differences between this ASCII string
0789   //! and the string (pointer and length).
0790   //! This is the primary implementation that string_view and CString overloads redirect to.
0791   //! @param[in] theString pointer to the string to compare with
0792   //! @param[in] theLength length of the string to compare with
0793   //! @return true if strings are different, false otherwise
0794   inline bool IsDifferent(const char* const theString, const int theLength) const;
0795 
0796   //! Returns true if there are differences between this ASCII string and C string.
0797   //! @param[in] theCString the C string to compare with
0798   //! @return true if strings are different, false otherwise
0799   inline bool IsDifferent(const char* const theCString) const;
0800 
0801   inline bool operator!=(const char* const theCString) const;
0802 
0803 #if Standard_CPP17_OR_HIGHER
0804   //! Returns true if there are differences between the
0805   //! characters in this ASCII string and string_view.
0806   //! @param[in] theStringView the string view to compare with
0807   //! @return true if strings are different, false otherwise
0808   inline bool IsDifferent(const std::string_view& theStringView) const;
0809 
0810   inline bool operator!=(const std::string_view& theStringView) const;
0811 #endif
0812 
0813   //! Template method for comparing difference with string literals or char arrays.
0814   //! @param[in] theLiteral the string literal or char array to compare with
0815   //! @return true if strings are different, false otherwise
0816   template <std::size_t N>
0817   inline bool IsDifferent(const char (&theLiteral)[N]) const;
0818 
0819   template <std::size_t N>
0820   inline bool operator!=(const char (&theLiteral)[N]) const;
0821 
0822   //! Core implementation: Returns TRUE if this string is lexicographically less than
0823   //! the string (pointer and length).
0824   //! This is the primary implementation that all other IsLess overloads redirect to.
0825   //! @param[in] theString pointer to the string to compare with
0826   //! @param[in] theLength length of the string to compare with
0827   //! @return true if this string is lexicographically less than the given string
0828   Standard_EXPORT bool IsLess(const char* const theString, const int theLength) const;
0829 
0830   //! Returns TRUE if this string is 'ASCII' less than other.
0831   //! @param[in] theOther the ASCII string to compare with
0832   //! @return true if this string is lexicographically less than other
0833   inline bool IsLess(const TCollection_AsciiString& theOther) const;
0834 
0835   inline bool operator<(const TCollection_AsciiString& theOther) const;
0836 
0837   //! Returns TRUE if this string is lexicographically less than C string.
0838   //! @param[in] theCString the C string to compare with
0839   //! @return true if this string is lexicographically less than C string
0840   inline bool IsLess(const char* const theCString) const;
0841 
0842   bool operator<(const char* const theCString) const { return IsLess(theCString); }
0843 
0844 #if Standard_CPP17_OR_HIGHER
0845   //! Returns TRUE if this ASCII string is lexicographically less than theStringView.
0846   //! @param[in] theStringView the string view to compare with
0847   //! @return true if this string is lexicographically less than theStringView
0848   inline bool IsLess(const std::string_view& theStringView) const;
0849 
0850   inline bool operator<(const std::string_view& theStringView) const;
0851 #endif
0852 
0853   //! Template method for lexicographic comparison with string literals or char arrays.
0854   //! @param[in] theLiteral the string literal or char array to compare with
0855   //! @return true if this string is lexicographically less than literal
0856   template <std::size_t N>
0857   inline bool IsLess(const char (&theLiteral)[N]) const;
0858 
0859   template <std::size_t N>
0860   inline bool operator<(const char (&theLiteral)[N]) const;
0861 
0862   //! Core implementation: Returns TRUE if this string is lexicographically greater than
0863   //! the string (pointer and length).
0864   //! This is the primary implementation that all other IsGreater overloads redirect to.
0865   //! @param[in] theString pointer to the string to compare with
0866   //! @param[in] theLength length of the string to compare with
0867   //! @return true if this string is lexicographically greater than the given string
0868   Standard_EXPORT bool IsGreater(const char* const theString, const int theLength) const;
0869 
0870   //! Returns TRUE if this string is 'ASCII' greater than other.
0871   //! @param[in] theOther the ASCII string to compare with
0872   //! @return true if this string is lexicographically greater than other
0873   inline bool IsGreater(const TCollection_AsciiString& theOther) const;
0874 
0875   inline bool operator>(const TCollection_AsciiString& theOther) const;
0876 
0877   //! Returns TRUE if this string is lexicographically greater than C string.
0878   //! @param[in] theCString the C string to compare with
0879   //! @return true if this string is lexicographically greater than C string
0880   inline bool IsGreater(const char* const theCString) const;
0881 
0882   inline bool operator>(const char* const theCString) const;
0883 
0884 #if Standard_CPP17_OR_HIGHER
0885   //! Returns TRUE if this ASCII string is lexicographically greater than theStringView.
0886   //! @param[in] theStringView the string view to compare with
0887   //! @return true if this string is lexicographically greater than theStringView
0888   inline bool IsGreater(const std::string_view& theStringView) const;
0889 
0890   inline bool operator>(const std::string_view& theStringView) const;
0891 #endif
0892 
0893   //! Template method for lexicographic greater comparison with string literals or char arrays.
0894   //! @param[in] theLiteral the string literal or char array to compare with
0895   //! @return true if this string is lexicographically greater than literal
0896   template <std::size_t N>
0897   inline bool IsGreater(const char (&theLiteral)[N]) const;
0898 
0899   template <std::size_t N>
0900   inline bool operator>(const char (&theLiteral)[N]) const;
0901 
0902   //! Core implementation: Determines whether the beginning of this string instance matches
0903   //! the specified string (pointer and length).
0904   //! @param[in] theStartString pointer to the string to check for at the beginning
0905   //! @param[in] theStartLength length of the string to check for
0906   //! @return true if this string starts with theStartString
0907   Standard_EXPORT bool StartsWith(const char* const theStartString, const int theStartLength) const;
0908 
0909   //! Determines whether the beginning of this string instance matches the specified string.
0910   //! @param[in] theStartString the string to check for at the beginning
0911   //! @return true if this string starts with theStartString
0912   inline bool StartsWith(const TCollection_AsciiString& theStartString) const;
0913 
0914   //! Determines whether the beginning of this string matches the specified C string.
0915   //! @param[in] theCString the C string to check for at the beginning
0916   //! @return true if this string starts with theCString
0917   inline bool StartsWith(const char* const theCString) const;
0918 
0919 #if Standard_CPP17_OR_HIGHER
0920   //! Determines whether the beginning of this string instance matches the specified string_view.
0921   //! @param[in] theStartString the string view to check for at the beginning
0922   //! @return true if this string starts with theStartString
0923   inline bool StartsWith(const std::string_view& theStartString) const;
0924 #endif
0925 
0926   //! Core implementation: Determines whether the end of this string instance matches
0927   //! the specified string (pointer and length).
0928   //! @param[in] theEndString pointer to the string to check for at the end
0929   //! @param[in] theEndLength length of the string to check for
0930   //! @return true if this string ends with theEndString
0931   Standard_EXPORT bool EndsWith(const char* const theEndString, const int theEndLength) const;
0932 
0933   //! Determines whether the end of this string instance matches the specified string.
0934   //! @param[in] theEndString the string to check for at the end
0935   //! @return true if this string ends with theEndString
0936   inline bool EndsWith(const TCollection_AsciiString& theEndString) const;
0937 
0938 #if Standard_CPP17_OR_HIGHER
0939   //! Determines whether the end of this string instance matches the specified string_view.
0940   //! @param[in] theEndString the string view to check for at the end
0941   //! @return true if this string ends with theEndString
0942   inline bool EndsWith(const std::string_view& theEndString) const;
0943 #endif
0944 
0945   //! Template method for checking if string starts with a literal or char array.
0946   //! @param[in] theLiteral the string literal or char array to check for at the beginning
0947   //! @return true if this string starts with literal
0948   template <std::size_t N>
0949   inline bool StartsWith(const char (&theLiteral)[N]) const;
0950 
0951   //! Template method for checking if string ends with a literal or char array.
0952   //! @param[in] theLiteral the string literal or char array to check for at the end
0953   //! @return true if this string ends with literal
0954   template <std::size_t N>
0955   inline bool EndsWith(const char (&theLiteral)[N]) const;
0956 
0957   //! Converts a AsciiString containing a numeric expression to an Integer.
0958   //!
0959   //! Example:
0960   //! ```cpp
0961   //! TCollection_AsciiString aString("215");
0962   //! int anInt = aString.IntegerValue();
0963   //! // Result: anInt == 215
0964   //! ```
0965   //! @return the integer value of the string
0966   Standard_EXPORT int IntegerValue() const;
0967 
0968   //! Returns True if the AsciiString contains an integer value.
0969   //! Note: an integer value is considered to be a real value as well.
0970   //! @return true if string represents an integer value
0971   Standard_EXPORT bool IsIntegerValue() const;
0972 
0973   //! Returns True if the AsciiString starts with some characters that can be interpreted as integer
0974   //! or real value.
0975   //! @param[in] theToCheckFull  when TRUE, checks if entire string defines a real value;
0976   //!                            otherwise checks if string starts with a real value
0977   //! Note: an integer value is considered to be a real value as well.
0978   //! @return true if string represents a real value
0979   Standard_EXPORT bool IsRealValue(bool theToCheckFull = false) const;
0980 
0981   //! Returns True if the AsciiString contains only ASCII characters
0982   //! between ' ' and '~'.
0983   //! This means no control character and no extended ASCII code.
0984   //! @return true if string contains only ASCII characters
0985   Standard_EXPORT bool IsAscii() const;
0986 
0987   //! Removes all space characters in the beginning of the string.
0988   Standard_EXPORT void LeftAdjust();
0989 
0990   //! left justify
0991   //! Length becomes equal to Width and the new characters are
0992   //! equal to Filler.
0993   //! If Width < Length nothing happens.
0994   //! Raises an exception if Width is less than zero.
0995   //!
0996   //! Example:
0997   //! ```cpp
0998   //! TCollection_AsciiString aString("abcdef");
0999   //! aString.LeftJustify(9, ' ');
1000   //! // Result: aString == "abcdef   "
1001   //! ```
1002   //! @param[in] theWidth the desired width
1003   //! @param[in] theFiller the character to fill with
1004   Standard_EXPORT void LeftJustify(const int theWidth, const char theFiller);
1005 
1006   //! Returns number of characters in this string.
1007   //! This is the same functionality as 'strlen' in C.
1008   //!
1009   //! Example:
1010   //! ```cpp
1011   //! TCollection_AsciiString anAlphabet("abcdef");
1012   //! int aLength = anAlphabet.Length();
1013   //! // Result: aLength == 6
1014   //! ```
1015   //! -   1 is the position of the first character in this string.
1016   //! -   The length of this string gives the position of its last character.
1017   //! -   Positions less than or equal to zero, or
1018   //! greater than the length of this string are
1019   //! invalid in functions which identify a character
1020   //! of this string by its position.
1021   //! @return the number of characters in the string
1022   int Length() const { return myLength; }
1023 
1024   //! Returns an index in this string of the first occurrence
1025   //! of the string S in this string from the starting index
1026   //! FromIndex to the ending index ToIndex
1027   //! returns zero if failure
1028   //! Raises an exception if FromIndex or ToIndex is out of range.
1029   //!
1030   //! Example:
1031   //! ```cpp
1032   //! TCollection_AsciiString aString("aabAaAa");
1033   //! TCollection_AsciiString aSearchString("Aa");
1034   //! int anIndex = aString.Location(aSearchString, 1, 7);
1035   //! // Result: anIndex == 4
1036   //! ```
1037   //! @param[in] theOther the string to search for
1038   //! @param[in] theFromIndex the starting index for search
1039   //! @param[in] theToIndex the ending index for search
1040   //! @return the index of first occurrence, or 0 if not found
1041   Standard_EXPORT int Location(const TCollection_AsciiString& theOther,
1042                                const int                      theFromIndex,
1043                                const int                      theToIndex) const;
1044 
1045   //! Returns the index of the nth occurrence of the character C
1046   //! in this string from the starting index FromIndex to the
1047   //! ending index ToIndex.
1048   //! Returns zero if failure.
1049   //! Raises an exception if FromIndex or ToIndex is out of range.
1050   //!
1051   //! Example:
1052   //! ```cpp
1053   //! TCollection_AsciiString aString("aabAa");
1054   //! int anIndex = aString.Location(3, 'a', 1, 5);
1055   //! // Result: anIndex == 5
1056   //! ```
1057   //! @param[in] theN the occurrence number to find
1058   //! @param[in] theC the character to search for
1059   //! @param[in] theFromIndex the starting index for search
1060   //! @param[in] theToIndex the ending index for search
1061   //! @return the index of the nth occurrence, or 0 if not found
1062   Standard_EXPORT int Location(const int  theN,
1063                                const char theC,
1064                                const int  theFromIndex,
1065                                const int  theToIndex) const;
1066 
1067   //! Converts this string to its lower-case equivalent.
1068   //!
1069   //! Example:
1070   //! ```cpp
1071   //! TCollection_AsciiString aString("Hello Dolly");
1072   //! aString.UpperCase();
1073   //! // Result: aString == "HELLO DOLLY"
1074   //! aString.LowerCase();
1075   //! // Result: aString == "hello dolly"
1076   //! ```
1077   Standard_EXPORT void LowerCase();
1078 
1079   //! Inserts the string other at the beginning of this ASCII string.
1080   //!
1081   //! Example:
1082   //! ```cpp
1083   //! TCollection_AsciiString anAlphabet("cde");
1084   //! TCollection_AsciiString aBegin("ab");
1085   //! anAlphabet.Prepend(aBegin);
1086   //! // Result: anAlphabet == "abcde"
1087   //! ```
1088   //! @param[in] theOther the string to prepend
1089   Standard_EXPORT void Prepend(const TCollection_AsciiString& theOther);
1090 
1091   //! Displays this string on a stream.
1092   //! @param[in] theStream the output stream
1093   Standard_EXPORT void                     Print(Standard_OStream& theStream) const;
1094   friend Standard_EXPORT Standard_OStream& operator<<(Standard_OStream&              theStream,
1095                                                       const TCollection_AsciiString& theString);
1096 
1097   //! Read this string from a stream.
1098   //! @param[in] theStream the input stream
1099   Standard_EXPORT void                     Read(Standard_IStream& theStream);
1100   friend Standard_EXPORT Standard_IStream& operator>>(Standard_IStream&        theStream,
1101                                                       TCollection_AsciiString& theString);
1102 
1103   //! Converts an AsciiString containing a numeric expression to a Real.
1104   //!
1105   //! Example:
1106   //! ```cpp
1107   //! TCollection_AsciiString aString1("215");
1108   //! double aReal1 = aString1.RealValue();
1109   //! // Result: aReal1 == 215.0
1110   //!
1111   //! TCollection_AsciiString aString2("3.14159267");
1112   //! double aReal2 = aString2.RealValue();
1113   //! // Result: aReal2 == 3.14159267
1114   //! ```
1115   //! @return the real value of the string
1116   Standard_EXPORT double RealValue() const;
1117 
1118   //! Remove all the occurrences of the character C in the string.
1119   //!
1120   //! Example:
1121   //! ```cpp
1122   //! TCollection_AsciiString aString("HellLLo");
1123   //! aString.RemoveAll('L', true);
1124   //! // Result: aString == "Hello"
1125   //! ```
1126   //! @param[in] theC the character to remove
1127   //! @param[in] theCaseSensitive flag indicating case sensitivity
1128   Standard_EXPORT void RemoveAll(const char theC, const bool theCaseSensitive);
1129 
1130   //! Removes every what characters from this string.
1131   //! @param[in] theWhat the character to remove
1132   Standard_EXPORT void RemoveAll(const char theWhat);
1133 
1134   //! Erases ahowmany characters from position where,
1135   //! where included.
1136   //!
1137   //! Example:
1138   //! ```cpp
1139   //! TCollection_AsciiString aString("Hello");
1140   //! aString.Remove(2, 2); // erases 2 characters from position 2
1141   //! // Result: aString == "Hlo"
1142   //! ```
1143   //! @param[in] theWhere the position to start erasing from
1144   //! @param[in] theHowMany the number of characters to erase
1145   Standard_EXPORT void Remove(const int theWhere, const int theHowMany = 1);
1146 
1147   //! Removes all space characters at the end of the string.
1148   Standard_EXPORT void RightAdjust();
1149 
1150   //! Right justify.
1151   //! Length becomes equal to Width and the new characters are
1152   //! equal to Filler.
1153   //! if Width < Length nothing happens.
1154   //! Raises an exception if Width is less than zero.
1155   //!
1156   //! Example:
1157   //! ```cpp
1158   //! TCollection_AsciiString aString("abcdef");
1159   //! aString.RightJustify(9, ' ');
1160   //! // Result: aString == "   abcdef"
1161   //! ```
1162   //! @param[in] theWidth the desired width
1163   //! @param[in] theFiller the character to fill with
1164   Standard_EXPORT void RightJustify(const int theWidth, const char theFiller);
1165 
1166   //! Core implementation: Searches a string (pointer and length) in this string from the beginning
1167   //! and returns position of first item matching.
1168   //! It returns -1 if not found.
1169   //! @param[in] theWhat pointer to the string to search for
1170   //! @param[in] theWhatLength length of the string to search for
1171   //! @return the position of first match, or -1 if not found
1172   Standard_EXPORT int Search(const char* const theWhat, const int theWhatLength) const;
1173 
1174   //! Searches an AsciiString in this string from the beginning
1175   //! and returns position of first item what matching.
1176   //! It returns -1 if not found.
1177   //! @param[in] theWhat the ASCII string to search for
1178   //! @return the position of first match, or -1 if not found
1179   inline int Search(const TCollection_AsciiString& theWhat) const;
1180 
1181   //! Searches a C string in this string from the beginning.
1182   //! @param[in] theCString the C string to search for
1183   //! @return the position of first match, or -1 if not found
1184   inline int Search(const char* const theCString) const;
1185 
1186 #if Standard_CPP17_OR_HIGHER
1187   //! Searches a string_view in this string from the beginning
1188   //! and returns position of first item matching.
1189   //! It returns -1 if not found.
1190   //! @param[in] theWhat the string view to search for
1191   //! @return the position of first match, or -1 if not found
1192   inline int Search(const std::string_view& theWhat) const;
1193 #endif
1194 
1195   //! Template method for searching string literals or char arrays.
1196   //! @param[in] theLiteral the string literal or char array to search for
1197   //! @return the position of first match, or -1 if not found
1198   template <std::size_t N>
1199   inline int Search(const char (&theLiteral)[N]) const;
1200 
1201   //! Core implementation: Searches a string (pointer and length) in this string from the end
1202   //! and returns position of first item matching.
1203   //! It returns -1 if not found.
1204   //! @param[in] theWhat pointer to the string to search for
1205   //! @param[in] theWhatLength length of the string to search for
1206   //! @return the position of first match from end, or -1 if not found
1207   Standard_EXPORT int SearchFromEnd(const char* const theWhat, const int theWhatLength) const;
1208 
1209   //! Searches a AsciiString in another AsciiString from the end
1210   //! and returns position of first item what matching.
1211   //! It returns -1 if not found.
1212   //! @param[in] theWhat the ASCII string to search for
1213   //! @return the position of first match from end, or -1 if not found
1214   inline int SearchFromEnd(const TCollection_AsciiString& theWhat) const;
1215 
1216   //! Searches a C string in this string from the end.
1217   //! @param[in] theCString the C string to search for
1218   //! @return the position of first match from end, or -1 if not found
1219   inline int SearchFromEnd(const char* const theCString) const;
1220 
1221 #if Standard_CPP17_OR_HIGHER
1222   //! Searches a string_view in this string from the end
1223   //! and returns position of first item matching.
1224   //! It returns -1 if not found.
1225   //! @param[in] theWhat the string view to search for
1226   //! @return the position of first match from end, or -1 if not found
1227   inline int SearchFromEnd(const std::string_view& theWhat) const;
1228 #endif
1229 
1230   //! Template method for searching string literals or char arrays from end.
1231   //! @param[in] theLiteral the string literal or char array to search for
1232   //! @return the position of first match from end, or -1 if not found
1233   template <std::size_t N>
1234   inline int SearchFromEnd(const char (&theLiteral)[N]) const;
1235 
1236   //! Replaces one character in the AsciiString at position where.
1237   //! If where is less than zero or greater than the length of this string
1238   //! an exception is raised.
1239   //!
1240   //! Example:
1241   //! ```cpp
1242   //! TCollection_AsciiString aString("Garbake");
1243   //! aString.SetValue(6, 'g');
1244   //! // Result: aString == "Garbage"
1245   //! ```
1246   //! @param[in] theWhere the position to replace at
1247   //! @param[in] theWhat the character to replace with
1248   Standard_EXPORT void SetValue(const int theWhere, const char theWhat);
1249 
1250   //! Core implementation: Replaces a part of this string with a string (pointer and length).
1251   //! This is the primary implementation that all other SetValue string overloads redirect to.
1252   //! @param[in] theWhere position to start replacement
1253   //! @param[in] theString pointer to the string to replace with
1254   //! @param[in] theLength length of the string to replace with
1255   Standard_EXPORT void SetValue(const int         theWhere,
1256                                 const char* const theString,
1257                                 const int         theLength);
1258 
1259   //! Replaces a part of this string by another AsciiString.
1260   //! @param[in] theWhere the position to start replacement
1261   //! @param[in] theWhat the ASCII string to replace with
1262   inline void SetValue(const int theWhere, const TCollection_AsciiString& theWhat);
1263 
1264   //! Replaces a part of this ASCII string with a C string.
1265   //! @param[in] theWhere position to start replacement
1266   //! @param[in] theCString the C string to replace with
1267   inline void SetValue(const int theWhere, const char* const theCString);
1268 
1269 #if Standard_CPP17_OR_HIGHER
1270   //! Replaces a part of this ASCII string with a string_view.
1271   //! @param[in] theWhere position to start replacement
1272   //! @param[in] theStringView the string view to replace with
1273   inline void SetValue(const int theWhere, const std::string_view& theStringView);
1274 #endif
1275 
1276   //! Splits a AsciiString into two sub-strings.
1277   //!
1278   //! Example:
1279   //! ```cpp
1280   //! TCollection_AsciiString aString("abcdefg");
1281   //! TCollection_AsciiString aSecondPart = aString.Split(3);
1282   //! // Result: aString == "abc" and aSecondPart == "defg"
1283   //! ```
1284   //! @param[in] theWhere the position to split at
1285   //! @return the second part of the split string
1286   Standard_EXPORT TCollection_AsciiString Split(const int theWhere);
1287 
1288   //! Creation of a sub-string of this string.
1289   //! The sub-string starts to the index Fromindex and ends
1290   //! to the index ToIndex.
1291   //! Raises an exception if ToIndex or FromIndex is out of bounds
1292   //!
1293   //! Example:
1294   //! ```cpp
1295   //! TCollection_AsciiString aString("abcdefg");
1296   //! TCollection_AsciiString aSubString = aString.SubString(3, 6);
1297   //! // Result: aSubString == "cdef"
1298   //! ```
1299   //! @param[in] theFromIndex the starting index
1300   //! @param[in] theToIndex the ending index
1301   //! @return the substring from FromIndex to ToIndex
1302   Standard_EXPORT TCollection_AsciiString SubString(const int theFromIndex,
1303                                                     const int theToIndex) const;
1304 
1305   //! Returns pointer to AsciiString (char *).
1306   //! This is useful for some casual manipulations.
1307   //! Warning: Because this "char *" is 'const', you can't modify its contents.
1308   //! @return the C string representation
1309   const char* ToCString() const { return myString; }
1310 
1311 #if Standard_CPP17_OR_HIGHER
1312   //! Returns string_view for this AsciiString.
1313   //! This provides a lightweight, non-owning view of the string data.
1314   //! @return the string_view representation
1315   explicit operator std::string_view() const { return std::string_view(myString, myLength); }
1316 #endif
1317 
1318   //! Extracts whichone token from this string.
1319   //! By default, the separators is set to space and tabulation.
1320   //! By default, the token extracted is the first one (whichone = 1).
1321   //! separators contains all separators you need.
1322   //! If no token indexed by whichone is found, it returns empty AsciiString.
1323   //!
1324   //! Example:
1325   //! ```cpp
1326   //! TCollection_AsciiString aString("This is a     message");
1327   //! TCollection_AsciiString aToken1 = aString.Token();
1328   //! // Result: aToken1 == "This"
1329   //!
1330   //! TCollection_AsciiString aToken2 = aString.Token(" ", 4);
1331   //! // Result: aToken2 == "message"
1332   //!
1333   //! TCollection_AsciiString aToken3 = aString.Token(" ", 2);
1334   //! // Result: aToken3 == "is"
1335   //!
1336   //! TCollection_AsciiString aToken4 = aString.Token(" ", 9);
1337   //! // Result: aToken4 == ""
1338   //!
1339   //! TCollection_AsciiString bString("1234; test:message   , value");
1340   //! TCollection_AsciiString bToken1 = bString.Token("; :,", 4);
1341   //! // Result: bToken1 == "value"
1342   //!
1343   //! TCollection_AsciiString bToken2 = bString.Token("; :,", 2);
1344   //! // Result: bToken2 == "test"
1345   //! ```
1346   //! @param[in] theSeparators the separator characters
1347   //! @param[in] theWhichOne the token number to extract
1348   Standard_EXPORT TCollection_AsciiString Token(const char* const theSeparators = " \t",
1349                                                 const int         theWhichOne   = 1) const;
1350 
1351   //! Truncates this string to ahowmany characters.
1352   //!
1353   //! Example:
1354   //! ```cpp
1355   //! TCollection_AsciiString aString("Hello Dolly");
1356   //! aString.Trunc(3);
1357   //! // Result: aString == "Hel"
1358   //! ```
1359   //! @param[in] theHowMany the number of characters to keep
1360   Standard_EXPORT void Trunc(const int theHowMany);
1361 
1362   //! Converts this string to its upper-case equivalent.
1363   Standard_EXPORT void UpperCase();
1364 
1365   //! Length of the string ignoring all spaces (' ') and the
1366   //! control character at the end.
1367   //! @return the useful length of the string
1368   Standard_EXPORT int UsefullLength() const;
1369 
1370   //! Returns character at position where in this string.
1371   //! If where is less than zero or greater than the length of this string,
1372   //! an exception is raised.
1373   //!
1374   //! Example:
1375   //! ```cpp
1376   //! TCollection_AsciiString aString("Hello");
1377   //! char aChar = aString.Value(2);
1378   //! // Result: aChar == 'e'
1379   //! ```
1380   //! @param[in] theWhere the position to get character from
1381   //! @return the character at the specified position
1382   Standard_EXPORT char Value(const int theWhere) const;
1383 
1384   //! Computes a hash code for the given ASCII string
1385   //! Returns the same integer value as the hash function for TCollection_ExtendedString
1386   //! @return a computed hash code
1387   inline size_t HashCode() const;
1388 
1389   //! Returns a const reference to a single shared empty string instance.
1390   //! This method provides access to a static empty string to avoid creating temporary empty
1391   //! strings. Use this method instead of constructing empty strings when you need a const
1392   //! reference.
1393   //!
1394   //! Example:
1395   //! ```cpp
1396   //! const TCollection_AsciiString& anEmptyStr = TCollection_AsciiString::EmptyString();
1397   //! // Use anEmptyStr instead of TCollection_AsciiString()
1398   //! ```
1399   //! @return const reference to static empty string
1400   Standard_EXPORT static const TCollection_AsciiString& EmptyString() noexcept;
1401 
1402   //! Returns True when the two strings are the same.
1403   //! (Just for HashCode for AsciiString)
1404   //! @param[in] string1 first string to compare
1405   //! @param[in] string2 second string to compare
1406   //! @return true if strings are equal
1407   inline static bool IsEqual(const TCollection_AsciiString& string1,
1408                              const TCollection_AsciiString& string2);
1409 
1410   //! Returns True when the two strings are the same.
1411   //! (Just for HashCode for AsciiString)
1412   //! @param[in] string1 first string to compare
1413   //! @param[in] string2 second C string to compare
1414   //! @return true if strings are equal
1415   static bool IsEqual(const TCollection_AsciiString& string1, const char* const string2);
1416 
1417 #if Standard_CPP17_OR_HIGHER
1418   //! Returns True when the ASCII string and string_view are the same.
1419   //! (Just for HashCode for AsciiString)
1420   //! @param[in] theString1 first string to compare
1421   //! @param[in] theStringView second string view to compare
1422   //! @return true if strings are equal
1423   inline static bool IsEqual(const TCollection_AsciiString& theString1,
1424                              const std::string_view&        theStringView);
1425 
1426   //! Returns True when the string_view and ASCII string are the same.
1427   //! (Just for HashCode for AsciiString)
1428   //! @param[in] theStringView first string view to compare
1429   //! @param[in] theString2 second string to compare
1430   //! @return true if strings are equal
1431   inline static bool IsEqual(const std::string_view&        theStringView,
1432                              const TCollection_AsciiString& theString2);
1433 #endif
1434 
1435   //! Core implementation: Returns True if the two strings (pointer and length) contain same
1436   //! characters. This is the primary implementation that all other IsSameString overloads redirect
1437   //! to.
1438   //! @param[in] theString1 pointer to first string to compare
1439   //! @param[in] theLength1 length of first string
1440   //! @param[in] theString2 pointer to second string to compare
1441   //! @param[in] theLength2 length of second string
1442   //! @param[in] theIsCaseSensitive flag indicating case sensitivity
1443   //! @return true if strings contain same characters
1444   Standard_EXPORT static bool IsSameString(const char* const theString1,
1445                                            const int         theLength1,
1446                                            const char* const theString2,
1447                                            const int         theLength2,
1448                                            const bool        theIsCaseSensitive);
1449 
1450   //! Returns True if the strings contain same characters.
1451   //! @param[in] theString1 first string to compare
1452   //! @param[in] theString2 second string to compare
1453   //! @param[in] theIsCaseSensitive flag indicating case sensitivity
1454   //! @return true if strings contain same characters
1455   inline static bool IsSameString(const TCollection_AsciiString& theString1,
1456                                   const TCollection_AsciiString& theString2,
1457                                   const bool                     theIsCaseSensitive);
1458 
1459   //! Returns True if the string and C string contain same characters.
1460   //! @param[in] theString1 first string to compare
1461   //! @param[in] theCString second C string to compare
1462   //! @param[in] theIsCaseSensitive flag indicating case sensitivity
1463   //! @return true if strings contain same characters
1464   inline static bool IsSameString(const TCollection_AsciiString& theString1,
1465                                   const char* const              theCString,
1466                                   const bool                     theIsCaseSensitive);
1467 
1468   //! Returns True if the C string and string contain same characters.
1469   //! @param[in] theCString first C string to compare
1470   //! @param[in] theString2 second string to compare
1471   //! @param[in] theIsCaseSensitive flag indicating case sensitivity
1472   //! @return true if strings contain same characters
1473   inline static bool IsSameString(const char* const              theCString,
1474                                   const TCollection_AsciiString& theString2,
1475                                   const bool                     theIsCaseSensitive);
1476 
1477 #if Standard_CPP17_OR_HIGHER
1478   //! Returns True if the string and string_view contain same characters.
1479   //! @param[in] theString1 first string to compare
1480   //! @param[in] theStringView second string view to compare
1481   //! @param[in] theIsCaseSensitive flag indicating case sensitivity
1482   //! @return true if strings contain same characters
1483   inline static bool IsSameString(const TCollection_AsciiString& theString1,
1484                                   const std::string_view&        theStringView,
1485                                   const bool                     theIsCaseSensitive);
1486 
1487   //! Returns True if the string_view and string contain same characters.
1488   //! @param[in] theStringView first string view to compare
1489   //! @param[in] theString2 second string to compare
1490   //! @param[in] theIsCaseSensitive flag indicating case sensitivity
1491   //! @return true if strings contain same characters
1492   inline static bool IsSameString(const std::string_view&        theStringView,
1493                                   const TCollection_AsciiString& theString2,
1494                                   const bool                     theIsCaseSensitive);
1495 #endif
1496 
1497   //! Returns True if the two C strings contain same characters.
1498   //! @param[in] theCString1 first C string to compare
1499   //! @param[in] theCString2 second C string to compare
1500   //! @param[in] theIsCaseSensitive flag indicating case sensitivity
1501   //! @return true if strings contain same characters
1502   inline static bool IsSameString(const char* const theCString1,
1503                                   const char* const theCString2,
1504                                   const bool        theIsCaseSensitive);
1505 
1506 #if Standard_CPP17_OR_HIGHER
1507   //! Returns True if the two string_views contain same characters.
1508   //! @param[in] theStringView1 first string view to compare
1509   //! @param[in] theStringView2 second string view to compare
1510   //! @param[in] theIsCaseSensitive flag indicating case sensitivity
1511   //! @return true if strings contain same characters
1512   inline static bool IsSameString(const std::string_view& theStringView1,
1513                                   const std::string_view& theStringView2,
1514                                   const bool              theIsCaseSensitive);
1515 #endif
1516 
1517 private:
1518   //! Internal wrapper to allocate on stack or heap
1519   void allocate(const int theLength);
1520 
1521   //! Internal wrapper to reallocate on stack or heap
1522   void reallocate(const int theLength);
1523 
1524   //! Internal wrapper to deallocate on stack
1525   void deallocate();
1526 
1527 private:
1528   Standard_PCharacter myString{}; //!< NULL-terminated string
1529   int                 myLength{}; //!< length in bytes (excluding terminating NULL symbol)
1530 };
1531 
1532 #include <TCollection_AsciiString.lxx>
1533 
1534 #endif // _TCollection_AsciiString_HeaderFile