Open CASCADE Technology Reference Manual 8.0.0
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions
TCollection_AsciiString Class Reference

Class defines a variable-length sequence of 8-bit characters. Despite class name (kept for historical reasons), it is intended to store UTF-8 string, not just ASCII characters. However, multi-byte nature of UTF-8 is not considered by the following methods: More...

#include <TCollection_AsciiString.hxx>

Public Member Functions

 TCollection_AsciiString () noexcept
 Initializes a AsciiString to an empty AsciiString.
 
 TCollection_AsciiString (const char *const theMessage)
 Initializes a AsciiString with a CString (null-terminated).
 
 TCollection_AsciiString (const char *const theMessage, const int theLength)
 Initializes a AsciiString with a CString and explicit length.
 
 TCollection_AsciiString (const char theChar)
 Initializes a AsciiString with a single character.
 
 TCollection_AsciiString (const int theLength, const char theFiller)
 Initializes an AsciiString with specified length space allocated and filled with filler character. This is useful for buffers.
 
 TCollection_AsciiString (const int theValue)
 Initializes an AsciiString with an integer value.
 
 TCollection_AsciiString (const double theValue)
 Initializes an AsciiString with a real value.
 
 TCollection_AsciiString (const TCollection_AsciiString &theString)
 Initializes a AsciiString with another AsciiString.
 
 TCollection_AsciiString (TCollection_AsciiString &&theOther) noexcept
 Move constructor.
 
 TCollection_AsciiString (const TCollection_AsciiString &theString, const char theChar)
 Initializes a AsciiString with copy of another AsciiString concatenated with the message character.
 
 TCollection_AsciiString (const TCollection_AsciiString &theString, const char *const theMessage)
 Initializes a AsciiString with copy of another AsciiString concatenated with the message string.
 
 TCollection_AsciiString (const TCollection_AsciiString &theString, const TCollection_AsciiString &theOtherString)
 Initializes a AsciiString with copy of another AsciiString concatenated with the message string.
 
 TCollection_AsciiString (const TCollection_ExtendedString &theExtendedString, const char theReplaceNonAscii=0)
 Creation by converting an extended string to an ascii string. If replaceNonAscii is non-null character, it will be used in place of any non-ascii character found in the source string. Otherwise, creates UTF-8 unicode string.
 
 TCollection_AsciiString (const wchar_t *theStringUtf)
 Initialize UTF-8 Unicode string from wide-char string considering it as Unicode string (the size of wide char is a platform-dependent - e.g. on Windows wchar_t is UTF-16).
 
template<std::size_t N>
 TCollection_AsciiString (const char(&theLiteral)[N])
 Template constructor for string literals or char arrays.
 
void AssignCat (const char theOther)
 Appends other character to this string. This is an unary operator.
 
void operator+= (const char theOther)
 
void AssignCat (const int theOther)
 Appends other integer to this string. This is an unary operator.
 
void operator+= (const int theOther)
 
void AssignCat (const double theOther)
 Appends other real number to this string. This is an unary operator.
 
void operator+= (const double theOther)
 
void AssignCat (const TCollection_ExtendedString &theOther, const char theReplaceNonAscii=0)
 Appends an extended string to this ASCII string. If theReplaceNonAscii is non-null character, it will be used in place of any non-ASCII character found in the source string. Otherwise, appends UTF-8 representation of the source string.
 
void operator+= (const TCollection_ExtendedString &theOther)
 
void AssignCat (const wchar_t *theStringUtf)
 Appends wide-char string converted to UTF-8 representation.
 
void operator+= (const wchar_t *theStringUtf)
 
void AssignCat (const char *const theString, const int theLength)
 Core implementation: Appends string (pointer and length) to this ASCII string. This is the primary implementation that all other AssignCat overloads redirect to.
 
void AssignCat (const TCollection_AsciiString &theOther)
 Appends other string to this string. This is an unary operator.
 
void operator+= (const TCollection_AsciiString &theOther)
 
void AssignCat (const char *const theCString)
 Appends C string to this ASCII string.
 
void operator+= (const char *const theCString)
 
template<std::size_t N>
void AssignCat (const char(&theLiteral)[N])
 Template method for appending string literals or char arrays. For true string literals (const char[N] in code), the size is known at compile time. For char arrays (like sprintf buffers), we need to call strlen to get actual length.
 
template<std::size_t N>
void operator+= (const char(&theLiteral)[N])
 
void Capitalize ()
 Converts the first character into its corresponding upper-case character and the other characters into lowercase.
 
TCollection_AsciiString Cat (const char *const theString, const int theLength) const
 Core implementation: Appends string (pointer and length) to this ASCII string and returns a new string. This is the primary implementation that all other Cat overloads redirect to.
 
TCollection_AsciiString Cat (const char theOther) const
 Appends other character to this string.
 
TCollection_AsciiString operator+ (const char theOther) const
 
TCollection_AsciiString Cat (const int theOther) const
 Appends other integer to this string.
 
TCollection_AsciiString operator+ (const int theOther) const
 
TCollection_AsciiString Cat (const double theOther) const
 Appends other real number to this string.
 
TCollection_AsciiString operator+ (const double theOther) const
 
TCollection_AsciiString Cat (const TCollection_ExtendedString &theOther, const char theReplaceNonAscii=0) const
 Appends extended string to this string. If theReplaceNonAscii is non-null character, it will be used in place of any non-ASCII character found in the source string. Otherwise, concatenates UTF-8 representation of the source string.
 
TCollection_AsciiString operator+ (const TCollection_ExtendedString &theOther) const
 
TCollection_AsciiString Cat (const wchar_t *theStringUtf) const
 Appends wide-char string converted to UTF-8 representation.
 
TCollection_AsciiString operator+ (const wchar_t *theStringUtf) const
 
TCollection_AsciiString Cat (const TCollection_AsciiString &theOther) const
 Appends other string to this string.
 
TCollection_AsciiString operator+ (const TCollection_AsciiString &theOther) const
 
TCollection_AsciiString Cat (const char *const theCString) const
 Appends C string to this ASCII string.
 
TCollection_AsciiString operator+ (const char *const theCString) const
 
template<std::size_t N>
TCollection_AsciiString Cat (const char(&theLiteral)[N]) const
 Template method for concatenating string literals or char arrays. For safety, uses strlen to get actual string length.
 
template<std::size_t N>
TCollection_AsciiString operator+ (const char(&theLiteral)[N]) const
 
void Center (const int theWidth, const char theFiller)
 Modifies this ASCII string so that its length becomes equal to Width and the new characters are equal to Filler. New characters are added both at the beginning and at the end of this string. If Width is less than the length of this ASCII string, nothing happens.
 
void ChangeAll (const char theChar, const char theNewChar, const bool theCaseSensitive=true)
 Substitutes all the characters equal to aChar by NewChar in this AsciiString. The substitution can be case sensitive. If you don't use default case sensitive, no matter whether aChar is uppercase or not.
 
void Clear ()
 Removes all characters contained in this string. This produces an empty AsciiString.
 
void Copy (const char *const theString, const int theLength)
 Core implementation: Copy string (pointer and length) to this ASCII string. This is the primary implementation that all other Copy overloads redirect to. Used as operator =.
 
void Copy (const char *const theCString)
 Copy C string to this ASCII string. Used as operator =.
 
void operator= (const char *const theCString)
 
template<std::size_t N>
void Copy (const char(&theLiteral)[N])
 Template method for copying string literals or char arrays. For safety, uses strlen to get actual string length.
 
template<std::size_t N>
void operator= (const char(&theLiteral)[N])
 
void Copy (const TCollection_AsciiString &theFromWhere)
 Copy fromwhere to this string. Used as operator =.
 
TCollection_AsciiStringoperator= (const TCollection_AsciiString &theOther)
 Copy assignment operator.
 
void Move (TCollection_AsciiString &&theOther)
 Moves string without reallocations.
 
TCollection_AsciiStringoperator= (TCollection_AsciiString &&theOther) noexcept
 Move assignment operator.
 
void Swap (TCollection_AsciiString &theOther)
 Exchange the data of two strings (without reallocating memory).
 
 ~TCollection_AsciiString ()
 Frees memory allocated by AsciiString.
 
int FirstLocationInSet (const char *const theSet, const int theSetLength, const int theFromIndex, const int theToIndex) const
 Core implementation: Returns the index of the first character of this string that is present in the given character set (pointer and length). The search begins at index FromIndex and ends at index ToIndex. Returns zero if failure. Raises an exception if FromIndex or ToIndex is out of range.
 
int FirstLocationInSet (const TCollection_AsciiString &theSet, const int theFromIndex, const int theToIndex) const
 Returns the index of the first character of this string that is present in Set. The search begins to the index FromIndex and ends to the the index ToIndex. Returns zero if failure. Raises an exception if FromIndex or ToIndex is out of range.
 
template<std::size_t N>
int FirstLocationInSet (const char(&theLiteral)[N], const int theFromIndex, const int theToIndex) const
 Template method for FirstLocationInSet with string literals.
 
int FirstLocationNotInSet (const char *const theSet, const int theSetLength, const int theFromIndex, const int theToIndex) const
 Core implementation: Returns the index of the first character of this string that is not present in the given character set (pointer and length). The search begins at index FromIndex and ends at index ToIndex. Returns zero if failure. Raises an exception if FromIndex or ToIndex is out of range.
 
int FirstLocationNotInSet (const TCollection_AsciiString &theSet, const int theFromIndex, const int theToIndex) const
 Returns the index of the first character of this string that is not present in the set Set. The search begins to the index FromIndex and ends to the the index ToIndex in this string. Returns zero if failure. Raises an exception if FromIndex or ToIndex is out of range.
 
template<std::size_t N>
int FirstLocationNotInSet (const char(&theLiteral)[N], const int theFromIndex, const int theToIndex) const
 Template method for FirstLocationNotInSet with string literals.
 
void Insert (const int theWhere, const char theWhat)
 Inserts a Character at position where.
 
void Insert (const int theWhere, const char *const theString, const int theLength)
 Core implementation: Inserts a string (pointer and length) at position theWhere. This is the primary implementation that all other Insert overloads redirect to.
 
void Insert (const int theWhere, const TCollection_AsciiString &theWhat)
 Inserts a AsciiString at position where.
 
void Insert (const int theWhere, const char *const theCString)
 Inserts a C string at position theWhere.
 
template<std::size_t N>
void Insert (const int theWhere, const char(&theLiteral)[N])
 Template method for inserting string literals with compile-time size deduction. This optimization avoids runtime strlen() calls and unnecessary conversions.
 
void InsertAfter (const int theIndex, const char *const theString, const int theLength)
 Core implementation: Inserts string (pointer and length) after a specific index in this string. This is the primary implementation that all other InsertAfter overloads redirect to. Raises an exception if index is out of bounds (less than 0 or greater than the length).
 
void InsertAfter (const int theIndex, const TCollection_AsciiString &theOther)
 Inserts an ASCII string after a specific index in this string. Raises an exception if index is out of bounds.
 
void InsertAfter (const int theIndex, const char *const theCString)
 Inserts a C string after a specific index in this string. Raises an exception if index is out of bounds.
 
template<std::size_t N>
void InsertAfter (const int theIndex, const char(&theLiteral)[N])
 Template method for inserting string literals or char arrays after a specific index.
 
void InsertBefore (const int theIndex, const char *const theString, const int theLength)
 Core implementation: Inserts string (pointer and length) before a specific index in this string. This is the primary implementation that all other InsertBefore overloads redirect to. Raises an exception if index is out of bounds (less than 1 or greater than the length).
 
void InsertBefore (const int theIndex, const TCollection_AsciiString &theOther)
 Inserts an ASCII string before a specific index in this string. Raises an exception if index is out of bounds.
 
void InsertBefore (const int theIndex, const char *const theCString)
 Inserts a C string before a specific index in this string. Raises an exception if index is out of bounds.
 
template<std::size_t N>
void InsertBefore (const int theIndex, const char(&theLiteral)[N])
 Template method for inserting string literals or char arrays before a specific index.
 
bool IsEmpty () const
 Returns True if this string contains zero character.
 
bool IsEqual (const TCollection_AsciiString &theOther) const
 Returns true if the characters in this ASCII string are identical to the characters in ASCII string other. Note that this method is an alias of operator ==.
 
bool operator== (const TCollection_AsciiString &theOther) const
 
bool IsEqual (const char *const theString, const int theLength) const
 Core implementation: Returns true if the characters in this ASCII string are identical to the string (pointer and length). This is the primary implementation that string_view and CString overloads redirect to.
 
bool IsEqual (const char *const theCString) const
 Returns true if the characters in this ASCII string are identical to the C string.
 
bool operator== (const char *const theCString) const
 
template<std::size_t N>
bool IsEqual (const char(&theLiteral)[N]) const
 Template method for comparing with string literals with compile-time optimization. This optimization avoids runtime strlen() calls and unnecessary conversions.
 
template<std::size_t N>
bool operator== (const char(&theLiteral)[N]) const
 
bool IsDifferent (const TCollection_AsciiString &theOther) const
 Returns true if there are differences between the characters in this ASCII string and ASCII string other. Note that this method is an alias of operator !=.
 
bool operator!= (const TCollection_AsciiString &theOther) const
 
bool IsDifferent (const char *const theString, const int theLength) const
 Core implementation: Returns true if there are differences between this ASCII string and the string (pointer and length). This is the primary implementation that string_view and CString overloads redirect to.
 
bool IsDifferent (const char *const theCString) const
 Returns true if there are differences between this ASCII string and C string.
 
bool operator!= (const char *const theCString) const
 
template<std::size_t N>
bool IsDifferent (const char(&theLiteral)[N]) const
 Template method for comparing difference with string literals or char arrays.
 
template<std::size_t N>
bool operator!= (const char(&theLiteral)[N]) const
 
bool IsLess (const char *const theString, const int theLength) const
 Core implementation: Returns TRUE if this string is lexicographically less than the string (pointer and length). This is the primary implementation that all other IsLess overloads redirect to.
 
bool IsLess (const TCollection_AsciiString &theOther) const
 Returns TRUE if this string is 'ASCII' less than other.
 
bool operator< (const TCollection_AsciiString &theOther) const
 
bool IsLess (const char *const theCString) const
 Returns TRUE if this string is lexicographically less than C string.
 
bool operator< (const char *const theCString) const
 
template<std::size_t N>
bool IsLess (const char(&theLiteral)[N]) const
 Template method for lexicographic comparison with string literals or char arrays.
 
template<std::size_t N>
bool operator< (const char(&theLiteral)[N]) const
 
bool IsGreater (const char *const theString, const int theLength) const
 Core implementation: Returns TRUE if this string is lexicographically greater than the string (pointer and length). This is the primary implementation that all other IsGreater overloads redirect to.
 
bool IsGreater (const TCollection_AsciiString &theOther) const
 Returns TRUE if this string is 'ASCII' greater than other.
 
bool operator> (const TCollection_AsciiString &theOther) const
 
bool IsGreater (const char *const theCString) const
 Returns TRUE if this string is lexicographically greater than C string.
 
bool operator> (const char *const theCString) const
 
template<std::size_t N>
bool IsGreater (const char(&theLiteral)[N]) const
 Template method for lexicographic greater comparison with string literals or char arrays.
 
template<std::size_t N>
bool operator> (const char(&theLiteral)[N]) const
 
bool StartsWith (const char *const theStartString, const int theStartLength) const
 Core implementation: Determines whether the beginning of this string instance matches the specified string (pointer and length).
 
bool StartsWith (const TCollection_AsciiString &theStartString) const
 Determines whether the beginning of this string instance matches the specified string.
 
bool StartsWith (const char *const theCString) const
 Determines whether the beginning of this string matches the specified C string.
 
bool EndsWith (const char *const theEndString, const int theEndLength) const
 Core implementation: Determines whether the end of this string instance matches the specified string (pointer and length).
 
bool EndsWith (const TCollection_AsciiString &theEndString) const
 Determines whether the end of this string instance matches the specified string.
 
template<std::size_t N>
bool StartsWith (const char(&theLiteral)[N]) const
 Template method for checking if string starts with a literal or char array.
 
template<std::size_t N>
bool EndsWith (const char(&theLiteral)[N]) const
 Template method for checking if string ends with a literal or char array.
 
int IntegerValue () const
 Converts a AsciiString containing a numeric expression to an Integer.
 
bool IsIntegerValue () const
 Returns True if the AsciiString contains an integer value. Note: an integer value is considered to be a real value as well.
 
bool IsRealValue (bool theToCheckFull=false) const
 Returns True if the AsciiString starts with some characters that can be interpreted as integer or real value.
 
bool IsAscii () const
 Returns True if the AsciiString contains only ASCII characters between ' ' and '~'. This means no control character and no extended ASCII code.
 
void LeftAdjust ()
 Removes all space characters in the beginning of the string.
 
void LeftJustify (const int theWidth, const char theFiller)
 left justify Length becomes equal to Width and the new characters are equal to Filler. If Width < Length nothing happens. Raises an exception if Width is less than zero.
 
int Length () const
 Returns number of characters in this string. This is the same functionality as 'strlen' in C.
 
int Location (const TCollection_AsciiString &theOther, const int theFromIndex, const int theToIndex) const
 Returns an index in this string of the first occurrence of the string S in this string from the starting index FromIndex to the ending index ToIndex returns zero if failure Raises an exception if FromIndex or ToIndex is out of range.
 
int Location (const int theN, const char theC, const int theFromIndex, const int theToIndex) const
 Returns the index of the nth occurrence of the character C in this string from the starting index FromIndex to the ending index ToIndex. Returns zero if failure. Raises an exception if FromIndex or ToIndex is out of range.
 
void LowerCase ()
 Converts this string to its lower-case equivalent.
 
void Prepend (const TCollection_AsciiString &theOther)
 Inserts the string other at the beginning of this ASCII string.
 
void Print (Standard_OStream &theStream) const
 Displays this string on a stream.
 
void Read (Standard_IStream &theStream)
 Read this string from a stream.
 
double RealValue () const
 Converts an AsciiString containing a numeric expression to a Real.
 
void RemoveAll (const char theC, const bool theCaseSensitive)
 Remove all the occurrences of the character C in the string.
 
void RemoveAll (const char theWhat)
 Removes every what characters from this string.
 
void Remove (const int theWhere, const int theHowMany=1)
 Erases ahowmany characters from position where, where included.
 
void RightAdjust ()
 Removes all space characters at the end of the string.
 
void RightJustify (const int theWidth, const char theFiller)
 Right justify. Length becomes equal to Width and the new characters are equal to Filler. if Width < Length nothing happens. Raises an exception if Width is less than zero.
 
int Search (const char *const theWhat, const int theWhatLength) const
 Core implementation: Searches a string (pointer and length) in this string from the beginning and returns position of first item matching. It returns -1 if not found.
 
int Search (const TCollection_AsciiString &theWhat) const
 Searches an AsciiString in this string from the beginning and returns position of first item what matching. It returns -1 if not found.
 
int Search (const char *const theCString) const
 Searches a C string in this string from the beginning.
 
template<std::size_t N>
int Search (const char(&theLiteral)[N]) const
 Template method for searching string literals or char arrays.
 
int SearchFromEnd (const char *const theWhat, const int theWhatLength) const
 Core implementation: Searches a string (pointer and length) in this string from the end and returns position of first item matching. It returns -1 if not found.
 
int SearchFromEnd (const TCollection_AsciiString &theWhat) const
 Searches a AsciiString in another AsciiString from the end and returns position of first item what matching. It returns -1 if not found.
 
int SearchFromEnd (const char *const theCString) const
 Searches a C string in this string from the end.
 
template<std::size_t N>
int SearchFromEnd (const char(&theLiteral)[N]) const
 Template method for searching string literals or char arrays from end.
 
void SetValue (const int theWhere, const char theWhat)
 Replaces one character in the AsciiString at position where. If where is less than zero or greater than the length of this string an exception is raised.
 
void SetValue (const int theWhere, const char *const theString, const int theLength)
 Core implementation: Replaces a part of this string with a string (pointer and length). This is the primary implementation that all other SetValue string overloads redirect to.
 
void SetValue (const int theWhere, const TCollection_AsciiString &theWhat)
 Replaces a part of this string by another AsciiString.
 
void SetValue (const int theWhere, const char *const theCString)
 Replaces a part of this ASCII string with a C string.
 
TCollection_AsciiString Split (const int theWhere)
 Splits a AsciiString into two sub-strings.
 
TCollection_AsciiString SubString (const int theFromIndex, const int theToIndex) const
 Creation of a sub-string of this string. The sub-string starts to the index Fromindex and ends to the index ToIndex. Raises an exception if ToIndex or FromIndex is out of bounds.
 
const charToCString () const
 Returns pointer to AsciiString (char *). This is useful for some casual manipulations. Warning: Because this "char *" is 'const', you can't modify its contents.
 
TCollection_AsciiString Token (const char *const theSeparators=" \t", const int theWhichOne=1) const
 Extracts whichone token from this string. By default, the separators is set to space and tabulation. By default, the token extracted is the first one (whichone = 1). separators contains all separators you need. If no token indexed by whichone is found, it returns empty AsciiString.
 
void Trunc (const int theHowMany)
 Truncates this string to ahowmany characters.
 
void UpperCase ()
 Converts this string to its upper-case equivalent.
 
int UsefullLength () const
 Length of the string ignoring all spaces (' ') and the control character at the end.
 
char Value (const int theWhere) const
 Returns character at position where in this string. If where is less than zero or greater than the length of this string, an exception is raised.
 
size_t HashCode () const
 Computes a hash code for the given ASCII string Returns the same integer value as the hash function for TCollection_ExtendedString.
 

Static Public Member Functions

static const TCollection_AsciiStringEmptyString () noexcept
 Returns a const reference to a single shared empty string instance. This method provides access to a static empty string to avoid creating temporary empty strings. Use this method instead of constructing empty strings when you need a const reference.
 
static bool IsEqual (const TCollection_AsciiString &string1, const TCollection_AsciiString &string2)
 Returns True when the two strings are the same. (Just for HashCode for AsciiString)
 
static bool IsEqual (const TCollection_AsciiString &string1, const char *const string2)
 Returns True when the two strings are the same. (Just for HashCode for AsciiString)
 
static bool IsSameString (const char *const theString1, const int theLength1, const char *const theString2, const int theLength2, const bool theIsCaseSensitive)
 Core implementation: Returns True if the two strings (pointer and length) contain same characters. This is the primary implementation that all other IsSameString overloads redirect to.
 
static bool IsSameString (const TCollection_AsciiString &theString1, const TCollection_AsciiString &theString2, const bool theIsCaseSensitive)
 Returns True if the strings contain same characters.
 
static bool IsSameString (const TCollection_AsciiString &theString1, const char *const theCString, const bool theIsCaseSensitive)
 Returns True if the string and C string contain same characters.
 
static bool IsSameString (const char *const theCString, const TCollection_AsciiString &theString2, const bool theIsCaseSensitive)
 Returns True if the C string and string contain same characters.
 
static bool IsSameString (const char *const theCString1, const char *const theCString2, const bool theIsCaseSensitive)
 Returns True if the two C strings contain same characters.
 

Detailed Description

Class defines a variable-length sequence of 8-bit characters. Despite class name (kept for historical reasons), it is intended to store UTF-8 string, not just ASCII characters. However, multi-byte nature of UTF-8 is not considered by the following methods:

Class provides editing operations with built-in memory management to make AsciiString objects easier to use than ordinary character arrays. AsciiString objects follow value semantics; in other words, they are the actual strings, not handles to strings, and are copied through assignment. You may use HAsciiString objects to get handles to strings.

Constructor & Destructor Documentation

◆ TCollection_AsciiString() [1/15]

TCollection_AsciiString::TCollection_AsciiString ( )
noexcept

Initializes a AsciiString to an empty AsciiString.

◆ TCollection_AsciiString() [2/15]

TCollection_AsciiString::TCollection_AsciiString ( const char *const theMessage)
inline

Initializes a AsciiString with a CString (null-terminated).

Parameters
[in]theMessagethe C string to initialize from

◆ TCollection_AsciiString() [3/15]

TCollection_AsciiString::TCollection_AsciiString ( const char *const theMessage,
const int theLength )

Initializes a AsciiString with a CString and explicit length.

Parameters
[in]theMessagethe C string to initialize from
[in]theLengththe length of the string

◆ TCollection_AsciiString() [4/15]

TCollection_AsciiString::TCollection_AsciiString ( const char theChar)

Initializes a AsciiString with a single character.

Parameters
[in]theCharthe character to initialize from

◆ TCollection_AsciiString() [5/15]

TCollection_AsciiString::TCollection_AsciiString ( const int theLength,
const char theFiller )

Initializes an AsciiString with specified length space allocated and filled with filler character. This is useful for buffers.

Parameters
[in]theLengththe length to allocate
[in]theFillerthe character to fill with

◆ TCollection_AsciiString() [6/15]

TCollection_AsciiString::TCollection_AsciiString ( const int theValue)

Initializes an AsciiString with an integer value.

Parameters
[in]theValuethe integer value to convert to string

◆ TCollection_AsciiString() [7/15]

TCollection_AsciiString::TCollection_AsciiString ( const double theValue)

Initializes an AsciiString with a real value.

Parameters
[in]theValuethe real value to convert to string

◆ TCollection_AsciiString() [8/15]

TCollection_AsciiString::TCollection_AsciiString ( const TCollection_AsciiString & theString)

Initializes a AsciiString with another AsciiString.

Parameters
[in]theStringthe string to copy from

◆ TCollection_AsciiString() [9/15]

TCollection_AsciiString::TCollection_AsciiString ( TCollection_AsciiString && theOther)
noexcept

Move constructor.

Parameters
[in]theOtherthe string to move from

◆ TCollection_AsciiString() [10/15]

TCollection_AsciiString::TCollection_AsciiString ( const TCollection_AsciiString & theString,
const char theChar )

Initializes a AsciiString with copy of another AsciiString concatenated with the message character.

Parameters
[in]theStringthe string to copy
[in]theCharthe character to append

◆ TCollection_AsciiString() [11/15]

TCollection_AsciiString::TCollection_AsciiString ( const TCollection_AsciiString & theString,
const char *const theMessage )

Initializes a AsciiString with copy of another AsciiString concatenated with the message string.

Parameters
[in]theStringthe string to copy
[in]theMessagethe C string to append

◆ TCollection_AsciiString() [12/15]

TCollection_AsciiString::TCollection_AsciiString ( const TCollection_AsciiString & theString,
const TCollection_AsciiString & theOtherString )

Initializes a AsciiString with copy of another AsciiString concatenated with the message string.

Parameters
[in]theStringthe string to copy
[in]theOtherStringthe string to append

◆ TCollection_AsciiString() [13/15]

TCollection_AsciiString::TCollection_AsciiString ( const TCollection_ExtendedString & theExtendedString,
const char theReplaceNonAscii = 0 )

Creation by converting an extended string to an ascii string. If replaceNonAscii is non-null character, it will be used in place of any non-ascii character found in the source string. Otherwise, creates UTF-8 unicode string.

Parameters
[in]theExtendedStringthe extended string to convert
[in]theReplaceNonAsciireplacement character for non-ASCII characters

◆ TCollection_AsciiString() [14/15]

TCollection_AsciiString::TCollection_AsciiString ( const wchar_t * theStringUtf)

Initialize UTF-8 Unicode string from wide-char string considering it as Unicode string (the size of wide char is a platform-dependent - e.g. on Windows wchar_t is UTF-16).

This constructor is unavailable if application is built with deprecated msvc option "-Zc:wchar_t-", since OCCT itself is never built with this option.

Parameters
[in]theStringUtfthe wide character string to convert

◆ TCollection_AsciiString() [15/15]

template<std::size_t N>
TCollection_AsciiString::TCollection_AsciiString ( const char(&) theLiteral[N])
inline

Template constructor for string literals or char arrays.

Parameters
[in]theLiteralthe string literal or char array

◆ ~TCollection_AsciiString()

TCollection_AsciiString::~TCollection_AsciiString ( )

Frees memory allocated by AsciiString.

Member Function Documentation

◆ AssignCat() [1/9]

void TCollection_AsciiString::AssignCat ( const char *const theCString)
inline

Appends C string to this ASCII string.

Parameters
[in]theCStringthe C string to append

◆ AssignCat() [2/9]

void TCollection_AsciiString::AssignCat ( const char *const theString,
const int theLength )

Core implementation: Appends string (pointer and length) to this ASCII string. This is the primary implementation that all other AssignCat overloads redirect to.

Parameters
[in]theStringpointer to the string to append
[in]theLengthlength of the string to append

◆ AssignCat() [3/9]

void TCollection_AsciiString::AssignCat ( const char theOther)

Appends other character to this string. This is an unary operator.

Parameters
[in]theOtherthe character to append

◆ AssignCat() [4/9]

template<std::size_t N>
void TCollection_AsciiString::AssignCat ( const char(&) theLiteral[N])
inline

Template method for appending string literals or char arrays. For true string literals (const char[N] in code), the size is known at compile time. For char arrays (like sprintf buffers), we need to call strlen to get actual length.

Example:

aString += " World"; // Size known at compile time for string literal
char buffer[50]; sprintf(buffer, "test");
aString += buffer; // Uses strlen for actual length
GLuint buffer
Definition OpenGl_glext.h:707
STL input iterator that wraps an OCCT More()/Next() iterator.
Definition NCollection_ForwardRange.hxx:142
Class defines a variable-length sequence of 8-bit characters. Despite class name (kept for historical...
Definition TCollection_AsciiString.hxx:53
Parameters
[in]theLiteralthe string literal or char array to append

◆ AssignCat() [5/9]

void TCollection_AsciiString::AssignCat ( const double theOther)

Appends other real number to this string. This is an unary operator.

Parameters
[in]theOtherthe real number to append

◆ AssignCat() [6/9]

void TCollection_AsciiString::AssignCat ( const int theOther)

Appends other integer to this string. This is an unary operator.

Parameters
[in]theOtherthe integer to append

◆ AssignCat() [7/9]

void TCollection_AsciiString::AssignCat ( const TCollection_AsciiString & theOther)
inline

Appends other string to this string. This is an unary operator.

Example:

// Result: aString == "Hello World"
Parameters
[in]theOtherthe string to append

◆ AssignCat() [8/9]

void TCollection_AsciiString::AssignCat ( const TCollection_ExtendedString & theOther,
const char theReplaceNonAscii = 0 )

Appends an extended string to this ASCII string. If theReplaceNonAscii is non-null character, it will be used in place of any non-ASCII character found in the source string. Otherwise, appends UTF-8 representation of the source string.

Parameters
[in]theOtherthe extended string to append
[in]theReplaceNonAsciireplacement character for non-ASCII characters

◆ AssignCat() [9/9]

void TCollection_AsciiString::AssignCat ( const wchar_t * theStringUtf)

Appends wide-char string converted to UTF-8 representation.

Parameters
[in]theStringUtfthe wide character string to append

◆ Capitalize()

void TCollection_AsciiString::Capitalize ( )

Converts the first character into its corresponding upper-case character and the other characters into lowercase.

Example:

aString.Capitalize();
// Result: aString == "Hello "

◆ Cat() [1/9]

TCollection_AsciiString TCollection_AsciiString::Cat ( const char *const theCString) const
inline

Appends C string to this ASCII string.

Parameters
[in]theCStringthe C string to append
Returns
new string with C string appended

◆ Cat() [2/9]

TCollection_AsciiString TCollection_AsciiString::Cat ( const char *const theString,
const int theLength ) const

Core implementation: Appends string (pointer and length) to this ASCII string and returns a new string. This is the primary implementation that all other Cat overloads redirect to.

Parameters
[in]theStringpointer to the string to append
[in]theLengthlength of the string to append
Returns
new string with the string appended

◆ Cat() [3/9]

TCollection_AsciiString TCollection_AsciiString::Cat ( const char theOther) const
inline

Appends other character to this string.

Example:

// Result: aResult == "I say !"
// To catenate more, you must put a String before.
// "Hello " + "Dolly" // THIS IS NOT ALLOWED
// This rule is applicable to AssignCat (operator +=) too.
Parameters
[in]theOtherthe character to append
Returns
new string with character appended

◆ Cat() [4/9]

template<std::size_t N>
TCollection_AsciiString TCollection_AsciiString::Cat ( const char(&) theLiteral[N]) const
inline

Template method for concatenating string literals or char arrays. For safety, uses strlen to get actual string length.

Example:

TCollection_AsciiString aResult = aString + " World"; // String literal
char buffer[50]; sprintf(buffer, "test");
aResult = aString + buffer; // Char array - uses strlen
// Result: aResult == "Hello test"
Parameters
[in]theLiteralthe string literal or char array to concatenate
Returns
new string with literal appended

◆ Cat() [5/9]

TCollection_AsciiString TCollection_AsciiString::Cat ( const double theOther) const

Appends other real number to this string.

Example:

// Result: aResult == "I say 15.15"
Parameters
[in]theOtherthe real number to append
Returns
new string with real number appended

◆ Cat() [6/9]

TCollection_AsciiString TCollection_AsciiString::Cat ( const int theOther) const

Appends other integer to this string.

Example:

// Result: aResult == "I say 15"
Parameters
[in]theOtherthe integer to append
Returns
new string with integer appended

◆ Cat() [7/9]

TCollection_AsciiString TCollection_AsciiString::Cat ( const TCollection_AsciiString & theOther) const
inline

Appends other string to this string.

Example:

Parameters
[in]theOtherthe string to append
Returns
new string with other string appended

◆ Cat() [8/9]

TCollection_AsciiString TCollection_AsciiString::Cat ( const TCollection_ExtendedString & theOther,
const char theReplaceNonAscii = 0 ) const

Appends extended string to this string. If theReplaceNonAscii is non-null character, it will be used in place of any non-ASCII character found in the source string. Otherwise, concatenates UTF-8 representation of the source string.

Parameters
[in]theOtherthe extended string to append
[in]theReplaceNonAsciireplacement character for non-ASCII characters
Returns
new string with extended string appended

◆ Cat() [9/9]

TCollection_AsciiString TCollection_AsciiString::Cat ( const wchar_t * theStringUtf) const

Appends wide-char string converted to UTF-8 representation.

Parameters
[in]theStringUtfthe wide character string to append
Returns
new string with wide-char string appended

◆ Center()

void TCollection_AsciiString::Center ( const int theWidth,
const char theFiller )

Modifies this ASCII string so that its length becomes equal to Width and the new characters are equal to Filler. New characters are added both at the beginning and at the end of this string. If Width is less than the length of this ASCII string, nothing happens.

Example:

anAlphabet.Center(9, ' ');
// Result: anAlphabet == " abcdef "
Parameters
[in]theWidththe desired width
[in]theFillerthe character to fill with

◆ ChangeAll()

void TCollection_AsciiString::ChangeAll ( const char theChar,
const char theNewChar,
const bool theCaseSensitive = true )

Substitutes all the characters equal to aChar by NewChar in this AsciiString. The substitution can be case sensitive. If you don't use default case sensitive, no matter whether aChar is uppercase or not.

Example:

aString.ChangeAll('H', 'M', true);
// Result: aString == "Mistake"
Parameters
[in]theCharthe character to replace
[in]theNewCharthe replacement character
[in]theCaseSensitiveflag indicating case sensitivity

◆ Clear()

void TCollection_AsciiString::Clear ( )

Removes all characters contained in this string. This produces an empty AsciiString.

◆ Copy() [1/4]

void TCollection_AsciiString::Copy ( const char *const theCString)
inline

Copy C string to this ASCII string. Used as operator =.

Parameters
[in]theCStringthe C string to copy from

◆ Copy() [2/4]

void TCollection_AsciiString::Copy ( const char *const theString,
const int theLength )

Core implementation: Copy string (pointer and length) to this ASCII string. This is the primary implementation that all other Copy overloads redirect to. Used as operator =.

Parameters
[in]theStringpointer to the string to copy from
[in]theLengthlength of the string to copy

◆ Copy() [3/4]

template<std::size_t N>
void TCollection_AsciiString::Copy ( const char(&) theLiteral[N])
inline

Template method for copying string literals or char arrays. For safety, uses strlen to get actual string length.

Example:

aString = "Hello World"; // String literal
char buffer[50]; sprintf(buffer, "test");
aString = buffer; // Char array - uses strlen
// Result: aString == "test"
Parameters
[in]theLiteralthe string literal or char array to copy from

◆ Copy() [4/4]

void TCollection_AsciiString::Copy ( const TCollection_AsciiString & theFromWhere)
inline

Copy fromwhere to this string. Used as operator =.

Example:

aString = anotherString; // operator=
// Result: aString == "Hello World"

◆ EmptyString()

static const TCollection_AsciiString & TCollection_AsciiString::EmptyString ( )
staticnoexcept

Returns a const reference to a single shared empty string instance. This method provides access to a static empty string to avoid creating temporary empty strings. Use this method instead of constructing empty strings when you need a const reference.

Example:

// Use anEmptyStr instead of TCollection_AsciiString()
static const TCollection_AsciiString & EmptyString() noexcept
Returns a const reference to a single shared empty string instance. This method provides access to a ...
Returns
const reference to static empty string

◆ EndsWith() [1/3]

bool TCollection_AsciiString::EndsWith ( const char *const theEndString,
const int theEndLength ) const

Core implementation: Determines whether the end of this string instance matches the specified string (pointer and length).

Parameters
[in]theEndStringpointer to the string to check for at the end
[in]theEndLengthlength of the string to check for
Returns
true if this string ends with theEndString

◆ EndsWith() [2/3]

template<std::size_t N>
bool TCollection_AsciiString::EndsWith ( const char(&) theLiteral[N]) const
inline

Template method for checking if string ends with a literal or char array.

Parameters
[in]theLiteralthe string literal or char array to check for at the end
Returns
true if this string ends with literal

◆ EndsWith() [3/3]

bool TCollection_AsciiString::EndsWith ( const TCollection_AsciiString & theEndString) const
inline

Determines whether the end of this string instance matches the specified string.

Parameters
[in]theEndStringthe string to check for at the end
Returns
true if this string ends with theEndString

◆ FirstLocationInSet() [1/3]

int TCollection_AsciiString::FirstLocationInSet ( const char *const theSet,
const int theSetLength,
const int theFromIndex,
const int theToIndex ) const

Core implementation: Returns the index of the first character of this string that is present in the given character set (pointer and length). The search begins at index FromIndex and ends at index ToIndex. Returns zero if failure. Raises an exception if FromIndex or ToIndex is out of range.

Parameters
[in]theSetpointer to the set of characters to search for
[in]theSetLengthlength of the set
[in]theFromIndexthe starting index for search
[in]theToIndexthe ending index for search
Returns
the index of first character found in set, or 0 if not found

◆ FirstLocationInSet() [2/3]

template<std::size_t N>
int TCollection_AsciiString::FirstLocationInSet ( const char(&) theLiteral[N],
const int theFromIndex,
const int theToIndex ) const
inline

Template method for FirstLocationInSet with string literals.

Parameters
[in]theLiteralthe string literal of characters to search for
[in]theFromIndexthe starting index for search
[in]theToIndexthe ending index for search
Returns
the index of first character found in set, or 0 if not found

◆ FirstLocationInSet() [3/3]

int TCollection_AsciiString::FirstLocationInSet ( const TCollection_AsciiString & theSet,
const int theFromIndex,
const int theToIndex ) const
inline

Returns the index of the first character of this string that is present in Set. The search begins to the index FromIndex and ends to the the index ToIndex. Returns zero if failure. Raises an exception if FromIndex or ToIndex is out of range.

Example:

int anIndex = aString.FirstLocationInSet(aSet, 1, 7);
// Result: anIndex == 1
Parameters
[in]theSetthe set of characters to search for
[in]theFromIndexthe starting index for search
[in]theToIndexthe ending index for search
Returns
the index of first character found in set, or 0 if not found

◆ FirstLocationNotInSet() [1/3]

int TCollection_AsciiString::FirstLocationNotInSet ( const char *const theSet,
const int theSetLength,
const int theFromIndex,
const int theToIndex ) const

Core implementation: Returns the index of the first character of this string that is not present in the given character set (pointer and length). The search begins at index FromIndex and ends at index ToIndex. Returns zero if failure. Raises an exception if FromIndex or ToIndex is out of range.

Parameters
[in]theSetpointer to the set of characters to check against
[in]theSetLengthlength of the set
[in]theFromIndexthe starting index for search
[in]theToIndexthe ending index for search
Returns
the index of first character not in set, or 0 if not found

◆ FirstLocationNotInSet() [2/3]

template<std::size_t N>
int TCollection_AsciiString::FirstLocationNotInSet ( const char(&) theLiteral[N],
const int theFromIndex,
const int theToIndex ) const
inline

Template method for FirstLocationNotInSet with string literals.

Parameters
[in]theLiteralthe string literal of characters to check against
[in]theFromIndexthe starting index for search
[in]theToIndexthe ending index for search
Returns
the index of first character not in set, or 0 if not found

◆ FirstLocationNotInSet() [3/3]

int TCollection_AsciiString::FirstLocationNotInSet ( const TCollection_AsciiString & theSet,
const int theFromIndex,
const int theToIndex ) const
inline

Returns the index of the first character of this string that is not present in the set Set. The search begins to the index FromIndex and ends to the the index ToIndex in this string. Returns zero if failure. Raises an exception if FromIndex or ToIndex is out of range.

Example:

int anIndex = aString.FirstLocationNotInSet(aSet, 1, 7);
// Result: anIndex == 3
Parameters
[in]theSetthe set of characters to check against
[in]theFromIndexthe starting index for search
[in]theToIndexthe ending index for search
Returns
the index of first character not in set, or 0 if not found

◆ HashCode()

size_t TCollection_AsciiString::HashCode ( ) const
inline

Computes a hash code for the given ASCII string Returns the same integer value as the hash function for TCollection_ExtendedString.

Returns
a computed hash code

◆ Insert() [1/5]

void TCollection_AsciiString::Insert ( const int theWhere,
const char *const theCString )
inline

Inserts a C string at position theWhere.

Parameters
[in]theWhereposition to insert at
[in]theCStringthe C string to insert

◆ Insert() [2/5]

void TCollection_AsciiString::Insert ( const int theWhere,
const char *const theString,
const int theLength )

Core implementation: Inserts a string (pointer and length) at position theWhere. This is the primary implementation that all other Insert overloads redirect to.

Parameters
[in]theWhereposition to insert at
[in]theStringpointer to the string to insert
[in]theLengthlength of the string to insert

◆ Insert() [3/5]

void TCollection_AsciiString::Insert ( const int theWhere,
const char theWhat )

Inserts a Character at position where.

Example:

aString.Insert(1, 'W');
// Result: aString == "Why not ?"
bString.Insert(3, 'y');
// Result: bString == "Why"
Parameters
[in]theWherethe position to insert at
[in]theWhatthe character to insert

◆ Insert() [4/5]

template<std::size_t N>
void TCollection_AsciiString::Insert ( const int theWhere,
const char(&) theLiteral[N] )
inline

Template method for inserting string literals with compile-time size deduction. This optimization avoids runtime strlen() calls and unnecessary conversions.

Example:

aString.Insert(2, "nce"); // Size known at compile time
// Result: aString == "Once more"
Parameters
[in]theWherethe position to insert at
[in]theLiteralthe string literal or char array to insert

◆ Insert() [5/5]

void TCollection_AsciiString::Insert ( const int theWhere,
const TCollection_AsciiString & theWhat )
inline

Inserts a AsciiString at position where.

Parameters
[in]theWherethe position to insert at
[in]theWhatthe ASCII string to insert

◆ InsertAfter() [1/4]

void TCollection_AsciiString::InsertAfter ( const int theIndex,
const char *const theCString )
inline

Inserts a C string after a specific index in this string. Raises an exception if index is out of bounds.

Parameters
[in]theIndexthe index to insert after
[in]theCStringthe C string to insert

◆ InsertAfter() [2/4]

void TCollection_AsciiString::InsertAfter ( const int theIndex,
const char *const theString,
const int theLength )

Core implementation: Inserts string (pointer and length) after a specific index in this string. This is the primary implementation that all other InsertAfter overloads redirect to. Raises an exception if index is out of bounds (less than 0 or greater than the length).

Parameters
[in]theIndexthe index to insert after
[in]theStringpointer to the string to insert
[in]theLengthlength of the string to insert

◆ InsertAfter() [3/4]

template<std::size_t N>
void TCollection_AsciiString::InsertAfter ( const int theIndex,
const char(&) theLiteral[N] )
inline

Template method for inserting string literals or char arrays after a specific index.

Parameters
[in]theIndexthe index to insert after
[in]theLiteralthe string literal or char array to insert

◆ InsertAfter() [4/4]

void TCollection_AsciiString::InsertAfter ( const int theIndex,
const TCollection_AsciiString & theOther )
inline

Inserts an ASCII string after a specific index in this string. Raises an exception if index is out of bounds.

Parameters
[in]theIndexthe index to insert after
[in]theOtherthe string to insert

◆ InsertBefore() [1/4]

void TCollection_AsciiString::InsertBefore ( const int theIndex,
const char *const theCString )
inline

Inserts a C string before a specific index in this string. Raises an exception if index is out of bounds.

Parameters
[in]theIndexthe index to insert before
[in]theCStringthe C string to insert

◆ InsertBefore() [2/4]

void TCollection_AsciiString::InsertBefore ( const int theIndex,
const char *const theString,
const int theLength )

Core implementation: Inserts string (pointer and length) before a specific index in this string. This is the primary implementation that all other InsertBefore overloads redirect to. Raises an exception if index is out of bounds (less than 1 or greater than the length).

Parameters
[in]theIndexthe index to insert before
[in]theStringpointer to the string to insert
[in]theLengthlength of the string to insert

◆ InsertBefore() [3/4]

template<std::size_t N>
void TCollection_AsciiString::InsertBefore ( const int theIndex,
const char(&) theLiteral[N] )
inline

Template method for inserting string literals or char arrays before a specific index.

Parameters
[in]theIndexthe index to insert before
[in]theLiteralthe string literal or char array to insert

◆ InsertBefore() [4/4]

void TCollection_AsciiString::InsertBefore ( const int theIndex,
const TCollection_AsciiString & theOther )
inline

Inserts an ASCII string before a specific index in this string. Raises an exception if index is out of bounds.

Parameters
[in]theIndexthe index to insert before
[in]theOtherthe string to insert

◆ IntegerValue()

int TCollection_AsciiString::IntegerValue ( ) const

Converts a AsciiString containing a numeric expression to an Integer.

Example:

int anInt = aString.IntegerValue();
// Result: anInt == 215
Returns
the integer value of the string

◆ IsAscii()

bool TCollection_AsciiString::IsAscii ( ) const

Returns True if the AsciiString contains only ASCII characters between ' ' and '~'. This means no control character and no extended ASCII code.

Returns
true if string contains only ASCII characters

◆ IsDifferent() [1/4]

bool TCollection_AsciiString::IsDifferent ( const char *const theCString) const
inline

Returns true if there are differences between this ASCII string and C string.

Parameters
[in]theCStringthe C string to compare with
Returns
true if strings are different, false otherwise

◆ IsDifferent() [2/4]

bool TCollection_AsciiString::IsDifferent ( const char *const theString,
const int theLength ) const
inline

Core implementation: Returns true if there are differences between this ASCII string and the string (pointer and length). This is the primary implementation that string_view and CString overloads redirect to.

Parameters
[in]theStringpointer to the string to compare with
[in]theLengthlength of the string to compare with
Returns
true if strings are different, false otherwise

◆ IsDifferent() [3/4]

template<std::size_t N>
bool TCollection_AsciiString::IsDifferent ( const char(&) theLiteral[N]) const
inline

Template method for comparing difference with string literals or char arrays.

Parameters
[in]theLiteralthe string literal or char array to compare with
Returns
true if strings are different, false otherwise

◆ IsDifferent() [4/4]

bool TCollection_AsciiString::IsDifferent ( const TCollection_AsciiString & theOther) const
inline

Returns true if there are differences between the characters in this ASCII string and ASCII string other. Note that this method is an alias of operator !=.

Parameters
[in]theOtherthe ASCII string to compare with
Returns
true if strings are different, false otherwise

◆ IsEmpty()

bool TCollection_AsciiString::IsEmpty ( ) const
inline

Returns True if this string contains zero character.

◆ IsEqual() [1/6]

bool TCollection_AsciiString::IsEqual ( const char *const theCString) const
inline

Returns true if the characters in this ASCII string are identical to the C string.

Parameters
[in]theCStringthe C string to compare with
Returns
true if strings are equal, false otherwise

◆ IsEqual() [2/6]

bool TCollection_AsciiString::IsEqual ( const char *const theString,
const int theLength ) const

Core implementation: Returns true if the characters in this ASCII string are identical to the string (pointer and length). This is the primary implementation that string_view and CString overloads redirect to.

Parameters
[in]theStringpointer to the string to compare with
[in]theLengthlength of the string to compare with
Returns
true if strings are equal, false otherwise

◆ IsEqual() [3/6]

template<std::size_t N>
bool TCollection_AsciiString::IsEqual ( const char(&) theLiteral[N]) const
inline

Template method for comparing with string literals with compile-time optimization. This optimization avoids runtime strlen() calls and unnecessary conversions.

Example:

bool isEqual = aString.IsEqual("Hello"); // Size known at compile time
bool isEqual2 = (aString == "Hello"); // Same optimization
Parameters
[in]theLiteralthe string literal or char array to compare with
Returns
true if strings are equal, false otherwise

◆ IsEqual() [4/6]

static bool TCollection_AsciiString::IsEqual ( const TCollection_AsciiString & string1,
const char *const string2 )
static

Returns True when the two strings are the same. (Just for HashCode for AsciiString)

Parameters
[in]string1first string to compare
[in]string2second C string to compare
Returns
true if strings are equal

◆ IsEqual() [5/6]

static bool TCollection_AsciiString::IsEqual ( const TCollection_AsciiString & string1,
const TCollection_AsciiString & string2 )
inlinestatic

Returns True when the two strings are the same. (Just for HashCode for AsciiString)

Parameters
[in]string1first string to compare
[in]string2second string to compare
Returns
true if strings are equal

◆ IsEqual() [6/6]

bool TCollection_AsciiString::IsEqual ( const TCollection_AsciiString & theOther) const
inline

Returns true if the characters in this ASCII string are identical to the characters in ASCII string other. Note that this method is an alias of operator ==.

Parameters
[in]theOtherthe ASCII string to compare with
Returns
true if strings are equal, false otherwise

◆ IsGreater() [1/4]

bool TCollection_AsciiString::IsGreater ( const char *const theCString) const
inline

Returns TRUE if this string is lexicographically greater than C string.

Parameters
[in]theCStringthe C string to compare with
Returns
true if this string is lexicographically greater than C string

◆ IsGreater() [2/4]

bool TCollection_AsciiString::IsGreater ( const char *const theString,
const int theLength ) const

Core implementation: Returns TRUE if this string is lexicographically greater than the string (pointer and length). This is the primary implementation that all other IsGreater overloads redirect to.

Parameters
[in]theStringpointer to the string to compare with
[in]theLengthlength of the string to compare with
Returns
true if this string is lexicographically greater than the given string

◆ IsGreater() [3/4]

template<std::size_t N>
bool TCollection_AsciiString::IsGreater ( const char(&) theLiteral[N]) const
inline

Template method for lexicographic greater comparison with string literals or char arrays.

Parameters
[in]theLiteralthe string literal or char array to compare with
Returns
true if this string is lexicographically greater than literal

◆ IsGreater() [4/4]

bool TCollection_AsciiString::IsGreater ( const TCollection_AsciiString & theOther) const
inline

Returns TRUE if this string is 'ASCII' greater than other.

Parameters
[in]theOtherthe ASCII string to compare with
Returns
true if this string is lexicographically greater than other

◆ IsIntegerValue()

bool TCollection_AsciiString::IsIntegerValue ( ) const

Returns True if the AsciiString contains an integer value. Note: an integer value is considered to be a real value as well.

Returns
true if string represents an integer value

◆ IsLess() [1/4]

bool TCollection_AsciiString::IsLess ( const char *const theCString) const
inline

Returns TRUE if this string is lexicographically less than C string.

Parameters
[in]theCStringthe C string to compare with
Returns
true if this string is lexicographically less than C string

◆ IsLess() [2/4]

bool TCollection_AsciiString::IsLess ( const char *const theString,
const int theLength ) const

Core implementation: Returns TRUE if this string is lexicographically less than the string (pointer and length). This is the primary implementation that all other IsLess overloads redirect to.

Parameters
[in]theStringpointer to the string to compare with
[in]theLengthlength of the string to compare with
Returns
true if this string is lexicographically less than the given string

◆ IsLess() [3/4]

template<std::size_t N>
bool TCollection_AsciiString::IsLess ( const char(&) theLiteral[N]) const
inline

Template method for lexicographic comparison with string literals or char arrays.

Parameters
[in]theLiteralthe string literal or char array to compare with
Returns
true if this string is lexicographically less than literal

◆ IsLess() [4/4]

bool TCollection_AsciiString::IsLess ( const TCollection_AsciiString & theOther) const
inline

Returns TRUE if this string is 'ASCII' less than other.

Parameters
[in]theOtherthe ASCII string to compare with
Returns
true if this string is lexicographically less than other

◆ IsRealValue()

bool TCollection_AsciiString::IsRealValue ( bool theToCheckFull = false) const

Returns True if the AsciiString starts with some characters that can be interpreted as integer or real value.

Parameters
[in]theToCheckFullwhen TRUE, checks if entire string defines a real value; otherwise checks if string starts with a real value Note: an integer value is considered to be a real value as well.
Returns
true if string represents a real value

◆ IsSameString() [1/5]

static bool TCollection_AsciiString::IsSameString ( const char *const theCString,
const TCollection_AsciiString & theString2,
const bool theIsCaseSensitive )
inlinestatic

Returns True if the C string and string contain same characters.

Parameters
[in]theCStringfirst C string to compare
[in]theString2second string to compare
[in]theIsCaseSensitiveflag indicating case sensitivity
Returns
true if strings contain same characters

◆ IsSameString() [2/5]

static bool TCollection_AsciiString::IsSameString ( const char *const theCString1,
const char *const theCString2,
const bool theIsCaseSensitive )
inlinestatic

Returns True if the two C strings contain same characters.

Parameters
[in]theCString1first C string to compare
[in]theCString2second C string to compare
[in]theIsCaseSensitiveflag indicating case sensitivity
Returns
true if strings contain same characters

◆ IsSameString() [3/5]

static bool TCollection_AsciiString::IsSameString ( const char *const theString1,
const int theLength1,
const char *const theString2,
const int theLength2,
const bool theIsCaseSensitive )
static

Core implementation: Returns True if the two strings (pointer and length) contain same characters. This is the primary implementation that all other IsSameString overloads redirect to.

Parameters
[in]theString1pointer to first string to compare
[in]theLength1length of first string
[in]theString2pointer to second string to compare
[in]theLength2length of second string
[in]theIsCaseSensitiveflag indicating case sensitivity
Returns
true if strings contain same characters

◆ IsSameString() [4/5]

static bool TCollection_AsciiString::IsSameString ( const TCollection_AsciiString & theString1,
const char *const theCString,
const bool theIsCaseSensitive )
inlinestatic

Returns True if the string and C string contain same characters.

Parameters
[in]theString1first string to compare
[in]theCStringsecond C string to compare
[in]theIsCaseSensitiveflag indicating case sensitivity
Returns
true if strings contain same characters

◆ IsSameString() [5/5]

static bool TCollection_AsciiString::IsSameString ( const TCollection_AsciiString & theString1,
const TCollection_AsciiString & theString2,
const bool theIsCaseSensitive )
inlinestatic

Returns True if the strings contain same characters.

Parameters
[in]theString1first string to compare
[in]theString2second string to compare
[in]theIsCaseSensitiveflag indicating case sensitivity
Returns
true if strings contain same characters

◆ LeftAdjust()

void TCollection_AsciiString::LeftAdjust ( )

Removes all space characters in the beginning of the string.

◆ LeftJustify()

void TCollection_AsciiString::LeftJustify ( const int theWidth,
const char theFiller )

left justify Length becomes equal to Width and the new characters are equal to Filler. If Width < Length nothing happens. Raises an exception if Width is less than zero.

Example:

aString.LeftJustify(9, ' ');
// Result: aString == "abcdef "
Parameters
[in]theWidththe desired width
[in]theFillerthe character to fill with

◆ Length()

int TCollection_AsciiString::Length ( ) const
inline

Returns number of characters in this string. This is the same functionality as 'strlen' in C.

Example:

int aLength = anAlphabet.Length();
// Result: aLength == 6
  • 1 is the position of the first character in this string.
  • The length of this string gives the position of its last character.
  • Positions less than or equal to zero, or greater than the length of this string are invalid in functions which identify a character of this string by its position.
    Returns
    the number of characters in the string

◆ Location() [1/2]

int TCollection_AsciiString::Location ( const int theN,
const char theC,
const int theFromIndex,
const int theToIndex ) const

Returns the index of the nth occurrence of the character C in this string from the starting index FromIndex to the ending index ToIndex. Returns zero if failure. Raises an exception if FromIndex or ToIndex is out of range.

Example:

int anIndex = aString.Location(3, 'a', 1, 5);
// Result: anIndex == 5
Parameters
[in]theNthe occurrence number to find
[in]theCthe character to search for
[in]theFromIndexthe starting index for search
[in]theToIndexthe ending index for search
Returns
the index of the nth occurrence, or 0 if not found

◆ Location() [2/2]

int TCollection_AsciiString::Location ( const TCollection_AsciiString & theOther,
const int theFromIndex,
const int theToIndex ) const

Returns an index in this string of the first occurrence of the string S in this string from the starting index FromIndex to the ending index ToIndex returns zero if failure Raises an exception if FromIndex or ToIndex is out of range.

Example:

int anIndex = aString.Location(aSearchString, 1, 7);
// Result: anIndex == 4
Parameters
[in]theOtherthe string to search for
[in]theFromIndexthe starting index for search
[in]theToIndexthe ending index for search
Returns
the index of first occurrence, or 0 if not found

◆ LowerCase()

void TCollection_AsciiString::LowerCase ( )

Converts this string to its lower-case equivalent.

Example:

aString.UpperCase();
// Result: aString == "HELLO DOLLY"
aString.LowerCase();
// Result: aString == "hello dolly"

◆ Move()

void TCollection_AsciiString::Move ( TCollection_AsciiString && theOther)

Moves string without reallocations.

Parameters
[in]theOtherthe string to move from

◆ operator!=() [1/3]

bool TCollection_AsciiString::operator!= ( const char *const theCString) const
inline

◆ operator!=() [2/3]

template<std::size_t N>
bool TCollection_AsciiString::operator!= ( const char(&) theLiteral[N]) const
inline

◆ operator!=() [3/3]

bool TCollection_AsciiString::operator!= ( const TCollection_AsciiString & theOther) const
inline

◆ operator+() [1/8]

TCollection_AsciiString TCollection_AsciiString::operator+ ( const char *const theCString) const
inline

◆ operator+() [2/8]

TCollection_AsciiString TCollection_AsciiString::operator+ ( const char theOther) const
inline

◆ operator+() [3/8]

template<std::size_t N>
TCollection_AsciiString TCollection_AsciiString::operator+ ( const char(&) theLiteral[N]) const
inline

◆ operator+() [4/8]

TCollection_AsciiString TCollection_AsciiString::operator+ ( const double theOther) const
inline

◆ operator+() [5/8]

TCollection_AsciiString TCollection_AsciiString::operator+ ( const int theOther) const
inline

◆ operator+() [6/8]

TCollection_AsciiString TCollection_AsciiString::operator+ ( const TCollection_AsciiString & theOther) const
inline

◆ operator+() [7/8]

TCollection_AsciiString TCollection_AsciiString::operator+ ( const TCollection_ExtendedString & theOther) const
inline

◆ operator+() [8/8]

TCollection_AsciiString TCollection_AsciiString::operator+ ( const wchar_t * theStringUtf) const
inline

◆ operator+=() [1/8]

void TCollection_AsciiString::operator+= ( const char *const theCString)
inline

◆ operator+=() [2/8]

void TCollection_AsciiString::operator+= ( const char theOther)
inline

◆ operator+=() [3/8]

template<std::size_t N>
void TCollection_AsciiString::operator+= ( const char(&) theLiteral[N])
inline

◆ operator+=() [4/8]

void TCollection_AsciiString::operator+= ( const double theOther)
inline

◆ operator+=() [5/8]

void TCollection_AsciiString::operator+= ( const int theOther)
inline

◆ operator+=() [6/8]

void TCollection_AsciiString::operator+= ( const TCollection_AsciiString & theOther)
inline

◆ operator+=() [7/8]

void TCollection_AsciiString::operator+= ( const TCollection_ExtendedString & theOther)
inline

◆ operator+=() [8/8]

void TCollection_AsciiString::operator+= ( const wchar_t * theStringUtf)
inline

◆ operator<() [1/3]

bool TCollection_AsciiString::operator< ( const char *const theCString) const
inline

◆ operator<() [2/3]

template<std::size_t N>
bool TCollection_AsciiString::operator< ( const char(&) theLiteral[N]) const
inline

◆ operator<() [3/3]

bool TCollection_AsciiString::operator< ( const TCollection_AsciiString & theOther) const
inline

◆ operator=() [1/4]

void TCollection_AsciiString::operator= ( const char *const theCString)
inline

◆ operator=() [2/4]

template<std::size_t N>
void TCollection_AsciiString::operator= ( const char(&) theLiteral[N])
inline

◆ operator=() [3/4]

TCollection_AsciiString & TCollection_AsciiString::operator= ( const TCollection_AsciiString & theOther)
inline

Copy assignment operator.

◆ operator=() [4/4]

TCollection_AsciiString & TCollection_AsciiString::operator= ( TCollection_AsciiString && theOther)
inlinenoexcept

Move assignment operator.

◆ operator==() [1/3]

bool TCollection_AsciiString::operator== ( const char *const theCString) const
inline

◆ operator==() [2/3]

template<std::size_t N>
bool TCollection_AsciiString::operator== ( const char(&) theLiteral[N]) const
inline

◆ operator==() [3/3]

bool TCollection_AsciiString::operator== ( const TCollection_AsciiString & theOther) const
inline

◆ operator>() [1/3]

bool TCollection_AsciiString::operator> ( const char *const theCString) const
inline

◆ operator>() [2/3]

template<std::size_t N>
bool TCollection_AsciiString::operator> ( const char(&) theLiteral[N]) const
inline

◆ operator>() [3/3]

bool TCollection_AsciiString::operator> ( const TCollection_AsciiString & theOther) const
inline

◆ Prepend()

void TCollection_AsciiString::Prepend ( const TCollection_AsciiString & theOther)

Inserts the string other at the beginning of this ASCII string.

Example:

anAlphabet.Prepend(aBegin);
// Result: anAlphabet == "abcde"
Parameters
[in]theOtherthe string to prepend

◆ Print()

void TCollection_AsciiString::Print ( Standard_OStream & theStream) const

Displays this string on a stream.

Parameters
[in]theStreamthe output stream

◆ Read()

void TCollection_AsciiString::Read ( Standard_IStream & theStream)

Read this string from a stream.

Parameters
[in]theStreamthe input stream

◆ RealValue()

double TCollection_AsciiString::RealValue ( ) const

Converts an AsciiString containing a numeric expression to a Real.

Example:

double aReal1 = aString1.RealValue();
// Result: aReal1 == 215.0
double aReal2 = aString2.RealValue();
// Result: aReal2 == 3.14159267
Returns
the real value of the string

◆ Remove()

void TCollection_AsciiString::Remove ( const int theWhere,
const int theHowMany = 1 )

Erases ahowmany characters from position where, where included.

Example:

aString.Remove(2, 2); // erases 2 characters from position 2
// Result: aString == "Hlo"
Parameters
[in]theWherethe position to start erasing from
[in]theHowManythe number of characters to erase

◆ RemoveAll() [1/2]

void TCollection_AsciiString::RemoveAll ( const char theC,
const bool theCaseSensitive )

Remove all the occurrences of the character C in the string.

Example:

aString.RemoveAll('L', true);
// Result: aString == "Hello"
Parameters
[in]theCthe character to remove
[in]theCaseSensitiveflag indicating case sensitivity

◆ RemoveAll() [2/2]

void TCollection_AsciiString::RemoveAll ( const char theWhat)

Removes every what characters from this string.

Parameters
[in]theWhatthe character to remove

◆ RightAdjust()

void TCollection_AsciiString::RightAdjust ( )

Removes all space characters at the end of the string.

◆ RightJustify()

void TCollection_AsciiString::RightJustify ( const int theWidth,
const char theFiller )

Right justify. Length becomes equal to Width and the new characters are equal to Filler. if Width < Length nothing happens. Raises an exception if Width is less than zero.

Example:

aString.RightJustify(9, ' ');
// Result: aString == " abcdef"
Parameters
[in]theWidththe desired width
[in]theFillerthe character to fill with

◆ Search() [1/4]

int TCollection_AsciiString::Search ( const char *const theCString) const
inline

Searches a C string in this string from the beginning.

Parameters
[in]theCStringthe C string to search for
Returns
the position of first match, or -1 if not found

◆ Search() [2/4]

int TCollection_AsciiString::Search ( const char *const theWhat,
const int theWhatLength ) const

Core implementation: Searches a string (pointer and length) in this string from the beginning and returns position of first item matching. It returns -1 if not found.

Parameters
[in]theWhatpointer to the string to search for
[in]theWhatLengthlength of the string to search for
Returns
the position of first match, or -1 if not found

◆ Search() [3/4]

template<std::size_t N>
int TCollection_AsciiString::Search ( const char(&) theLiteral[N]) const
inline

Template method for searching string literals or char arrays.

Parameters
[in]theLiteralthe string literal or char array to search for
Returns
the position of first match, or -1 if not found

◆ Search() [4/4]

int TCollection_AsciiString::Search ( const TCollection_AsciiString & theWhat) const
inline

Searches an AsciiString in this string from the beginning and returns position of first item what matching. It returns -1 if not found.

Parameters
[in]theWhatthe ASCII string to search for
Returns
the position of first match, or -1 if not found

◆ SearchFromEnd() [1/4]

int TCollection_AsciiString::SearchFromEnd ( const char *const theCString) const
inline

Searches a C string in this string from the end.

Parameters
[in]theCStringthe C string to search for
Returns
the position of first match from end, or -1 if not found

◆ SearchFromEnd() [2/4]

int TCollection_AsciiString::SearchFromEnd ( const char *const theWhat,
const int theWhatLength ) const

Core implementation: Searches a string (pointer and length) in this string from the end and returns position of first item matching. It returns -1 if not found.

Parameters
[in]theWhatpointer to the string to search for
[in]theWhatLengthlength of the string to search for
Returns
the position of first match from end, or -1 if not found

◆ SearchFromEnd() [3/4]

template<std::size_t N>
int TCollection_AsciiString::SearchFromEnd ( const char(&) theLiteral[N]) const
inline

Template method for searching string literals or char arrays from end.

Parameters
[in]theLiteralthe string literal or char array to search for
Returns
the position of first match from end, or -1 if not found

◆ SearchFromEnd() [4/4]

int TCollection_AsciiString::SearchFromEnd ( const TCollection_AsciiString & theWhat) const
inline

Searches a AsciiString in another AsciiString from the end and returns position of first item what matching. It returns -1 if not found.

Parameters
[in]theWhatthe ASCII string to search for
Returns
the position of first match from end, or -1 if not found

◆ SetValue() [1/4]

void TCollection_AsciiString::SetValue ( const int theWhere,
const char *const theCString )
inline

Replaces a part of this ASCII string with a C string.

Parameters
[in]theWhereposition to start replacement
[in]theCStringthe C string to replace with

◆ SetValue() [2/4]

void TCollection_AsciiString::SetValue ( const int theWhere,
const char *const theString,
const int theLength )

Core implementation: Replaces a part of this string with a string (pointer and length). This is the primary implementation that all other SetValue string overloads redirect to.

Parameters
[in]theWhereposition to start replacement
[in]theStringpointer to the string to replace with
[in]theLengthlength of the string to replace with

◆ SetValue() [3/4]

void TCollection_AsciiString::SetValue ( const int theWhere,
const char theWhat )

Replaces one character in the AsciiString at position where. If where is less than zero or greater than the length of this string an exception is raised.

Example:

aString.SetValue(6, 'g');
// Result: aString == "Garbage"
Parameters
[in]theWherethe position to replace at
[in]theWhatthe character to replace with

◆ SetValue() [4/4]

void TCollection_AsciiString::SetValue ( const int theWhere,
const TCollection_AsciiString & theWhat )
inline

Replaces a part of this string by another AsciiString.

Parameters
[in]theWherethe position to start replacement
[in]theWhatthe ASCII string to replace with

◆ Split()

TCollection_AsciiString TCollection_AsciiString::Split ( const int theWhere)

Splits a AsciiString into two sub-strings.

Example:

// Result: aString == "abc" and aSecondPart == "defg"
Parameters
[in]theWherethe position to split at
Returns
the second part of the split string

◆ StartsWith() [1/4]

bool TCollection_AsciiString::StartsWith ( const char *const theCString) const
inline

Determines whether the beginning of this string matches the specified C string.

Parameters
[in]theCStringthe C string to check for at the beginning
Returns
true if this string starts with theCString

◆ StartsWith() [2/4]

bool TCollection_AsciiString::StartsWith ( const char *const theStartString,
const int theStartLength ) const

Core implementation: Determines whether the beginning of this string instance matches the specified string (pointer and length).

Parameters
[in]theStartStringpointer to the string to check for at the beginning
[in]theStartLengthlength of the string to check for
Returns
true if this string starts with theStartString

◆ StartsWith() [3/4]

template<std::size_t N>
bool TCollection_AsciiString::StartsWith ( const char(&) theLiteral[N]) const
inline

Template method for checking if string starts with a literal or char array.

Parameters
[in]theLiteralthe string literal or char array to check for at the beginning
Returns
true if this string starts with literal

◆ StartsWith() [4/4]

bool TCollection_AsciiString::StartsWith ( const TCollection_AsciiString & theStartString) const
inline

Determines whether the beginning of this string instance matches the specified string.

Parameters
[in]theStartStringthe string to check for at the beginning
Returns
true if this string starts with theStartString

◆ SubString()

TCollection_AsciiString TCollection_AsciiString::SubString ( const int theFromIndex,
const int theToIndex ) const

Creation of a sub-string of this string. The sub-string starts to the index Fromindex and ends to the index ToIndex. Raises an exception if ToIndex or FromIndex is out of bounds.

Example:

// Result: aSubString == "cdef"
Parameters
[in]theFromIndexthe starting index
[in]theToIndexthe ending index
Returns
the substring from FromIndex to ToIndex

◆ Swap()

void TCollection_AsciiString::Swap ( TCollection_AsciiString & theOther)

Exchange the data of two strings (without reallocating memory).

Parameters
[in,out]theOtherthe string to exchange data with

◆ ToCString()

const char * TCollection_AsciiString::ToCString ( ) const
inline

Returns pointer to AsciiString (char *). This is useful for some casual manipulations. Warning: Because this "char *" is 'const', you can't modify its contents.

Returns
the C string representation

◆ Token()

TCollection_AsciiString TCollection_AsciiString::Token ( const char *const theSeparators = " \t",
const int theWhichOne = 1 ) const

Extracts whichone token from this string. By default, the separators is set to space and tabulation. By default, the token extracted is the first one (whichone = 1). separators contains all separators you need. If no token indexed by whichone is found, it returns empty AsciiString.

Example:

TCollection_AsciiString aString("This is a message");
// Result: aToken1 == "This"
// Result: aToken2 == "message"
// Result: aToken3 == "is"
// Result: aToken4 == ""
TCollection_AsciiString bString("1234; test:message , value");
// Result: bToken1 == "value"
// Result: bToken2 == "test"
Parameters
[in]theSeparatorsthe separator characters
[in]theWhichOnethe token number to extract

◆ Trunc()

void TCollection_AsciiString::Trunc ( const int theHowMany)

Truncates this string to ahowmany characters.

Example:

aString.Trunc(3);
// Result: aString == "Hel"
Parameters
[in]theHowManythe number of characters to keep

◆ UpperCase()

void TCollection_AsciiString::UpperCase ( )

Converts this string to its upper-case equivalent.

◆ UsefullLength()

int TCollection_AsciiString::UsefullLength ( ) const

Length of the string ignoring all spaces (' ') and the control character at the end.

Returns
the useful length of the string

◆ Value()

char TCollection_AsciiString::Value ( const int theWhere) const

Returns character at position where in this string. If where is less than zero or greater than the length of this string, an exception is raised.

Example:

char aChar = aString.Value(2);
// Result: aChar == 'e'
Parameters
[in]theWherethe position to get character from
Returns
the character at the specified position

The documentation for this class was generated from the following file: