Open CASCADE Technology  7.4.0
Public Member Functions | Static Public Member Functions | Friends

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 ()
 Initializes a AsciiString to an empty AsciiString. More...
 
 TCollection_AsciiString (const Standard_CString message)
 Initializes a AsciiString with a CString. More...
 
 TCollection_AsciiString (const Standard_CString message, const Standard_Integer aLen)
 Initializes a AsciiString with a CString. More...
 
 TCollection_AsciiString (const Standard_Character aChar)
 Initializes a AsciiString with a single character. More...
 
 TCollection_AsciiString (const Standard_Integer length, const Standard_Character filler)
 Initializes an AsciiString with <length> space allocated. and filled with <filler>. This is usefull for buffers. More...
 
 TCollection_AsciiString (const Standard_Integer value)
 Initializes an AsciiString with an integer value. More...
 
 TCollection_AsciiString (const Standard_Real value)
 Initializes an AsciiString with a real value. More...
 
 TCollection_AsciiString (const TCollection_AsciiString &astring)
 Initializes a AsciiString with another AsciiString. More...
 
 TCollection_AsciiString (TCollection_AsciiString &&theOther)
 Move constructor. More...
 
 TCollection_AsciiString (const TCollection_AsciiString &astring, const Standard_Character message)
 Initializes a AsciiString with copy of another AsciiString concatenated with the message character. More...
 
 TCollection_AsciiString (const TCollection_AsciiString &astring, const Standard_CString message)
 Initializes a AsciiString with copy of another AsciiString concatenated with the message string. More...
 
 TCollection_AsciiString (const TCollection_AsciiString &astring, const TCollection_AsciiString &message)
 Initializes a AsciiString with copy of another AsciiString concatenated with the message string. More...
 
 TCollection_AsciiString (const TCollection_ExtendedString &astring, const Standard_Character replaceNonAscii=0)
 Creation by converting an extended string to an ascii string. If replaceNonAscii is non-null charecter, it will be used in place of any non-ascii character found in the source string. Otherwise, creates UTF-8 unicode string. More...
 
 TCollection_AsciiString (const Standard_WideChar *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). More...
 
void AssignCat (const Standard_Character other)
 Appends <other> to me. This is an unary operator. More...
 
void operator+= (const Standard_Character other)
 
void AssignCat (const Standard_Integer other)
 Appends <other> to me. This is an unary operator. More...
 
void operator+= (const Standard_Integer other)
 
void AssignCat (const Standard_Real other)
 Appends <other> to me. This is an unary operator. More...
 
void operator+= (const Standard_Real other)
 
void AssignCat (const Standard_CString other)
 Appends <other> to me. This is an unary operator. ex: aString += "Dummy" To catenate more than one CString, you must put a AsciiString before. Example: aString += "Hello " + "Dolly" IS NOT VALID ! But astring += anotherString + "Hello " + "Dolly" is valid. More...
 
void operator+= (const Standard_CString other)
 
void AssignCat (const TCollection_AsciiString &other)
 Appends <other> to me. This is an unary operator. Example: aString += anotherString. More...
 
void operator+= (const TCollection_AsciiString &other)
 
void Capitalize ()
 Converts the first character into its corresponding upper-case character and the other characters into lowercase Example: before me = "hellO " after me = "Hello ". More...
 
TCollection_AsciiString Cat (const Standard_Character other) const
 Appends <other> to me. Syntax: aString = aString + "Dummy" Example: aString contains "I say " aString = aString + "Hello " + "Dolly" gives "I say Hello Dolly" To catenate more than one CString, you must put a String before. So the following example is WRONG ! aString = "Hello " + "Dolly" THIS IS NOT ALLOWED This rule is applicable to AssignCat (operator +=) too. More...
 
TCollection_AsciiString operator+ (const Standard_Character other) const
 
TCollection_AsciiString Cat (const Standard_Integer other) const
 Appends <other> to me. Syntax: aString = aString + 15; Example: aString contains "I say " gives "I say 15" To catenate more than one CString, you must put a String before. So the following example is WRONG ! aString = "Hello " + "Dolly" THIS IS NOT ALLOWED This rule is applicable to AssignCat (operator +=) too. More...
 
TCollection_AsciiString operator+ (const Standard_Integer other) const
 
TCollection_AsciiString Cat (const Standard_Real other) const
 Appends <other> to me. Syntax: aString = aString + 15.15; Example: aString contains "I say " gives "I say 15.15" To catenate more than one CString, you must put a String before. So the following example is WRONG ! aString = "Hello " + "Dolly" THIS IS NOT ALLOWED This rule is applicable to AssignCat (operator +=) too. More...
 
TCollection_AsciiString operator+ (const Standard_Real other) const
 
TCollection_AsciiString Cat (const Standard_CString other) const
 Appends <other> to me. Syntax: aString = aString + "Dummy" Example: aString contains "I say " aString = aString + "Hello " + "Dolly" gives "I say Hello Dolly" To catenate more than one CString, you must put a String before. So the following example is WRONG ! aString = "Hello " + "Dolly" THIS IS NOT ALLOWED This rule is applicable to AssignCat (operator +=) too. More...
 
TCollection_AsciiString operator+ (const Standard_CString other) const
 
TCollection_AsciiString Cat (const TCollection_AsciiString &other) const
 Appends <other> to me. Example: aString = aString + anotherString. More...
 
TCollection_AsciiString operator+ (const TCollection_AsciiString &other) const
 
void Center (const Standard_Integer Width, const Standard_Character Filler)
 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 TCollection_AsciiString myAlphabet("abcdef"); myAlphabet.Center(9,' '); assert ( myAlphabet == " abcdef " );. More...
 
void ChangeAll (const Standard_Character aChar, const Standard_Character NewChar, const Standard_Boolean CaseSensitive=Standard_True)
 Substitutes all the characters equal to aChar by NewChar in the AsciiString <me>. The substitution can be case sensitive. If you don't use default case sensitive, no matter wether aChar is uppercase or not. Example: me = "Histake" -> ChangeAll('H','M',Standard_True) gives me = "Mistake". More...
 
void Clear ()
 Removes all characters contained in <me>. This produces an empty AsciiString. More...
 
void Copy (const Standard_CString fromwhere)
 Copy <fromwhere> to <me>. Used as operator = Example: aString = anotherCString;. More...
 
void operator= (const Standard_CString fromwhere)
 
void Copy (const TCollection_AsciiString &fromwhere)
 Copy <fromwhere> to <me>. Used as operator = Example: aString = anotherString;. More...
 
void operator= (const TCollection_AsciiString &fromwhere)
 
void Swap (TCollection_AsciiString &theOther)
 Exchange the data of two strings (without reallocating memory). More...
 
TCollection_AsciiStringoperator= (TCollection_AsciiString &&theOther)
 Move assignment operator. More...
 
 ~TCollection_AsciiString ()
 Frees memory allocated by AsciiString. More...
 
Standard_Integer FirstLocationInSet (const TCollection_AsciiString &Set, const Standard_Integer FromIndex, const Standard_Integer ToIndex) const
 Returns the index of the first character of <me> 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: before me = "aabAcAa", S = "Aa", FromIndex = 1, Toindex = 7 after me = "aabAcAa" returns 1. More...
 
Standard_Integer FirstLocationNotInSet (const TCollection_AsciiString &Set, const Standard_Integer FromIndex, const Standard_Integer ToIndex) const
 Returns the index of the first character of <me> that is not present in the set <Set>. The search begins to the index FromIndex and ends to the the index ToIndex in <me>. Returns zero if failure. Raises an exception if FromIndex or ToIndex is out of range. Example: before me = "aabAcAa", S = "Aa", FromIndex = 1, Toindex = 7 after me = "aabAcAa" returns 3. More...
 
void Insert (const Standard_Integer where, const Standard_Character what)
 Inserts a Character at position <where>. Example: aString contains "hy not ?" aString.Insert(1,'W'); gives "Why not ?" aString contains "Wh" aString.Insert(3,'y'); gives "Why" aString contains "Way" aString.Insert(2,'h'); gives "Why". More...
 
void Insert (const Standard_Integer where, const Standard_CString what)
 Inserts a CString at position <where>. Example: aString contains "O more" aString.Insert(2,"nce"); gives "Once more". More...
 
void Insert (const Standard_Integer where, const TCollection_AsciiString &what)
 Inserts a AsciiString at position <where>. More...
 
void InsertAfter (const Standard_Integer Index, const TCollection_AsciiString &other)
 Pushing a string after a specific index in the string <me>. Raises an exception if Index is out of bounds. More...
 
void InsertBefore (const Standard_Integer Index, const TCollection_AsciiString &other)
 Pushing a string before a specific index in the string <me>. Raises an exception if Index is out of bounds. More...
 
Standard_Boolean IsEmpty () const
 Returns True if the string <me> contains zero character. More...
 
Standard_Boolean IsEqual (const Standard_CString other) 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 ==. More...
 
Standard_Boolean operator== (const Standard_CString other) const
 
Standard_Boolean IsEqual (const TCollection_AsciiString &other) 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 ==. More...
 
Standard_Boolean operator== (const TCollection_AsciiString &other) const
 
Standard_Boolean IsDifferent (const Standard_CString other) 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 !=. More...
 
Standard_Boolean operator!= (const Standard_CString other) const
 
Standard_Boolean IsDifferent (const TCollection_AsciiString &other) 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 !=. More...
 
Standard_Boolean operator!= (const TCollection_AsciiString &other) const
 
Standard_Boolean IsLess (const Standard_CString other) const
 Returns TRUE if <me> is 'ASCII' less than <other>. More...
 
Standard_Boolean operator< (const Standard_CString other) const
 
Standard_Boolean IsLess (const TCollection_AsciiString &other) const
 Returns TRUE if <me> is 'ASCII' less than <other>. More...
 
Standard_Boolean operator< (const TCollection_AsciiString &other) const
 
Standard_Boolean IsGreater (const Standard_CString other) const
 Returns TRUE if <me> is 'ASCII' greater than <other>. More...
 
Standard_Boolean operator> (const Standard_CString other) const
 
Standard_Boolean IsGreater (const TCollection_AsciiString &other) const
 Returns TRUE if <me> is 'ASCII' greater than <other>. More...
 
Standard_Boolean operator> (const TCollection_AsciiString &other) const
 
Standard_Boolean StartsWith (const TCollection_AsciiString &theStartString) const
 Determines whether the beginning of this string instance matches the specified string. More...
 
Standard_Boolean EndsWith (const TCollection_AsciiString &theEndString) const
 Determines whether the end of this string instance matches the specified string. More...
 
Standard_Integer IntegerValue () const
 Converts a AsciiString containing a numeric expression to an Integer. Example: "215" returns 215. More...
 
Standard_Boolean IsIntegerValue () const
 Returns True if the AsciiString contains an integer value. Note: an integer value is considered to be a real value as well. More...
 
Standard_Boolean IsRealValue () const
 Returns True if the AsciiString contains a real value. Note: an integer value is considered to be a real value as well. More...
 
Standard_Boolean IsAscii () const
 Returns True if the AsciiString contains only ASCII characters between ' ' and '~'. This means no control character and no extended ASCII code. More...
 
void LeftAdjust ()
 Removes all space characters in the begining of the string. More...
 
void LeftJustify (const Standard_Integer Width, const Standard_Character Filler)
 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: before me = "abcdef" , Width = 9 , Filler = ' ' after me = "abcdef " More...
 
Standard_Integer Length () const
 Returns number of characters in <me>. This is the same functionality as 'strlen' in C. Example TCollection_AsciiString myAlphabet("abcdef"); assert ( myAlphabet.Length() == 6 );. More...
 
Standard_Integer Location (const TCollection_AsciiString &other, const Standard_Integer FromIndex, const Standard_Integer ToIndex) const
 Returns an index in the string <me> of the first occurence of the string S in the string <me> 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: before me = "aabAaAa", S = "Aa", FromIndex = 1, ToIndex = 7 after me = "aabAaAa" returns 4. More...
 
Standard_Integer Location (const Standard_Integer N, const Standard_Character C, const Standard_Integer FromIndex, const Standard_Integer ToIndex) const
 Returns the index of the nth occurence of the character C in the string <me> 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: before me = "aabAa", N = 3, C = 'a', FromIndex = 1, ToIndex = 5 after me = "aabAa" returns 5. More...
 
void LowerCase ()
 Converts <me> to its lower-case equivalent. Example TCollection_AsciiString myString("Hello Dolly"); myString.UpperCase(); assert ( myString == "HELLO DOLLY" ); myString.LowerCase(); assert ( myString == "hello dolly" );. More...
 
void Prepend (const TCollection_AsciiString &other)
 Inserts the string other at the beginning of this ASCII string. Example TCollection_AsciiString myAlphabet("cde"); TCollection_AsciiString myBegin("ab"); myAlphabet.Prepend(myBegin); assert ( myAlphabet == "abcde" );. More...
 
void Print (Standard_OStream &astream) const
 Displays <me> on a stream. More...
 
void Read (Standard_IStream &astream)
 Read <me> from a stream. More...
 
Standard_Real RealValue () const
 Converts an AsciiString containing a numeric expression. to a Real. Example: ex: "215" returns 215.0. ex: "3.14159267" returns 3.14159267. More...
 
void RemoveAll (const Standard_Character C, const Standard_Boolean CaseSensitive)
 Remove all the occurences of the character C in the string. Example: before me = "HellLLo", C = 'L' , CaseSensitive = True after me = "Hello". More...
 
void RemoveAll (const Standard_Character what)
 Removes every <what> characters from <me>. More...
 
void Remove (const Standard_Integer where, const Standard_Integer ahowmany=1)
 Erases <ahowmany> characters from position <where>, <where> included. Example: aString contains "Hello" aString.Remove(2,2) erases 2 characters from position 2 This gives "Hlo". More...
 
void RightAdjust ()
 Removes all space characters at the end of the string. More...
 
void RightJustify (const Standard_Integer Width, const Standard_Character Filler)
 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: before me = "abcdef" , Width = 9 , Filler = ' ' after me = " abcdef". More...
 
Standard_Integer Search (const Standard_CString what) const
 Searches a CString in <me> from the beginning and returns position of first item <what> matching. it returns -1 if not found. Example: aString contains "Sample single test" aString.Search("le") returns 5. More...
 
Standard_Integer Search (const TCollection_AsciiString &what) const
 Searches an AsciiString in <me> from the beginning and returns position of first item <what> matching. It returns -1 if not found. More...
 
Standard_Integer SearchFromEnd (const Standard_CString what) const
 Searches a CString in a AsciiString from the end and returns position of first item <what> matching. It returns -1 if not found. Example: aString contains "Sample single test" aString.SearchFromEnd("le") returns 12. More...
 
Standard_Integer SearchFromEnd (const TCollection_AsciiString &what) const
 Searches a AsciiString in another AsciiString from the end and returns position of first item <what> matching. It returns -1 if not found. More...
 
void SetValue (const Standard_Integer where, const Standard_Character what)
 Replaces one character in the AsciiString at position <where>. If <where> is less than zero or greater than the length of <me> an exception is raised. Example: aString contains "Garbake" astring.Replace(6,'g') gives <me> = "Garbage". More...
 
void SetValue (const Standard_Integer where, const Standard_CString what)
 Replaces a part of <me> by a CString. If <where> is less than zero or greater than the length of <me> an exception is raised. Example: aString contains "abcde" aString.SetValue(4,"1234567") gives <me> = "abc1234567". More...
 
void SetValue (const Standard_Integer where, const TCollection_AsciiString &what)
 Replaces a part of <me> by another AsciiString. More...
 
TCollection_AsciiString Split (const Standard_Integer where)
 Splits a AsciiString into two sub-strings. Example: aString contains "abcdefg" aString.Split(3) gives <me> = "abc" and returns "defg". More...
 
TCollection_AsciiString SubString (const Standard_Integer FromIndex, const Standard_Integer ToIndex) const
 Creation of a sub-string of the string <me>. 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: before me = "abcdefg", ToIndex=3, FromIndex=6 after me = "abcdefg" returns "cdef". More...
 
Standard_CString ToCString () 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. More...
 
TCollection_AsciiString Token (const Standard_CString separators=" \, const Standard_Integer whichone=1) const
 Extracts <whichone> token from <me>. 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: aString contains "This is a message" aString.Token() returns "This" aString.Token(" ",4) returns "message" aString.Token(" ",2) returns "is" aString.Token(" ",9) returns "" Other separators than space character and tabulation are allowed : aString contains "1234; test:message , value" aString.Token("; :,",4) returns "value" aString.Token("; :,",2) returns "test". More...
 
void Trunc (const Standard_Integer ahowmany)
 Truncates <me> to <ahowmany> characters. Example: me = "Hello Dolly" -> Trunc(3) -> me = "Hel". More...
 
void UpperCase ()
 Converts <me> to its upper-case equivalent. More...
 
Standard_Integer UsefullLength () const
 Length of the string ignoring all spaces (' ') and the control character at the end. More...
 
Standard_Character Value (const Standard_Integer where) const
 Returns character at position <where> in <me>. If <where> is less than zero or greater than the lenght of <me>, an exception is raised. Example: aString contains "Hello" aString.Value(2) returns 'e'. More...
 

Static Public Member Functions

static Standard_Integer HashCode (const TCollection_AsciiString &theAsciiString, Standard_Integer theUpperBound)
 Computes a hash code for the given ASCII string, in the range [1, theUpperBound]. Returns the same integer value as the hash function for TCollection_ExtendedString. More...
 
static Standard_Boolean IsEqual (const TCollection_AsciiString &string1, const TCollection_AsciiString &string2)
 Returns True when the two strings are the same. (Just for HashCode for AsciiString) More...
 
static Standard_Boolean IsEqual (const TCollection_AsciiString &string1, const Standard_CString string2)
 Returns True when the two strings are the same. (Just for HashCode for AsciiString) More...
 
static Standard_Boolean IsSameString (const TCollection_AsciiString &theString1, const TCollection_AsciiString &theString2, const Standard_Boolean theIsCaseSensitive)
 Returns True if the strings contain same characters. More...
 

Friends

Standard_OStreamoperator<< (Standard_OStream &astream, const TCollection_AsciiString &astring)
 
Standard_IStreamoperator>> (Standard_IStream &astream, TCollection_AsciiString &astring)
 

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/14]

TCollection_AsciiString::TCollection_AsciiString ( )

Initializes a AsciiString to an empty AsciiString.

◆ TCollection_AsciiString() [2/14]

TCollection_AsciiString::TCollection_AsciiString ( const Standard_CString  message)

Initializes a AsciiString with a CString.

◆ TCollection_AsciiString() [3/14]

TCollection_AsciiString::TCollection_AsciiString ( const Standard_CString  message,
const Standard_Integer  aLen 
)

Initializes a AsciiString with a CString.

◆ TCollection_AsciiString() [4/14]

TCollection_AsciiString::TCollection_AsciiString ( const Standard_Character  aChar)

Initializes a AsciiString with a single character.

◆ TCollection_AsciiString() [5/14]

TCollection_AsciiString::TCollection_AsciiString ( const Standard_Integer  length,
const Standard_Character  filler 
)

Initializes an AsciiString with <length> space allocated. and filled with <filler>. This is usefull for buffers.

◆ TCollection_AsciiString() [6/14]

TCollection_AsciiString::TCollection_AsciiString ( const Standard_Integer  value)

Initializes an AsciiString with an integer value.

◆ TCollection_AsciiString() [7/14]

TCollection_AsciiString::TCollection_AsciiString ( const Standard_Real  value)

Initializes an AsciiString with a real value.

◆ TCollection_AsciiString() [8/14]

TCollection_AsciiString::TCollection_AsciiString ( const TCollection_AsciiString astring)

Initializes a AsciiString with another AsciiString.

◆ TCollection_AsciiString() [9/14]

TCollection_AsciiString::TCollection_AsciiString ( TCollection_AsciiString &&  theOther)
inline

Move constructor.

◆ TCollection_AsciiString() [10/14]

TCollection_AsciiString::TCollection_AsciiString ( const TCollection_AsciiString astring,
const Standard_Character  message 
)

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

◆ TCollection_AsciiString() [11/14]

TCollection_AsciiString::TCollection_AsciiString ( const TCollection_AsciiString astring,
const Standard_CString  message 
)

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

◆ TCollection_AsciiString() [12/14]

TCollection_AsciiString::TCollection_AsciiString ( const TCollection_AsciiString astring,
const TCollection_AsciiString message 
)

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

◆ TCollection_AsciiString() [13/14]

TCollection_AsciiString::TCollection_AsciiString ( const TCollection_ExtendedString astring,
const Standard_Character  replaceNonAscii = 0 
)

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

◆ TCollection_AsciiString() [14/14]

TCollection_AsciiString::TCollection_AsciiString ( const Standard_WideChar 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.

◆ ~TCollection_AsciiString()

TCollection_AsciiString::~TCollection_AsciiString ( )

Frees memory allocated by AsciiString.

Member Function Documentation

◆ AssignCat() [1/5]

void TCollection_AsciiString::AssignCat ( const Standard_Character  other)

Appends <other> to me. This is an unary operator.

◆ AssignCat() [2/5]

void TCollection_AsciiString::AssignCat ( const Standard_Integer  other)

Appends <other> to me. This is an unary operator.

◆ AssignCat() [3/5]

void TCollection_AsciiString::AssignCat ( const Standard_Real  other)

Appends <other> to me. This is an unary operator.

◆ AssignCat() [4/5]

void TCollection_AsciiString::AssignCat ( const Standard_CString  other)

Appends <other> to me. This is an unary operator. ex: aString += "Dummy" To catenate more than one CString, you must put a AsciiString before. Example: aString += "Hello " + "Dolly" IS NOT VALID ! But astring += anotherString + "Hello " + "Dolly" is valid.

◆ AssignCat() [5/5]

void TCollection_AsciiString::AssignCat ( const TCollection_AsciiString other)

Appends <other> to me. This is an unary operator. Example: aString += anotherString.

◆ Capitalize()

void TCollection_AsciiString::Capitalize ( )

Converts the first character into its corresponding upper-case character and the other characters into lowercase Example: before me = "hellO " after me = "Hello ".

◆ Cat() [1/5]

TCollection_AsciiString TCollection_AsciiString::Cat ( const Standard_Character  other) const

Appends <other> to me. Syntax: aString = aString + "Dummy" Example: aString contains "I say " aString = aString + "Hello " + "Dolly" gives "I say Hello Dolly" To catenate more than one CString, you must put a String before. So the following example is WRONG ! aString = "Hello " + "Dolly" THIS IS NOT ALLOWED This rule is applicable to AssignCat (operator +=) too.

◆ Cat() [2/5]

TCollection_AsciiString TCollection_AsciiString::Cat ( const Standard_Integer  other) const

Appends <other> to me. Syntax: aString = aString + 15; Example: aString contains "I say " gives "I say 15" To catenate more than one CString, you must put a String before. So the following example is WRONG ! aString = "Hello " + "Dolly" THIS IS NOT ALLOWED This rule is applicable to AssignCat (operator +=) too.

◆ Cat() [3/5]

TCollection_AsciiString TCollection_AsciiString::Cat ( const Standard_Real  other) const

Appends <other> to me. Syntax: aString = aString + 15.15; Example: aString contains "I say " gives "I say 15.15" To catenate more than one CString, you must put a String before. So the following example is WRONG ! aString = "Hello " + "Dolly" THIS IS NOT ALLOWED This rule is applicable to AssignCat (operator +=) too.

◆ Cat() [4/5]

TCollection_AsciiString TCollection_AsciiString::Cat ( const Standard_CString  other) const

Appends <other> to me. Syntax: aString = aString + "Dummy" Example: aString contains "I say " aString = aString + "Hello " + "Dolly" gives "I say Hello Dolly" To catenate more than one CString, you must put a String before. So the following example is WRONG ! aString = "Hello " + "Dolly" THIS IS NOT ALLOWED This rule is applicable to AssignCat (operator +=) too.

◆ Cat() [5/5]

TCollection_AsciiString TCollection_AsciiString::Cat ( const TCollection_AsciiString other) const

Appends <other> to me. Example: aString = aString + anotherString.

◆ Center()

void TCollection_AsciiString::Center ( const Standard_Integer  Width,
const Standard_Character  Filler 
)

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 TCollection_AsciiString myAlphabet("abcdef"); myAlphabet.Center(9,' '); assert ( myAlphabet == " abcdef " );.

◆ ChangeAll()

void TCollection_AsciiString::ChangeAll ( const Standard_Character  aChar,
const Standard_Character  NewChar,
const Standard_Boolean  CaseSensitive = Standard_True 
)

Substitutes all the characters equal to aChar by NewChar in the AsciiString <me>. The substitution can be case sensitive. If you don't use default case sensitive, no matter wether aChar is uppercase or not. Example: me = "Histake" -> ChangeAll('H','M',Standard_True) gives me = "Mistake".

◆ Clear()

void TCollection_AsciiString::Clear ( )

Removes all characters contained in <me>. This produces an empty AsciiString.

◆ Copy() [1/2]

void TCollection_AsciiString::Copy ( const Standard_CString  fromwhere)

Copy <fromwhere> to <me>. Used as operator = Example: aString = anotherCString;.

◆ Copy() [2/2]

void TCollection_AsciiString::Copy ( const TCollection_AsciiString fromwhere)

Copy <fromwhere> to <me>. Used as operator = Example: aString = anotherString;.

◆ EndsWith()

Standard_Boolean TCollection_AsciiString::EndsWith ( const TCollection_AsciiString theEndString) const

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

◆ FirstLocationInSet()

Standard_Integer TCollection_AsciiString::FirstLocationInSet ( const TCollection_AsciiString Set,
const Standard_Integer  FromIndex,
const Standard_Integer  ToIndex 
) const

Returns the index of the first character of <me> 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: before me = "aabAcAa", S = "Aa", FromIndex = 1, Toindex = 7 after me = "aabAcAa" returns 1.

◆ FirstLocationNotInSet()

Standard_Integer TCollection_AsciiString::FirstLocationNotInSet ( const TCollection_AsciiString Set,
const Standard_Integer  FromIndex,
const Standard_Integer  ToIndex 
) const

Returns the index of the first character of <me> that is not present in the set <Set>. The search begins to the index FromIndex and ends to the the index ToIndex in <me>. Returns zero if failure. Raises an exception if FromIndex or ToIndex is out of range. Example: before me = "aabAcAa", S = "Aa", FromIndex = 1, Toindex = 7 after me = "aabAcAa" returns 3.

◆ HashCode()

static Standard_Integer TCollection_AsciiString::HashCode ( const TCollection_AsciiString theAsciiString,
Standard_Integer  theUpperBound 
)
static

Computes a hash code for the given ASCII string, in the range [1, theUpperBound]. Returns the same integer value as the hash function for TCollection_ExtendedString.

Parameters
theAsciiStringthe ASCII string which hash code is to be computed
theUpperBoundthe upper bound of the range a computing hash code must be within
Returns
a computed hash code, in the range [1, theUpperBound]

◆ Insert() [1/3]

void TCollection_AsciiString::Insert ( const Standard_Integer  where,
const Standard_Character  what 
)

Inserts a Character at position <where>. Example: aString contains "hy not ?" aString.Insert(1,'W'); gives "Why not ?" aString contains "Wh" aString.Insert(3,'y'); gives "Why" aString contains "Way" aString.Insert(2,'h'); gives "Why".

◆ Insert() [2/3]

void TCollection_AsciiString::Insert ( const Standard_Integer  where,
const Standard_CString  what 
)

Inserts a CString at position <where>. Example: aString contains "O more" aString.Insert(2,"nce"); gives "Once more".

◆ Insert() [3/3]

void TCollection_AsciiString::Insert ( const Standard_Integer  where,
const TCollection_AsciiString what 
)

Inserts a AsciiString at position <where>.

◆ InsertAfter()

void TCollection_AsciiString::InsertAfter ( const Standard_Integer  Index,
const TCollection_AsciiString other 
)

Pushing a string after a specific index in the string <me>. Raises an exception if Index is out of bounds.

  • less than 0 (InsertAfter), or less than 1 (InsertBefore), or
  • greater than the number of characters in this ASCII string. Example: before me = "cde" , Index = 0 , other = "ab" after me = "abcde" , other = "ab"

◆ InsertBefore()

void TCollection_AsciiString::InsertBefore ( const Standard_Integer  Index,
const TCollection_AsciiString other 
)

Pushing a string before a specific index in the string <me>. Raises an exception if Index is out of bounds.

  • less than 0 (InsertAfter), or less than 1 (InsertBefore), or
  • greater than the number of characters in this ASCII string. Example: before me = "cde" , Index = 1 , other = "ab" after me = "abcde" , other = "ab"

◆ IntegerValue()

Standard_Integer TCollection_AsciiString::IntegerValue ( ) const

Converts a AsciiString containing a numeric expression to an Integer. Example: "215" returns 215.

◆ IsAscii()

Standard_Boolean 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.

◆ IsDifferent() [1/2]

Standard_Boolean TCollection_AsciiString::IsDifferent ( const Standard_CString  other) 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 !=.

◆ IsDifferent() [2/2]

Standard_Boolean TCollection_AsciiString::IsDifferent ( const TCollection_AsciiString other) 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 !=.

◆ IsEmpty()

Standard_Boolean TCollection_AsciiString::IsEmpty ( ) const
inline

Returns True if the string <me> contains zero character.

◆ IsEqual() [1/4]

Standard_Boolean TCollection_AsciiString::IsEqual ( const Standard_CString  other) 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 ==.

◆ IsEqual() [2/4]

Standard_Boolean TCollection_AsciiString::IsEqual ( const TCollection_AsciiString other) 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 ==.

◆ IsEqual() [3/4]

static Standard_Boolean TCollection_AsciiString::IsEqual ( const TCollection_AsciiString string1,
const TCollection_AsciiString string2 
)
static

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

◆ IsEqual() [4/4]

static Standard_Boolean TCollection_AsciiString::IsEqual ( const TCollection_AsciiString string1,
const Standard_CString  string2 
)
static

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

◆ IsGreater() [1/2]

Standard_Boolean TCollection_AsciiString::IsGreater ( const Standard_CString  other) const

Returns TRUE if <me> is 'ASCII' greater than <other>.

◆ IsGreater() [2/2]

Standard_Boolean TCollection_AsciiString::IsGreater ( const TCollection_AsciiString other) const

Returns TRUE if <me> is 'ASCII' greater than <other>.

◆ IsIntegerValue()

Standard_Boolean 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.

◆ IsLess() [1/2]

Standard_Boolean TCollection_AsciiString::IsLess ( const Standard_CString  other) const

Returns TRUE if <me> is 'ASCII' less than <other>.

◆ IsLess() [2/2]

Standard_Boolean TCollection_AsciiString::IsLess ( const TCollection_AsciiString other) const

Returns TRUE if <me> is 'ASCII' less than <other>.

◆ IsRealValue()

Standard_Boolean TCollection_AsciiString::IsRealValue ( ) const

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

◆ IsSameString()

static Standard_Boolean TCollection_AsciiString::IsSameString ( const TCollection_AsciiString theString1,
const TCollection_AsciiString theString2,
const Standard_Boolean  theIsCaseSensitive 
)
static

Returns True if the strings contain same characters.

◆ LeftAdjust()

void TCollection_AsciiString::LeftAdjust ( )

Removes all space characters in the begining of the string.

◆ LeftJustify()

void TCollection_AsciiString::LeftJustify ( const Standard_Integer  Width,
const Standard_Character  Filler 
)

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: before me = "abcdef" , Width = 9 , Filler = ' ' after me = "abcdef "

◆ Length()

Standard_Integer TCollection_AsciiString::Length ( ) const

Returns number of characters in <me>. This is the same functionality as 'strlen' in C. Example TCollection_AsciiString myAlphabet("abcdef"); assert ( myAlphabet.Length() == 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.

◆ Location() [1/2]

Standard_Integer TCollection_AsciiString::Location ( const TCollection_AsciiString other,
const Standard_Integer  FromIndex,
const Standard_Integer  ToIndex 
) const

Returns an index in the string <me> of the first occurence of the string S in the string <me> 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: before me = "aabAaAa", S = "Aa", FromIndex = 1, ToIndex = 7 after me = "aabAaAa" returns 4.

◆ Location() [2/2]

Standard_Integer TCollection_AsciiString::Location ( const Standard_Integer  N,
const Standard_Character  C,
const Standard_Integer  FromIndex,
const Standard_Integer  ToIndex 
) const

Returns the index of the nth occurence of the character C in the string <me> 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: before me = "aabAa", N = 3, C = 'a', FromIndex = 1, ToIndex = 5 after me = "aabAa" returns 5.

◆ LowerCase()

void TCollection_AsciiString::LowerCase ( )

Converts <me> to its lower-case equivalent. Example TCollection_AsciiString myString("Hello Dolly"); myString.UpperCase(); assert ( myString == "HELLO DOLLY" ); myString.LowerCase(); assert ( myString == "hello dolly" );.

◆ operator!=() [1/2]

Standard_Boolean TCollection_AsciiString::operator!= ( const Standard_CString  other) const
inline

◆ operator!=() [2/2]

Standard_Boolean TCollection_AsciiString::operator!= ( const TCollection_AsciiString other) const
inline

◆ operator+() [1/5]

TCollection_AsciiString TCollection_AsciiString::operator+ ( const Standard_Character  other) const
inline

◆ operator+() [2/5]

TCollection_AsciiString TCollection_AsciiString::operator+ ( const Standard_Integer  other) const
inline

◆ operator+() [3/5]

TCollection_AsciiString TCollection_AsciiString::operator+ ( const Standard_Real  other) const
inline

◆ operator+() [4/5]

TCollection_AsciiString TCollection_AsciiString::operator+ ( const Standard_CString  other) const
inline

◆ operator+() [5/5]

TCollection_AsciiString TCollection_AsciiString::operator+ ( const TCollection_AsciiString other) const
inline

◆ operator+=() [1/5]

void TCollection_AsciiString::operator+= ( const Standard_Character  other)
inline

◆ operator+=() [2/5]

void TCollection_AsciiString::operator+= ( const Standard_Integer  other)
inline

◆ operator+=() [3/5]

void TCollection_AsciiString::operator+= ( const Standard_Real  other)
inline

◆ operator+=() [4/5]

void TCollection_AsciiString::operator+= ( const Standard_CString  other)
inline

◆ operator+=() [5/5]

void TCollection_AsciiString::operator+= ( const TCollection_AsciiString other)
inline

◆ operator<() [1/2]

Standard_Boolean TCollection_AsciiString::operator< ( const Standard_CString  other) const
inline

◆ operator<() [2/2]

Standard_Boolean TCollection_AsciiString::operator< ( const TCollection_AsciiString other) const
inline

◆ operator=() [1/3]

void TCollection_AsciiString::operator= ( const Standard_CString  fromwhere)
inline

◆ operator=() [2/3]

void TCollection_AsciiString::operator= ( const TCollection_AsciiString fromwhere)
inline

◆ operator=() [3/3]

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

Move assignment operator.

◆ operator==() [1/2]

Standard_Boolean TCollection_AsciiString::operator== ( const Standard_CString  other) const
inline

◆ operator==() [2/2]

Standard_Boolean TCollection_AsciiString::operator== ( const TCollection_AsciiString other) const
inline

◆ operator>() [1/2]

Standard_Boolean TCollection_AsciiString::operator> ( const Standard_CString  other) const
inline

◆ operator>() [2/2]

Standard_Boolean TCollection_AsciiString::operator> ( const TCollection_AsciiString other) const
inline

◆ Prepend()

void TCollection_AsciiString::Prepend ( const TCollection_AsciiString other)

Inserts the string other at the beginning of this ASCII string. Example TCollection_AsciiString myAlphabet("cde"); TCollection_AsciiString myBegin("ab"); myAlphabet.Prepend(myBegin); assert ( myAlphabet == "abcde" );.

◆ Print()

void TCollection_AsciiString::Print ( Standard_OStream astream) const

Displays <me> on a stream.

◆ Read()

void TCollection_AsciiString::Read ( Standard_IStream astream)

Read <me> from a stream.

◆ RealValue()

Standard_Real TCollection_AsciiString::RealValue ( ) const

Converts an AsciiString containing a numeric expression. to a Real. Example: ex: "215" returns 215.0. ex: "3.14159267" returns 3.14159267.

◆ Remove()

void TCollection_AsciiString::Remove ( const Standard_Integer  where,
const Standard_Integer  ahowmany = 1 
)

Erases <ahowmany> characters from position <where>, <where> included. Example: aString contains "Hello" aString.Remove(2,2) erases 2 characters from position 2 This gives "Hlo".

◆ RemoveAll() [1/2]

void TCollection_AsciiString::RemoveAll ( const Standard_Character  C,
const Standard_Boolean  CaseSensitive 
)

Remove all the occurences of the character C in the string. Example: before me = "HellLLo", C = 'L' , CaseSensitive = True after me = "Hello".

◆ RemoveAll() [2/2]

void TCollection_AsciiString::RemoveAll ( const Standard_Character  what)

Removes every <what> characters from <me>.

◆ RightAdjust()

void TCollection_AsciiString::RightAdjust ( )

Removes all space characters at the end of the string.

◆ RightJustify()

void TCollection_AsciiString::RightJustify ( const Standard_Integer  Width,
const Standard_Character  Filler 
)

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: before me = "abcdef" , Width = 9 , Filler = ' ' after me = " abcdef".

◆ Search() [1/2]

Standard_Integer TCollection_AsciiString::Search ( const Standard_CString  what) const

Searches a CString in <me> from the beginning and returns position of first item <what> matching. it returns -1 if not found. Example: aString contains "Sample single test" aString.Search("le") returns 5.

◆ Search() [2/2]

Standard_Integer TCollection_AsciiString::Search ( const TCollection_AsciiString what) const

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

◆ SearchFromEnd() [1/2]

Standard_Integer TCollection_AsciiString::SearchFromEnd ( const Standard_CString  what) const

Searches a CString in a AsciiString from the end and returns position of first item <what> matching. It returns -1 if not found. Example: aString contains "Sample single test" aString.SearchFromEnd("le") returns 12.

◆ SearchFromEnd() [2/2]

Standard_Integer TCollection_AsciiString::SearchFromEnd ( const TCollection_AsciiString what) const

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

◆ SetValue() [1/3]

void TCollection_AsciiString::SetValue ( const Standard_Integer  where,
const Standard_Character  what 
)

Replaces one character in the AsciiString at position <where>. If <where> is less than zero or greater than the length of <me> an exception is raised. Example: aString contains "Garbake" astring.Replace(6,'g') gives <me> = "Garbage".

◆ SetValue() [2/3]

void TCollection_AsciiString::SetValue ( const Standard_Integer  where,
const Standard_CString  what 
)

Replaces a part of <me> by a CString. If <where> is less than zero or greater than the length of <me> an exception is raised. Example: aString contains "abcde" aString.SetValue(4,"1234567") gives <me> = "abc1234567".

◆ SetValue() [3/3]

void TCollection_AsciiString::SetValue ( const Standard_Integer  where,
const TCollection_AsciiString what 
)

Replaces a part of <me> by another AsciiString.

◆ Split()

TCollection_AsciiString TCollection_AsciiString::Split ( const Standard_Integer  where)

Splits a AsciiString into two sub-strings. Example: aString contains "abcdefg" aString.Split(3) gives <me> = "abc" and returns "defg".

◆ StartsWith()

Standard_Boolean TCollection_AsciiString::StartsWith ( const TCollection_AsciiString theStartString) const

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

◆ SubString()

TCollection_AsciiString TCollection_AsciiString::SubString ( const Standard_Integer  FromIndex,
const Standard_Integer  ToIndex 
) const

Creation of a sub-string of the string <me>. 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: before me = "abcdefg", ToIndex=3, FromIndex=6 after me = "abcdefg" returns "cdef".

◆ Swap()

void TCollection_AsciiString::Swap ( TCollection_AsciiString theOther)

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

◆ ToCString()

Standard_CString TCollection_AsciiString::ToCString ( ) 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.

◆ Token()

TCollection_AsciiString TCollection_AsciiString::Token ( )

Extracts <whichone> token from <me>. 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: aString contains "This is a message" aString.Token() returns "This" aString.Token(" ",4) returns "message" aString.Token(" ",2) returns "is" aString.Token(" ",9) returns "" Other separators than space character and tabulation are allowed : aString contains "1234; test:message , value" aString.Token("; :,",4) returns "value" aString.Token("; :,",2) returns "test".

◆ Trunc()

void TCollection_AsciiString::Trunc ( const Standard_Integer  ahowmany)

Truncates <me> to <ahowmany> characters. Example: me = "Hello Dolly" -> Trunc(3) -> me = "Hel".

◆ UpperCase()

void TCollection_AsciiString::UpperCase ( )

Converts <me> to its upper-case equivalent.

◆ UsefullLength()

Standard_Integer TCollection_AsciiString::UsefullLength ( ) const

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

◆ Value()

Standard_Character TCollection_AsciiString::Value ( const Standard_Integer  where) const

Returns character at position <where> in <me>. If <where> is less than zero or greater than the lenght of <me>, an exception is raised. Example: aString contains "Hello" aString.Value(2) returns 'e'.

Friends And Related Function Documentation

◆ operator<<

Standard_OStream& operator<< ( Standard_OStream astream,
const TCollection_AsciiString astring 
)
friend

◆ operator>>

Standard_IStream& operator>> ( Standard_IStream astream,
TCollection_AsciiString astring 
)
friend

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