TCollection
OCCT package TCollection: TCollection, TCollection_AsciiString, TCollection_ExtendedString, TCollection_HAsciiString, and 1 more bound classes.
TCollection
The package <TCollection> provides the services for the transient basic data structures.
Constructors(1)
Static methods(1)
- NextPrimeForMap(I: number): number
Returns a prime number greater than suitable to dimension a Map. When becomes great there is a limit on the result (today the limit is around 1 000 000). This is not a limit of the number of items but a limit in the number of buckets. i.e. there will be more collisions in the map.
Parameters (1)I
TCollection_AsciiString
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:
- Method ::Length() return the number of bytes, not the number of Unicode symbols.
- Methods taking/returning symbol index work with 8-bit code units, not true Unicode symbols, including ::Remove(), ::SetValue(), ::Value(), ::Search(), ::Trunc() and others. If application needs to process multi-byte Unicode symbols explicitly,
NCollection_UtfIterator<char>class can be used for iterating through Unicode string (UTF-32 code unit will be returned for each position).
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.
Constructors(11)
Initializes a AsciiString to an empty AsciiString.
- constructor(theMessage: string): TCollection_AsciiString
Initializes a AsciiString with a CString (null-terminated).
Parameters (1)theMessage—the C string to initialize from
- constructor(theValue: number): TCollection_AsciiString
Initializes an AsciiString with a real value.
Parameters (1)theValue—the real value to convert to string
- constructor(theValue: number): TCollection_AsciiString
Initializes an AsciiString with a real value.
Parameters (1)theValue—the real value to convert to string
- constructor(theString: TCollection_AsciiString): TCollection_AsciiString
Initializes a AsciiString with another AsciiString.
Parameters (1)theString—the string to copy from
- constructor(theMessage: string, theLength: number): TCollection_AsciiString
Initializes a AsciiString with a CString and explicit length.
Parameters (2)theMessage—the C string to initialize fromtheLength—the length of the string
- constructor(theLength: number, theFiller: string): TCollection_AsciiString
Initializes an AsciiString with specified length space allocated and filled with filler character. This is useful for buffers.
Parameters (2)theLength—the length to allocatetheFiller—the character to fill with
- constructor(theString: TCollection_AsciiString, theChar: string): TCollection_AsciiString
Initializes a AsciiString with copy of another AsciiString concatenated with the message character.
Parameters (2)theString—the string to copytheChar—the character to append
- constructor(theString: TCollection_AsciiString, theMessage: string): TCollection_AsciiString
Initializes a AsciiString with copy of another AsciiString concatenated with the message string.
Parameters (2)theString—the string to copytheMessage—the C string to append
- constructor(theString: TCollection_AsciiString, theOtherString: TCollection_AsciiString): TCollection_AsciiString
Initializes a AsciiString with copy of another AsciiString concatenated with the message string.
Parameters (2)theString—the string to copytheOtherString—the string to append
- constructor(theExtendedString: TCollection_ExtendedString, theReplaceNonAscii?: string): TCollection_AsciiString
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 (2)theExtendedString—the extended string to converttheReplaceNonAscii—replacement character for non-ASCII characters
Static methods(8)
- IsEqual(string1: TCollection_AsciiString, string2: TCollection_AsciiString): boolean
Returns True when the two strings are the same. (Just for HashCode for AsciiString).
Parameters (2)string1—first string to comparestring2—second C string to compare
Returnstrue if strings are equal
- IsEqual(string1: TCollection_AsciiString, string2: string): boolean
Returns True when the two strings are the same. (Just for HashCode for AsciiString).
Parameters (2)string1—first string to comparestring2—second C string to compare
Returnstrue if strings are equal
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:Returnsconst reference to static empty string
- IsSameString(theString1: TCollection_AsciiString, theString2: TCollection_AsciiString, theIsCaseSensitive: boolean): boolean
Returns True if the strings contain same characters.
Parameters (3)theString1—first string to comparetheString2—second string to comparetheIsCaseSensitive—flag indicating case sensitivity
Returnstrue if strings contain same characters
- IsSameString(theString1: TCollection_AsciiString, theCString: string, theIsCaseSensitive: boolean): boolean
Returns True if the string and C string contain same characters.
Parameters (3)theString1—first string to comparetheCString—second C string to comparetheIsCaseSensitive—flag indicating case sensitivity
Returnstrue if strings contain same characters
- IsSameString(theCString: string, theString2: TCollection_AsciiString, theIsCaseSensitive: boolean): boolean
Returns True if the C string and string contain same characters.
Parameters (3)theCString—first C string to comparetheString2—second string to comparetheIsCaseSensitive—flag indicating case sensitivity
Returnstrue if strings contain same characters
- IsSameString(theCString1: string, theCString2: string, theIsCaseSensitive: boolean): boolean
Returns True if the two C strings contain same characters.
Parameters (3)theCString1—first C string to comparetheCString2—second C string to comparetheIsCaseSensitive—flag indicating case sensitivity
Returnstrue if strings contain same characters
- IsSameString(theString1: string, theLength1: number, theString2: string, theLength2: number, theIsCaseSensitive: boolean): boolean
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 (5)theString1—pointer to first string to comparetheLength1—length of first stringtheString2—pointer to second string to comparetheLength2—length of second stringtheIsCaseSensitive—flag indicating case sensitivity
Returnstrue if strings contain same characters
Instance methods(90)
- AssignCat(theOther: string): void
Appends other character to this string. This is an unary operator.
Parameters (1)theOther—the character to append
- AssignCat(theOther: number): void
Appends other integer to this string. This is an unary operator.
Parameters (1)theOther—the integer to append
- AssignCat(theOther: number): void
Appends other real number to this string. This is an unary operator.
Parameters (1)theOther—the real number to append
- AssignCat(theOther: TCollection_AsciiString): void
Appends other string to this string. This is an unary operator.
Example:Parameters (1)theOther—the string to append
- AssignCat(theCString: string): void
Appends C string to this ASCII string.
Parameters (1)theCString—the C string to append
- AssignCat(theOther: TCollection_ExtendedString, theReplaceNonAscii: string): void
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 (2)theOther—the extended string to appendtheReplaceNonAscii—replacement character for non-ASCII characters
- AssignCat(theString: string, theLength: number): void
Core implementation: Appends string (pointer and length) to this ASCII string. This is the primary implementation that all other AssignCat overloads redirect to.
Parameters (2)theString—pointer to the string to appendtheLength—length of the string to append
- Capitalize(): void
Converts the first character into its corresponding upper-case character and the other characters into lowercase.
Example: - Cat(theOther: string): TCollection_AsciiString
Appends other character to this string.
Example:Parameters (1)theOther—the character to append
Returnsnew string with character appended
- Cat(theOther: number): TCollection_AsciiString
Appends other integer to this string.
Example:Parameters (1)theOther—the integer to append
Returnsnew string with integer appended
- Cat(theOther: number): TCollection_AsciiString
Appends other real number to this string.
Example:Parameters (1)theOther—the real number to append
Returnsnew string with real number appended
- Cat(theOther: TCollection_AsciiString): TCollection_AsciiString
Appends other string to this string.
Example:Parameters (1)theOther—the string to append
Returnsnew string with other string appended
- Cat(theCString: string): TCollection_AsciiString
Appends C string to this ASCII string.
Parameters (1)theCString—the C string to append
Returnsnew string with C string appended
- Cat(theString: string, theLength: number): TCollection_AsciiString
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 (2)theString—pointer to the string to appendtheLength—length of the string to append
Returnsnew string with the string appended
- Cat(theOther: TCollection_ExtendedString, theReplaceNonAscii: string): TCollection_AsciiString
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 (2)theOther—the extended string to appendtheReplaceNonAscii—replacement character for non-ASCII characters
Returnsnew string with extended string appended
- Center(theWidth: number, theFiller: string): void
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:Parameters (2)theWidth—the desired widththeFiller—the character to fill with
- ChangeAll(theChar: string, theNewChar: string, theCaseSensitive?: boolean): void
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:Parameters (3)theChar—the character to replacetheNewChar—the replacement charactertheCaseSensitive—flag indicating case sensitivity
- Clear(): void
Removes all characters contained in this string. This produces an empty AsciiString.
- Copy(theCString: string): void
Copy C string to this ASCII string. Used as operator =.
Parameters (1)theCString—the C string to copy from
- Copy(theFromWhere: TCollection_AsciiString): void
Template method for copying string literals or char arrays. For safety, uses strlen to get actual string length.
Example:Parameters (1)theFromWhere
- Copy(theString: string, theLength: number): void
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 (2)theString—pointer to the string to copy fromtheLength—length of the string to copy
- Swap(theOther: TCollection_AsciiString): void
Exchange the data of two strings (without reallocating memory).
Parameters (1)theOther—the string to exchange data with Mutated in place; read the updated value from this argument after the call.
- FirstLocationInSet(theSet: string, theSetLength: number, theFromIndex: number, theToIndex: number): number
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 (4)theSet—pointer to the set of characters to search fortheSetLength—length of the settheFromIndex—the starting index for searchtheToIndex—the ending index for search
Returnsthe index of first character found in set, or 0 if not found
- FirstLocationInSet(theSet: TCollection_AsciiString, theFromIndex: number, theToIndex: number): number
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:Parameters (3)theSet—the set of characters to search fortheFromIndex—the starting index for searchtheToIndex—the ending index for search
Returnsthe index of first character found in set, or 0 if not found
- FirstLocationNotInSet(theSet: string, theSetLength: number, theFromIndex: number, theToIndex: number): number
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 (4)theSet—pointer to the set of characters to check againsttheSetLength—length of the settheFromIndex—the starting index for searchtheToIndex—the ending index for search
Returnsthe index of first character not in set, or 0 if not found
- FirstLocationNotInSet(theSet: TCollection_AsciiString, theFromIndex: number, theToIndex: number): number
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:Parameters (3)theSet—the set of characters to check againsttheFromIndex—the starting index for searchtheToIndex—the ending index for search
Returnsthe index of first character not in set, or 0 if not found
- Insert(theWhere: number, theWhat: string): void
Inserts a Character at position where.
Example:Parameters (2)theWhere—the position to insert attheWhat—the character to insert
- Insert(theWhere: number, theWhat: TCollection_AsciiString): void
Inserts a AsciiString at position where.
Parameters (2)theWhere—the position to insert attheWhat—the ASCII string to insert
- Insert(theWhere: number, theCString: string): void
Inserts a C string at position theWhere.
Parameters (2)theWhere—position to insert attheCString—the C string to insert
- Insert(theWhere: number, theString: string, theLength: number): void
Core implementation: Inserts a string (pointer and length) at position theWhere. This is the primary implementation that all other Insert overloads redirect to.
Parameters (3)theWhere—position to insert attheString—pointer to the string to inserttheLength—length of the string to insert
- InsertAfter(theIndex: number, theOther: TCollection_AsciiString): void
Inserts an ASCII string after a specific index in this string. Raises an exception if index is out of bounds.
Parameters (2)theIndex—the index to insert aftertheOther—the string to insert
- InsertAfter(theIndex: number, theCString: string): void
Inserts a C string after a specific index in this string. Raises an exception if index is out of bounds.
Parameters (2)theIndex—the index to insert aftertheCString—the C string to insert
- InsertAfter(theIndex: number, theString: string, theLength: number): void
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 (3)theIndex—the index to insert aftertheString—pointer to the string to inserttheLength—length of the string to insert
- InsertBefore(theIndex: number, theOther: TCollection_AsciiString): void
Inserts an ASCII string before a specific index in this string. Raises an exception if index is out of bounds.
Parameters (2)theIndex—the index to insert beforetheOther—the string to insert
- InsertBefore(theIndex: number, theCString: string): void
Inserts a C string before a specific index in this string. Raises an exception if index is out of bounds.
Parameters (2)theIndex—the index to insert beforetheCString—the C string to insert
- InsertBefore(theIndex: number, theString: string, theLength: number): void
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 (3)theIndex—the index to insert beforetheString—pointer to the string to inserttheLength—length of the string to insert
- IsEmpty(): boolean
Returns True if this string contains zero character.
- IsEqual(theOther: TCollection_AsciiString): boolean
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 (1)theOther—the ASCII string to compare with
Returnstrue if strings are equal, false otherwise
- IsEqual(theCString: string): boolean
Returns true if the characters in this ASCII string are identical to the C string.
Parameters (1)theCString—the C string to compare with
Returnstrue if strings are equal, false otherwise
- IsEqual(theString: string, theLength: number): boolean
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 (2)theString—pointer to the string to compare withtheLength—length of the string to compare with
Returnstrue if strings are equal, false otherwise
- IsDifferent(theOther: TCollection_AsciiString): boolean
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 (1)theOther—the ASCII string to compare with
Returnstrue if strings are different, false otherwise
- IsDifferent(theCString: string): boolean
Returns true if there are differences between this ASCII string and C string.
Parameters (1)theCString—the C string to compare with
Returnstrue if strings are different, false otherwise
- IsDifferent(theString: string, theLength: number): boolean
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 (2)theString—pointer to the string to compare withtheLength—length of the string to compare with
Returnstrue if strings are different, false otherwise
- IsLess(theOther: TCollection_AsciiString): boolean
Returns TRUE if this string is 'ASCII' less than other.
Parameters (1)theOther—the ASCII string to compare with
Returnstrue if this string is lexicographically less than other
- IsLess(theCString: string): boolean
Returns TRUE if this string is lexicographically less than C string.
Parameters (1)theCString—the C string to compare with
Returnstrue if this string is lexicographically less than C string
- IsLess(theString: string, theLength: number): boolean
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 (2)theString—pointer to the string to compare withtheLength—length of the string to compare with
Returnstrue if this string is lexicographically less than the given string
- IsGreater(theOther: TCollection_AsciiString): boolean
Returns TRUE if this string is 'ASCII' greater than other.
Parameters (1)theOther—the ASCII string to compare with
Returnstrue if this string is lexicographically greater than other
- IsGreater(theCString: string): boolean
Returns TRUE if this string is lexicographically greater than C string.
Parameters (1)theCString—the C string to compare with
Returnstrue if this string is lexicographically greater than C string
- IsGreater(theString: string, theLength: number): boolean
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 (2)theString—pointer to the string to compare withtheLength—length of the string to compare with
Returnstrue if this string is lexicographically greater than the given string
- StartsWith(theStartString: TCollection_AsciiString): boolean
Determines whether the beginning of this string instance matches the specified string.
Parameters (1)theStartString—the string to check for at the beginning
Returnstrue if this string starts with theStartString
- StartsWith(theCString: string): boolean
Determines whether the beginning of this string matches the specified C string.
Parameters (1)theCString—the C string to check for at the beginning
Returnstrue if this string starts with theCString
- StartsWith(theStartString: string, theStartLength: number): boolean
Core implementation: Determines whether the beginning of this string instance matches the specified string (pointer and length).
Parameters (2)theStartString—pointer to the string to check for at the beginningtheStartLength—length of the string to check for
Returnstrue if this string starts with theStartString
- EndsWith(theEndString: string, theEndLength: number): boolean
Core implementation: Determines whether the end of this string instance matches the specified string (pointer and length).
Parameters (2)theEndString—pointer to the string to check for at the endtheEndLength—length of the string to check for
Returnstrue if this string ends with theEndString
- EndsWith(theEndString: TCollection_AsciiString): boolean
Determines whether the end of this string instance matches the specified string.
Parameters (1)theEndString—the string to check for at the end
Returnstrue if this string ends with theEndString
- IntegerValue(): number
Converts a AsciiString containing a numeric expression to an Integer.
Example:Returnsthe integer value of the string
- IsIntegerValue(): boolean
Returns True if the AsciiString contains an integer value. Note: an integer value is considered to be a real value as well.
Returnstrue if string represents an integer value
- IsRealValue(theToCheckFull?: boolean): boolean
Returns True if the AsciiString starts with some characters that can be interpreted as integer or real value.
Parameters (1)theToCheckFull—when 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.
Returnstrue if string represents a real value
- IsAscii(): boolean
Returns True if the AsciiString contains only ASCII characters between ' ' and '~'. This means no control character and no extended ASCII code.
Returnstrue if string contains only ASCII characters
- LeftAdjust(): void
Removes all space characters in the beginning of the string.
- LeftJustify(theWidth: number, theFiller: string): void
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:Parameters (2)theWidth—the desired widththeFiller—the character to fill with
- Length(): number
Returns number of characters in this string. This is the same functionality as 'strlen' in C.
Example:- 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.
Returnsthe number of characters in the string
- Location(theOther: TCollection_AsciiString, theFromIndex: number, theToIndex: number): number
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:Parameters (3)theOther—the string to search fortheFromIndex—the starting index for searchtheToIndex—the ending index for search
Returnsthe index of first occurrence, or 0 if not found
- Location(theN: number, theC: string, theFromIndex: number, theToIndex: number): number
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:Parameters (4)theN—the occurrence number to findtheC—the character to search fortheFromIndex—the starting index for searchtheToIndex—the ending index for search
Returnsthe index of the nth occurrence, or 0 if not found
- LowerCase(): void
Converts this string to its lower-case equivalent.
Example: - Prepend(theOther: TCollection_AsciiString): void
Inserts the string other at the beginning of this ASCII string.
Example:Parameters (1)theOther—the string to prepend
- RealValue(): number
Converts an AsciiString containing a numeric expression to a Real.
Example:Returnsthe real value of the string
- RemoveAll(theC: string, theCaseSensitive: boolean): void
Remove all the occurrences of the character C in the string.
Example:Parameters (2)theC—the character to removetheCaseSensitive—flag indicating case sensitivity
- RemoveAll(theWhat: string): void
Removes every what characters from this string.
Parameters (1)theWhat—the character to remove
- Remove(theWhere: number, theHowMany?: number): void
Erases ahowmany characters from position where, where included.
Example:Parameters (2)theWhere—the position to start erasing fromtheHowMany—the number of characters to erase
- RightAdjust(): void
Removes all space characters at the end of the string.
- RightJustify(theWidth: number, theFiller: string): void
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:Parameters (2)theWidth—the desired widththeFiller—the character to fill with
- Search(theWhat: TCollection_AsciiString): number
Searches an AsciiString in this string from the beginning and returns position of first item what matching. It returns -1 if not found.
Parameters (1)theWhat—the ASCII string to search for
Returnsthe position of first match, or -1 if not found
- Search(theCString: string): number
Searches a C string in this string from the beginning.
Parameters (1)theCString—the C string to search for
Returnsthe position of first match, or -1 if not found
- Search(theWhat: string, theWhatLength: number): number
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 (2)theWhat—pointer to the string to search fortheWhatLength—length of the string to search for
Returnsthe position of first match, or -1 if not found
- SearchFromEnd(theWhat: TCollection_AsciiString): number
Searches a AsciiString in another AsciiString from the end and returns position of first item what matching. It returns -1 if not found.
Parameters (1)theWhat—the ASCII string to search for
Returnsthe position of first match from end, or -1 if not found
- SearchFromEnd(theCString: string): number
Searches a C string in this string from the end.
Parameters (1)theCString—the C string to search for
Returnsthe position of first match from end, or -1 if not found
- SearchFromEnd(theWhat: string, theWhatLength: number): number
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 (2)theWhat—pointer to the string to search fortheWhatLength—length of the string to search for
Returnsthe position of first match from end, or -1 if not found
- SetValue(theWhere: number, theWhat: string): void
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:Parameters (2)theWhere—the position to replace attheWhat—the character to replace with
- SetValue(theWhere: number, theWhat: TCollection_AsciiString): void
Replaces a part of this string by another AsciiString.
Parameters (2)theWhere—the position to start replacementtheWhat—the ASCII string to replace with
- SetValue(theWhere: number, theCString: string): void
Replaces a part of this ASCII string with a C string.
Parameters (2)theWhere—position to start replacementtheCString—the C string to replace with
- SetValue(theWhere: number, theString: string, theLength: number): void
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 (3)theWhere—position to start replacementtheString—pointer to the string to replace withtheLength—length of the string to replace with
- Split(theWhere: number): TCollection_AsciiString
Splits a AsciiString into two sub-strings.
Example:Parameters (1)theWhere—the position to split at
Returnsthe second part of the split string
- SubString(theFromIndex: number, theToIndex: number): TCollection_AsciiString
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:Parameters (2)theFromIndex—the starting indextheToIndex—the ending index
Returnsthe substring from FromIndex to ToIndex
- ToCString(): string
Returns pointer to AsciiString (char *). This is useful for some casual manipulations. Warning: Because this "char *" is 'const', you can't modify its contents.
Returnsthe C string representation
- Token(theSeparators?: string, theWhichOne?: number): TCollection_AsciiString
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:Parameters (2)theSeparators—the separator characterstheWhichOne—the token number to extract
- Trunc(theHowMany: number): void
Truncates this string to ahowmany characters.
Example:Parameters (1)theHowMany—the number of characters to keep
- UpperCase(): void
Converts this string to its upper-case equivalent.
- UsefullLength(): number
Length of the string ignoring all spaces (' ') and the control character at the end.
Returnsthe useful length of the string
- Value(theWhere: number): string
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:Parameters (1)theWhere—the position to get character from
Returnsthe character at the specified position
- HashCode(): number
Computes a hash code for the given ASCII string Returns the same integer value as the hash function for
TCollection_ExtendedString.Returnsa computed hash code
TCollection_ExtendedString
A variable-length sequence of "extended" (UNICODE) characters (16-bit character type). It provides editing operations with built-in memory management to make ExtendedString objects easier to use than ordinary extended character arrays. ExtendedString objects follow "value semantics", that is, they are the actual strings, not handles to strings, and are copied through assignment. You may use HExtendedString objects to get handles to strings.
Beware that class can transparently store UTF-16 string with surrogate pairs (Unicode symbol represented by two 16-bit code units). However, surrogate pairs are not considered by the following methods:
- Method ::Length() return the number of 16-bit code units, not the number of Unicode symbols.
- Methods taking/returning symbol index work with 16-bit code units, not true Unicode symbols, including ::Remove(), ::SetValue(), ::Value(), ::Search(), ::Trunc() and others. If application needs to process surrogate pairs,
NCollection_UtfIterator<char16_t>class can be used for iterating through Unicode string (UTF-32 code unit will be returned for each position).
Constructors(7)
Initializes an ExtendedString to an empty ExtendedString.
- constructor(theValue: number): TCollection_ExtendedString
Initializes an ExtendedString with an integer value.
Parameters (1)theValue—the integer value to convert to string
- constructor(theValue: number): TCollection_ExtendedString
Initializes an ExtendedString with a real value.
Parameters (1)theValue—the real value to convert to string
Initializes an ExtendedString with another ExtendedString.
Parameters (1)theString—the string to copy from
- constructor(theStringView: string): TCollection_ExtendedString
Initializes an ExtendedString with a single extended character.
Parameters (1)theStringView
- constructor(theString: string, theIsMultiByte?: boolean): TCollection_ExtendedString
Creation by converting a CString to an extended string. If theIsMultiByte is true then the string is treated as having UTF-8 coding. If it is not a UTF-8 then theIsMultiByte is ignored and each character is copied to ExtCharacter.
Parameters (2)theString—the C string to converttheIsMultiByte—flag indicating UTF-8 coding
- constructor(theString: TCollection_AsciiString, theIsMultiByte?: boolean): TCollection_ExtendedString
Creation by converting an AsciiString to an extended string. The string is treated as having UTF-8 coding. If it is not a UTF-8 or multi byte then each character is copied to ExtCharacter.
Parameters (2)theString—the ASCII string to converttheIsMultiByte—flag indicating UTF-8 coding
Static methods(2)
- IsEqual(theString1: TCollection_ExtendedString, theString2: TCollection_ExtendedString): boolean
Returns true if the characters in this extended string are identical to the characters in the other extended string. Note that this method is an alias of operator ==.
Parameters (2)theString1—first string to comparetheString2—second string to compare
Returnstrue if strings are equal
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:Returnsconst reference to static empty string
Instance methods(78)
- AssignCat(theOther: TCollection_ExtendedString): void
Appends the other extended string to this extended string. Note that this method is an alias of operator +=.
Example:Parameters (1)theOther—the string to append
- AssignCat(theOther: number): void
Appends the integer value to this extended string.
Parameters (1)theOther—the integer to append
- AssignCat(theChar: string): void
Appends the utf16 char to this extended string.
Parameters (1)theChar—the character to append
- AssignCat(theOther: number): void
Appends the real value to this extended string.
Parameters (1)theOther—the real value to append
- AssignCat(theChar: string): void
Appends the utf16 char to this extended string.
Parameters (1)theChar—the character to append
- AssignCat(theStringView: string): void
Appends the char16_t string to this extended string.
Parameters (1)theStringView
- AssignCat(theString: string, theLength: number): void
Core implementation: Appends char16_t string (pointer and length) to this extended string. This is the primary implementation that all other AssignCat overloads redirect to.
Parameters (2)theString—pointer to the string to appendtheLength—length of the string to append
- Cat(theOther: number): TCollection_ExtendedString
Concatenates char16_t string and returns a new string.
Parameters (1)theOther—the null-terminated string to append
Returnsnew string with theOther appended
- Cat(theOther: number): TCollection_ExtendedString
Appends the integer value to this string and returns a new string.
Parameters (1)theOther—the integer to append
Returnsnew string with integer appended
- Cat(theChar: string): TCollection_ExtendedString
Appends a single extended (char16_t) character to this string and returns a new string.
Parameters (1)theChar—the extended character to append
- Cat(theOther: TCollection_ExtendedString): TCollection_ExtendedString
Appends the other extended string to this string and returns a new string.
Example:Parameters (1)theOther—the string to append
Returnsnew string with theOther appended
- Cat_2(theOther: string): TCollection_ExtendedString
Appends the other extended string to this string and returns a new string.
Example:Parameters (1)theOther—the string to append
Returnsnew string with theOther appended
- Cat(theOther: string, theLength: number): TCollection_ExtendedString
Core implementation: Concatenates char16_t string (pointer and length) and returns a new string.
Parameters (2)theOther—pointer to the string to appendtheLength—length of the string to append
Returnsnew string with theOther appended
- ChangeAll(theChar: string, theNewChar: string): void
Substitutes all the characters equal to theChar by theNewChar in this ExtendedString. The substitution can be case sensitive. If you don't use default case sensitive, no matter whether theChar is uppercase or not.
Example:Parameters (2)theChar—the character to replacetheNewChar—the replacement character
- Clear(): void
Removes all characters contained in this string. This produces an empty ExtendedString.
- Copy(theFromWhere: TCollection_ExtendedString): void
Copy theFromWhere to this string. Used as operator =.
Example:Parameters (1)theFromWhere—the string to copy from
- Copy_2(theString: string): void
Copy from a char16_t pointer.
Parameters (1)theString—the null-terminated string to copy
- Copy(theString: string, theLength: number): void
Core implementation: Copy from a char16_t pointer with explicit length.
Parameters (2)theString—pointer to the string to copytheLength—length of the string to copy
- Swap(theOther: TCollection_ExtendedString): void
Exchange the data of two strings (without reallocating memory).
Parameters (1)theOther—the string to exchange data with Mutated in place; read the updated value from this argument after the call.
- Insert(theWhere: number, theWhat: string): void
Insert a Character at position theWhere.
Example:Parameters (2)theWhere—the position to insert at (1-based)theWhat—the character to insert
- Insert(theWhere: number, theWhat: TCollection_ExtendedString): void
Insert a char16_t string at position theWhere.
Parameters (2)theWhere—the position to insert at (1-based)theWhat—the null-terminated string to insert
- Insert(theWhere: number, theWhat: string, theLength: number): void
Core implementation: Insert a char16_t string (pointer and length) at position theWhere.
Parameters (3)theWhere—the position to insert at (1-based)theWhat—pointer to the string to inserttheLength—length of the string to insert
- IsEmpty(): boolean
Returns True if this string contains no characters.
- IsEqual(theOther: TCollection_ExtendedString): boolean
Returns true if this string equals theOther null-terminated string. Note that this method is an alias of operator ==.
Parameters (1)theOther—the char16_t string to compare with
Returnstrue if strings are equal, false otherwise
- IsEqual_2(theOther: string): boolean
Returns true if the characters in this extended string are identical to the characters in theOther extended string. Note that this method is an alias of operator ==.
Parameters (1)theOther—the extended string to compare with
Returnstrue if strings are equal, false otherwise
- IsEqual_1(theOther: string, theLength: number): boolean
Core implementation: Returns true if this string equals theOther (pointer and length).
Parameters (2)theOther—pointer to the string to compare withtheLength—length of the string to compare with
Returnstrue if strings are equal, false otherwise
- IsDifferent(theOther: TCollection_ExtendedString): boolean
Returns true if this string differs from theOther null-terminated string. Note that this method is an alias of operator !=.
Parameters (1)theOther—the char16_t string to compare with
Returnstrue if strings are different, false otherwise
- IsDifferent_2(theOther: string): boolean
Returns true if there are differences between the characters in this extended string and theOther extended string. Note that this method is an alias of operator !=.
Parameters (1)theOther—the extended string to compare with
Returnstrue if strings are different, false otherwise
- IsDifferent(theOther: string, theLength: number): boolean
Core implementation: Returns true if this string differs from theOther (pointer and length).
Parameters (2)theOther—pointer to the string to compare withtheLength—length of the string to compare with
Returnstrue if strings are different, false otherwise
- IsLess(theOther: TCollection_ExtendedString): boolean
Returns TRUE if this string is lexicographically less than theOther.
Parameters (1)theOther—the char16_t string to compare with
Returnstrue if this string is less than theOther
- IsLess_2(theOther: string): boolean
Returns TRUE if this string is lexicographically less than theOther.
Parameters (1)theOther—the extended string to compare with
Returnstrue if this string is less than theOther
- IsLess(theOther: string, theLength: number): boolean
Core implementation: Returns TRUE if this string is lexicographically less than theOther.
Parameters (2)theOther—pointer to the string to compare withtheLength—length of the string to compare with
Returnstrue if this string is less than theOther
- IsGreater(theOther: TCollection_ExtendedString): boolean
Returns TRUE if this string is lexicographically greater than theOther.
Parameters (1)theOther—the char16_t string to compare with
Returnstrue if this string is greater than theOther
- IsGreater_2(theOther: string): boolean
Returns TRUE if this string is lexicographically greater than theOther.
Parameters (1)theOther—the extended string to compare with
Returnstrue if this string is greater than theOther
- IsGreater(theOther: string, theLength: number): boolean
Core implementation: Returns TRUE if this string is lexicographically greater than theOther.
Parameters (2)theOther—pointer to the string to compare withtheLength—length of the string to compare with
Returnstrue if this string is greater than theOther
- StartsWith(theStartString: TCollection_ExtendedString): boolean
Determines whether this string starts with theStartString.
Parameters (1)theStartString—the null-terminated string to check for
Returnstrue if this string starts with theStartString
- StartsWith_2(theStartString: string): boolean
Determines whether the beginning of this string instance matches the specified string.
Parameters (1)theStartString—the string to check for at the beginning
Returnstrue if this string starts with theStartString
- StartsWith(theStartString: string, theLength: number): boolean
Core implementation: Determines whether this string starts with theStartString.
Parameters (2)theStartString—pointer to the string to check fortheLength—length of the string to check for
Returnstrue if this string starts with theStartString
- EndsWith(theEndString: TCollection_ExtendedString): boolean
Determines whether this string ends with theEndString.
Parameters (1)theEndString—the null-terminated string to check for
Returnstrue if this string ends with theEndString
- EndsWith_2(theEndString: string): boolean
Determines whether the end of this string instance matches the specified string.
Parameters (1)theEndString—the string to check for at the end
Returnstrue if this string ends with theEndString
- EndsWith(theEndString: string, theLength: number): boolean
Core implementation: Determines whether this string ends with theEndString.
Parameters (2)theEndString—pointer to the string to check fortheLength—length of the string to check for
Returnstrue if this string ends with theEndString
- IsAscii(): boolean
Returns True if the ExtendedString contains only "Ascii Range" characters.
Returnstrue if string contains only ASCII characters
- Length(): number
Returns the number of 16-bit code units (might be greater than number of Unicode symbols if string contains surrogate pairs).
Returnsthe number of 16-bit code units
- RemoveAll(theWhat: string): void
Removes every theWhat characters from this string.
Parameters (1)theWhat—the character to remove
- Remove(theWhere: number, theHowMany?: number): void
Erases theHowMany characters from position theWhere, theWhere included.
Example:Parameters (2)theWhere—the position to start erasing from (1-based)theHowMany—the number of characters to erase
- Search(theWhat: TCollection_ExtendedString): number
Searches for theWhat null-terminated string from the beginning.
Parameters (1)theWhat—the null-terminated string to search for
Returnsthe position of first match (1-based), or -1 if not found
- Search_2(theWhat: string): number
Searches an ExtendedString in this string from the beginning and returns position of first item theWhat matching. It returns -1 if not found.
Parameters (1)theWhat—the string to search for
Returnsthe position of first match (1-based), or -1 if not found
- Search(theWhat: string, theLength: number): number
Core implementation: Searches for theWhat (pointer and length) from the beginning.
Parameters (2)theWhat—pointer to the string to search fortheLength—length of the string to search for
Returnsthe position of first match (1-based), or -1 if not found
- SearchFromEnd(theWhat: TCollection_ExtendedString): number
Searches for theWhat null-terminated string from the end.
Parameters (1)theWhat—the null-terminated string to search for
Returnsthe position of first match from end (1-based), or -1 if not found
- SearchFromEnd_2(theWhat: string): number
Searches an ExtendedString in this string from the end and returns position of first item theWhat matching. It returns -1 if not found.
Parameters (1)theWhat—the string to search for
Returnsthe position of first match from end (1-based), or -1 if not found
- SearchFromEnd(theWhat: string, theLength: number): number
Core implementation: Searches for theWhat (pointer and length) from the end.
Parameters (2)theWhat—pointer to the string to search fortheLength—length of the string to search for
Returnsthe position of first match from end (1-based), or -1 if not found
- SetValue(theWhere: number, theWhat: string): void
Replaces one character in the ExtendedString at position theWhere. If theWhere is less than zero or greater than the length of this string an exception is raised.
Example:Parameters (2)theWhere—the position to replace at (1-based)theWhat—the character to replace with
- SetValue(theWhere: number, theWhat: TCollection_ExtendedString): void
Replaces a part of this string by a null-terminated char16_t string.
Parameters (2)theWhere—the position to start replacement (1-based)theWhat—the null-terminated string to replace with
- SetValue(theWhere: number, theWhat: string, theLength: number): void
Core implementation: Replaces a part of this string by char16_t string (pointer and length).
Parameters (3)theWhere—the position to start replacement (1-based)theWhat—pointer to the string to replace withtheLength—length of the string to replace with
- SubString(theFromIndex: number, theToIndex: number): TCollection_ExtendedString
Copies characters from this string starting from index theFromIndex to the index theToIndex (inclusive). Raises an exception if theToIndex or theFromIndex is out of bounds.
Example:Parameters (2)theFromIndex—the starting index (1-based)theToIndex—the ending index (1-based, inclusive)
Returnsthe substring from theFromIndex to theToIndex
- Split(theWhere: number): TCollection_ExtendedString
Splits this extended string into two sub-strings at position theWhere.
- The second sub-string (from position theWhere + 1 of this string to the end) is returned in a new extended string.
- This extended string is modified: its last characters are removed, it becomes equal to the first sub-string (from the first character to position theWhere).
Example:
Parameters (1)theWhere—the position to split at (0-based)
Returnsthe second part of the split string
- Token(theSeparators: string, theWhichOne?: number): TCollection_ExtendedString
Extracts theWhichOne token from this string. By default, the theSeparators is set to space and tabulation. By default, the token extracted is the first one (theWhichOne = 1). theSeparators contains all separators you need. If no token indexed by theWhichOne is found, it returns an empty ExtendedString.
Example:Parameters (2)theSeparators—the separator characterstheWhichOne—the token number to extract (1-based)
Returnsthe extracted token
- ToExtString(): string
Returns pointer to ExtString (char16_t*).
Returnsthe char16_t string representation
- Trunc(theHowMany: number): void
Truncates this string to theHowMany characters.
Example:Parameters (1)theHowMany—the number of characters to keep
- Value(theWhere: number): string
Returns character at position theWhere in this string. If theWhere is less than zero or greater than the length of this string, an exception is raised.
Example:Parameters (1)theWhere—the position to get character from (1-based)
Returnsthe character at the specified position
- HashCode(): number
Returns a hashed value for the extended string. Note: if string is ASCII, the computed value is the same as the value computed with the HashCode function on a
TCollection_AsciiStringstring composed with equivalent ASCII characters.Returnsa computed hash code
- LengthOfCString(): number
Returns expected CString length in UTF8 coding (like strlen, without null terminator). It can be used for memory calculation before converting to CString containing symbols in UTF8 coding. For external allocation, use: char* buf = new char[str.LengthOfCString() + 1];.
Returnsexpected UTF-8 string length
- LeftAdjust(): void
Removes all space characters in the beginning of the string.
- RightAdjust(): void
Removes all space characters at the end of the string.
- LeftJustify(theWidth: number, theFiller: string): void
Left justify. Length becomes equal to theWidth and the new characters are equal to theFiller. If theWidth < Length nothing happens.
Parameters (2)theWidth—the desired width of the stringtheFiller—the character to fill with
- RightJustify(theWidth: number, theFiller: string): void
Right justify. Length becomes equal to theWidth and the new characters are equal to theFiller. If theWidth < Length nothing happens.
Parameters (2)theWidth—the desired width of the stringtheFiller—the character to fill with
- Center(theWidth: number, theFiller: string): void
Modifies this string so that its length becomes equal to theWidth and the new characters are equal to theFiller. New characters are added both at the beginning and at the end of this string. If theWidth is less than the length of this string, nothing happens.
Parameters (2)theWidth—the desired width of the stringtheFiller—the character to fill with
- Capitalize(): void
Converts the first character into its corresponding upper-case character and the other characters into lowercase.
RemarksNote: Only ASCII characters (a-z, A-Z) are affected by case conversion.
- Prepend(theOther: TCollection_ExtendedString): void
Inserts a null-terminated char16_t string at the beginning.
Parameters (1)theOther—the null-terminated string to prepend
- Prepend_2(theOther: string): void
Inserts the other extended string at the beginning of this string.
Parameters (1)theOther—the string to prepend
- Prepend(theOther: string, theLength: number): void
Core implementation: Inserts char16_t string (pointer and length) at the beginning.
Parameters (2)theOther—pointer to the string to prependtheLength—length of the string to prepend
- FirstLocationInSet(theSet: TCollection_ExtendedString, theFromIndex: number, theToIndex: number): number
Returns the index of the first character of this string that is present in theSet. The search begins at index theFromIndex and ends at index theToIndex. Returns zero if failure.
Parameters (3)theSet—the set of characters to search fortheFromIndex—the starting index for search (1-based)theToIndex—the ending index for search (1-based)
Returnsthe index of first character found in set, or 0 if not found
- FirstLocationNotInSet(theSet: TCollection_ExtendedString, theFromIndex: number, theToIndex: number): number
Returns the index of the first character of this string that is NOT present in theSet. The search begins at index theFromIndex and ends at index theToIndex. Returns zero if failure.
Parameters (3)theSet—the set of characters to check againsttheFromIndex—the starting index for search (1-based)theToIndex—the ending index for search (1-based)
Returnsthe index of first character not in set, or 0 if not found
- IntegerValue(): number
Converts this extended string containing a numeric expression to an Integer.
Returnsthe integer value
- IsIntegerValue(): boolean
Returns True if this extended string contains an integer value.
Returnstrue if string represents an integer value
- RealValue(): number
Converts this extended string containing a numeric expression to a Real.
Returnsthe real value
- IsRealValue(theToCheckFull?: boolean): boolean
Returns True if this extended string starts with characters that can be interpreted as a real value.
Parameters (1)theToCheckFull—when TRUE, checks if entire string defines a real value; otherwise checks if string starts with a real value
Returnstrue if string represents a real value
- IsSameString(theOther: TCollection_ExtendedString, theIsCaseSensitive: boolean): boolean
Returns True if the strings contain same characters.
Parameters (2)theOther—the string to compare withtheIsCaseSensitive—flag indicating case sensitivity
Returnstrue if strings contain same characters
RemarksNote: When case-insensitive, only ASCII characters (a-z, A-Z) are affected.
TCollection_HAsciiString
A variable-length sequence of ASCII characters (normal 8-bit character type). It provides editing operations with built-in memory management to make HAsciiString objects easier to use than ordinary character arrays. HAsciiString objects are handles to strings.
- HAsciiString strings may be shared by several objects.
- You may use an AsciiString object to get the actual string. Note: HAsciiString objects use an AsciiString string as a field.
Constructors(8)
Initializes a HAsciiString to an empty AsciiString.
- constructor(message: string): TCollection_HAsciiString
Initializes a HAsciiString with a CString.
Parameters (1)message
- constructor(value: number): TCollection_HAsciiString
Initializes a HAsciiString with a single character.
Parameters (1)value
- constructor(value: number): TCollection_HAsciiString
Initializes a HAsciiString with an integer value.
Parameters (1)value
Initializes a HAsciiString with a real value.
Parameters (1)aString
Initializes a HAsciiString with a AsciiString.
Parameters (1)aString
- constructor(length: number, filler: string): TCollection_HAsciiString
Initializes a HAsciiString with <length> space allocated. and filled with <filler>.This is useful for buffers.
Parameters (2)lengthfiller
- constructor(aString: TCollection_HExtendedString, replaceNonAscii: string): TCollection_HAsciiString
Initializes a HAsciiString with a HExtendedString. 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 (2)aStringreplaceNonAscii
Static methods(2)
- get_type_name(): string
Instance methods(56)
- AssignCat(other: string): void
Appends <other> to me.
Parameters (1)other
- AssignCat(other: TCollection_HAsciiString): void
Appends <other> to me. Example: aString = aString + anotherString.
Parameters (1)other
- Capitalize(): void
Converts the first character into its corresponding upper-case character and the other characters into lowercase. Example: before me = "hellO " after me = "Hello ".
- Cat(other: string): TCollection_HAsciiString
Creates a new string by concatenation of this ASCII string and the other ASCII string. Example: aString = aString + anotherString aString = aString + "Dummy" aString contains "I say " aString = aString + "Hello " + "Dolly" gives "I say Hello Dolly" Warning: 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.
Parameters (1)other
Creates a new string by concatenation of this ASCII string and the other ASCII string. Example: aString = aString + anotherString.
Parameters (1)other
- Center(Width: number, Filler: string): void
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
occ::handle<TCollection_HAsciiString>myAlphabet = newTCollection_HAsciiString("abcdef"); myAlphabet->Center(9,' '); assert ( !strcmp( myAlphabet->ToCString(), " abcdef ") );.Parameters (2)WidthFiller
- ChangeAll(aChar: string, NewChar: string, CaseSensitive?: boolean): void
Replaces all characters equal to aChar by NewChar in this ASCII string. The substitution is case sensitive if CaseSensitive is true (default value). If you do not use the default case sensitive option, it does not matter whether aChar is upper-case or not. Example
occ::handle<TCollection_HAsciiString>myMistake = newTCollection_HAsciiString("Hather"); myMistake->ChangeAll('H','F'); assert ( !strcmp( myMistake->ToCString(), "Father") );.Parameters (3)aCharNewCharCaseSensitive
- Clear(): void
Removes all characters contained in <me>. This produces an empty HAsciiString.
- FirstLocationInSet(Set: TCollection_HAsciiString, FromIndex: number, ToIndex: number): number
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.
Parameters (3)SetFromIndexToIndex
- FirstLocationNotInSet(Set: TCollection_HAsciiString, FromIndex: number, ToIndex: number): number
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.
Parameters (3)SetFromIndexToIndex
- Insert(where: number, what: string): void
Insert 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".
Parameters (2)wherewhat
- Insert(where: number, what: string): void
Insert a HAsciiString at position <where>.
Parameters (2)wherewhat
- Insert(where: number, what: TCollection_HAsciiString): void
Insert a HAsciiString at position <where>.
Parameters (2)wherewhat
- InsertAfter(Index: number, other: TCollection_HAsciiString): void
Inserts the other ASCII string a after a specific index in the string <me> Example: before me = "cde" , Index = 0 , other = "ab" after me = "abcde" , other = "ab".
Parameters (2)Indexother
- InsertBefore(Index: number, other: TCollection_HAsciiString): void
Inserts the other ASCII string a before a specific index in the string <me> Raises an exception if Index is out of bounds Example: before me = "cde" , Index = 1 , other = "ab" after me = "abcde" , other = "ab".
Parameters (2)Indexother
- IsEmpty(): boolean
Returns True if the string <me> contains zero character.
- IsLess(other: TCollection_HAsciiString): boolean
Returns TRUE if <me> is 'ASCII' less than <other>.
Parameters (1)other
- IsGreater(other: TCollection_HAsciiString): boolean
Returns TRUE if <me> is 'ASCII' greater than <other>.
Parameters (1)other
- IntegerValue(): number
Converts a HAsciiString containing a numeric expression to an Integer. Example: "215" returns 215.
- IsIntegerValue(): boolean
Returns True if the string contains an integer value.
- IsRealValue(): boolean
Returns True if the string contains a real value.
- IsAscii(): boolean
Returns True if the string contains only ASCII characters between ' ' and '~'. This means no control character and no extended ASCII code.
- IsDifferent(S: TCollection_HAsciiString): boolean
Returns True if the string S not contains same characters than the string <me>.
Parameters (1)S
- IsSameString(S: TCollection_HAsciiString): boolean
Returns True if the string S contains same characters than the string <me>.
Parameters (1)S
- IsSameString(S: TCollection_HAsciiString, CaseSensitive: boolean): boolean
Returns True if the string S contains same characters than the string <me>.
Parameters (2)SCaseSensitive
- LeftAdjust(): void
Removes all space characters in the beginning of the string.
- LeftJustify(Width: number, Filler: string): void
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 ".
Parameters (2)WidthFiller
- Length(): number
Returns number of characters in <me>. This is the same functionality as 'strlen' in C.
- Location(other: TCollection_HAsciiString, FromIndex: number, ToIndex: number): number
returns an index in the string <me> of the first occurrence 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
Parameters (3)otherFromIndexToIndex
- Location(N: number, C: string, FromIndex: number, ToIndex: number): number
Returns the index of the nth occurrence 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.
Parameters (4)NCFromIndexToIndex
- LowerCase(): void
Converts <me> to its lower-case equivalent.
- Prepend(other: TCollection_HAsciiString): void
Inserts the other string at the beginning of the string <me> Example: before me = "cde" , S = "ab" after me = "abcde" , S = "ab".
Parameters (1)other
- RealValue(): number
Converts a string containing a numeric expression to a Real. Example: "215" returns 215.0. "3.14159267" returns 3.14159267.
- RemoveAll(C: string, CaseSensitive: boolean): void
Remove all the occurrences of the character C in the string Example: before me = "HellLLo", C = 'L' , CaseSensitive = True after me = "Hello".
Parameters (2)CCaseSensitive
- RemoveAll(what: string): void
Removes every <what> characters from <me>.
Parameters (1)what
- Remove(where: number, ahowmany?: number): void
Erases <ahowmany> characters from position <where>, <where> included. Example: aString contains "Hello" aString.Erase(2,2) erases 2 characters from position 1 This gives "Hlo".
Parameters (2)whereahowmany
- RightAdjust(): void
Removes all space characters at the end of the string.
- RightJustify(Width: number, Filler: string): void
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".
Parameters (2)WidthFiller
- Search(what: string): number
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.
Parameters (1)what
- Search(what: TCollection_HAsciiString): number
Searches a String in <me> from the beginning and returns position of first item <what> matching. it returns -1 if not found.
Parameters (1)what
- SearchFromEnd(what: string): number
Searches a CString in a String 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.
Parameters (1)what
- SearchFromEnd(what: TCollection_HAsciiString): number
Searches a HAsciiString in another HAsciiString from the end and returns position of first item <what> matching. It returns -1 if not found.
Parameters (1)what
- SetValue(where: number, what: string): void
Replaces one character in the string 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".
Parameters (2)wherewhat
- SetValue(where: number, what: string): void
Replaces a part of <me> in the string 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".
Parameters (2)wherewhat
- SetValue(where: number, what: TCollection_HAsciiString): void
Replaces a part of <me> by another string.
Parameters (2)wherewhat
- Split(where: number): TCollection_HAsciiString
Splits a HAsciiString into two sub-strings. Example: aString contains "abcdefg" aString.Split(3) gives <me> = "abc" and returns "defg".
Parameters (1)where
- SubString(FromIndex: number, ToIndex: number): TCollection_HAsciiString
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".
Parameters (2)FromIndexToIndex
- ToCString(): string
Returns pointer to string (char *) This is useful for some casual manipulations Because this "char *" is 'const', you can't modify its contents.
- Token(separators?: string, whichone?: number): TCollection_HAsciiString
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 an empty String.
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".Parameters (2)separatorswhichone
- Trunc(ahowmany: number): void
Truncates <me> to <ahowmany> characters. Example: me = "Hello Dolly" -> Trunc(3) -> me = "Hel".
Parameters (1)ahowmany
- UpperCase(): void
Converts <me> to its upper-case equivalent.
- UsefullLength(): number
Length of the string ignoring all spaces (' ') and the control character at the end.
- Value(where: number): string
Returns character at position <where> in <me>. If <where> is less than zero or greater than the length of <me>, an exception is raised. Example: aString contains "Hello" aString.Value(2) returns 'e'.
Parameters (1)where
Returns the field myString.
- IsSameState(other: TCollection_HAsciiString): booleanParameters (1)
other
TCollection_HExtendedString
A variable-length sequence of "extended" (UNICODE) characters (16-bit character type). It provides editing operations with built-in memory management to make ExtendedString objects easier to use than ordinary extended character arrays. HExtendedString objects are handles to strings.
- HExtendedString strings may be shared by several objects.
- You may use an ExtendedString object to get the actual string. Note: HExtendedString objects use an ExtendedString string as a field.
Constructors(5)
Initializes a HExtendedString to an empty ExtendedString.
- constructor(message: string): TCollection_HExtendedString
Initializes a HExtendedString with a CString.
Parameters (1)message
Initializes a HExtendedString with an ExtString.
Parameters (1)aString
Initializes a HExtendedString with a single character.
Parameters (1)aString
Initializes a HExtendedString with a ExtendedString.
Parameters (1)aString
Static methods(2)
- get_type_name(): string
Instance methods(25)
- AssignCat(other: TCollection_HExtendedString): void
Appends <other> to me.
Parameters (1)other
Returns a string appending <other> to me.
Parameters (1)other
- ChangeAll(aChar: string, NewChar: string): void
Substitutes all the characters equal to aChar by NewChar in the string <me>.
Parameters (2)aCharNewChar
- Clear(): void
Removes all characters contained in <me>. This produces an empty ExtendedString.
- IsEmpty(): boolean
Returns True if the string <me> contains zero character.
- Insert(where: number, what: string): void
Insert a ExtCharacter 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".
Parameters (2)wherewhat
- Insert(where: number, what: TCollection_HExtendedString): void
Insert a HExtendedString at position <where>.
Parameters (2)wherewhat
- IsLess(other: TCollection_HExtendedString): boolean
Returns TRUE if <me> is less than <other>.
Parameters (1)other
- IsGreater(other: TCollection_HExtendedString): boolean
Returns TRUE if <me> is greater than <other>.
Parameters (1)other
- IsAscii(): boolean
Returns True if the string contains only "Ascii Range" characters.
- Length(): number
Returns number of characters in <me>. This is the same functionality as 'strlen' in C.
- Remove(where: number, ahowmany?: number): void
Erases <ahowmany> characters from position <where>, <where> included. Example: aString contains "Hello" aString.Erase(2,2) erases 2 characters from position 1 This gives "Hlo".
Parameters (2)whereahowmany
- RemoveAll(what: string): void
Removes every <what> characters from <me>.
Parameters (1)what
- SetValue(where: number, what: string): void
Replaces one character in the string 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".
Parameters (2)wherewhat
- SetValue(where: number, what: TCollection_HExtendedString): void
Replaces a part of <me> by another string.
Parameters (2)wherewhat
- Split(where: number): TCollection_HExtendedString
Splits a ExtendedString into two sub-strings. Example: aString contains "abcdefg" aString.Split(3) gives <me> = "abc" and returns "defg".
Parameters (1)where
- Search(what: TCollection_HExtendedString): number
Searches a String in <me> from the beginning and returns position of first item <what> matching. It returns -1 if not found.
Parameters (1)what
- SearchFromEnd(what: TCollection_HExtendedString): number
Searches a ExtendedString in another ExtendedString from the end and returns position of first item <what> matching. It returns -1 if not found.
Parameters (1)what
- ToExtString(): string
Returns pointer to ExtString.
- Token(separators: string, whichone?: number): TCollection_HExtendedString
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 an empty String.
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".Parameters (2)separatorswhichone
- Trunc(ahowmany: number): void
Truncates <me> to <ahowmany> characters. Example: me = "Hello Dolly" -> Trunc(3) -> me = "Hel".
Parameters (1)ahowmany
- Value(where: number): string
Returns ExtCharacter at position <where> in <me>. If <where> is less than zero or greater than the length of <me>, an exception is raised. Example: aString contains "Hello" aString.Value(2) returns 'e'.
Parameters (1)where
Returns the field myString.
- IsSameState(other: TCollection_HExtendedString): booleanParameters (1)
other