OpenCascade.js
API ReferenceFoundationClassesTKernel

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.

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

    Parameters (1)
    • theMessage
      the C string to initialize from
  • Initializes an AsciiString with a real value.

    Parameters (1)
    • theValue
      the real value to convert to string
  • Initializes an AsciiString with a real value.

    Parameters (1)
    • theValue
      the real value to convert to string
  • 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 from
    • theLength
      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 allocate
    • theFiller
      the character to fill with
  • Initializes a AsciiString with copy of another AsciiString concatenated with the message character.

    Parameters (2)
    • theString
      the string to copy
    • theChar
      the character to append
  • Initializes a AsciiString with copy of another AsciiString concatenated with the message string.

    Parameters (2)
    • theString
      the string to copy
    • theMessage
      the C string to append
  • Initializes a AsciiString with copy of another AsciiString concatenated with the message string.

    Parameters (2)
    • theString
      the string to copy
    • theOtherString
      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 convert
    • theReplaceNonAscii
      replacement character for non-ASCII characters

Static methods(8)

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

    Parameters (2)
    • string1
      first string to compare
    • string2
      second C string to compare
    Returns

    true 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 compare
    • string2
      second C string to compare
    Returns

    true 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:

    constTCollection_AsciiString&anEmptyStr=TCollection_AsciiString::EmptyString(); //UseanEmptyStrinsteadofTCollection_AsciiString()
    Returns

    const 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 compare
    • theString2
      second string to compare
    • theIsCaseSensitive
      flag indicating case sensitivity
    Returns

    true 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 compare
    • theCString
      second C string to compare
    • theIsCaseSensitive
      flag indicating case sensitivity
    Returns

    true 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 compare
    • theString2
      second string to compare
    • theIsCaseSensitive
      flag indicating case sensitivity
    Returns

    true 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 compare
    • theCString2
      second C string to compare
    • theIsCaseSensitive
      flag indicating case sensitivity
    Returns

    true 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 compare
    • theLength1
      length of first string
    • theString2
      pointer to second string to compare
    • theLength2
      length of second string
    • theIsCaseSensitive
      flag indicating case sensitivity
    Returns

    true 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
  • Appends other string to this string. This is an unary operator.
    Example:

    TCollection_AsciiStringaString("Hello"); TCollection_AsciiStringanotherString("World"); aString+=anotherString; //Result:aString=="HelloWorld"
    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 append
    • theReplaceNonAscii
      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 append
    • theLength
      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:

    TCollection_AsciiStringaString("hellO"); aString.Capitalize(); //Result:aString=="Hello"
  • Cat(theOther: string): TCollection_AsciiString

    Appends other character to this string.
    Example:

    TCollection_AsciiStringaString("Isay"); TCollection_AsciiStringaResult=aString+'!'; //Result:aResult=="Isay!" //Tocatenatemore,youmustputaStringbefore. //"Hello"+"Dolly"//THISISNOTALLOWED //ThisruleisapplicabletoAssignCat(operator+=)too.
    Parameters (1)
    • theOther
      the character to append
    Returns

    new string with character appended

  • Cat(theOther: number): TCollection_AsciiString

    Appends other integer to this string.
    Example:

    TCollection_AsciiStringaString("Isay"); TCollection_AsciiStringaResult=aString+15; //Result:aResult=="Isay15"
    Parameters (1)
    • theOther
      the integer to append
    Returns

    new string with integer appended

  • Cat(theOther: number): TCollection_AsciiString

    Appends other real number to this string.
    Example:

    TCollection_AsciiStringaString("Isay"); TCollection_AsciiStringaResult=aString+15.15; //Result:aResult=="Isay15.15"
    Parameters (1)
    • theOther
      the real number to append
    Returns

    new string with real number appended

  • Appends other string to this string.
    Example:

    TCollection_AsciiStringaString("Hello"); TCollection_AsciiStringanotherString("World"); TCollection_AsciiStringaResult=aString+anotherString; //Result:aResult=="HelloWorld"
    Parameters (1)
    • theOther
      the string to append
    Returns

    new 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
    Returns

    new 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 append
    • theLength
      length of the string to append
    Returns

    new 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 append
    • theReplaceNonAscii
      replacement character for non-ASCII characters
    Returns

    new 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:

    TCollection_AsciiStringanAlphabet("abcdef"); anAlphabet.Center(9,''); //Result:anAlphabet=="abcdef"
    Parameters (2)
    • theWidth
      the desired width
    • theFiller
      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:

    TCollection_AsciiStringaString("Histake"); aString.ChangeAll('H','M',true); //Result:aString=="Mistake"
    Parameters (3)
    • theChar
      the character to replace
    • theNewChar
      the replacement character
    • theCaseSensitive
      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:

    TCollection_AsciiStringaString; aString="HelloWorld";//Stringliteral charbuffer[50];sprintf(buffer,"test"); aString=buffer;//Chararray-usesstrlen //Result:aString=="test"
    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 from
    • theLength
      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 for
    • theSetLength
      length of the set
    • theFromIndex
      the starting index for search
    • theToIndex
      the ending index for search
    Returns

    the 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:

    TCollection_AsciiStringaString("aabAcAa"); TCollection_AsciiStringaSet("Aa"); intanIndex=aString.FirstLocationInSet(aSet,1,7); //Result:anIndex==1
    Parameters (3)
    • theSet
      the set of characters to search for
    • theFromIndex
      the starting index for search
    • theToIndex
      the ending index for search
    Returns

    the 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 against
    • theSetLength
      length of the set
    • theFromIndex
      the starting index for search
    • theToIndex
      the ending index for search
    Returns

    the 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:

    TCollection_AsciiStringaString("aabAcAa"); TCollection_AsciiStringaSet("Aa"); intanIndex=aString.FirstLocationNotInSet(aSet,1,7); //Result:anIndex==3
    Parameters (3)
    • theSet
      the set of characters to check against
    • theFromIndex
      the starting index for search
    • theToIndex
      the ending index for search
    Returns

    the 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:

    TCollection_AsciiStringaString("hynot?"); aString.Insert(1,'W'); //Result:aString=="Whynot?" TCollection_AsciiStringbString("Wh"); bString.Insert(3,'y'); //Result:bString=="Why"
    Parameters (2)
    • theWhere
      the position to insert at
    • theWhat
      the character to insert
  • Insert(theWhere: number, theWhat: TCollection_AsciiString): void

    Inserts a AsciiString at position where.

    Parameters (2)
    • theWhere
      the position to insert at
    • theWhat
      the ASCII string to insert
  • Insert(theWhere: number, theCString: string): void

    Inserts a C string at position theWhere.

    Parameters (2)
    • theWhere
      position to insert at
    • theCString
      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 at
    • theString
      pointer to the string to insert
    • theLength
      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 after
    • theOther
      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 after
    • theCString
      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 after
    • theString
      pointer to the string to insert
    • theLength
      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 before
    • theOther
      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 before
    • theCString
      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 before
    • theString
      pointer to the string to insert
    • theLength
      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
    Returns

    true 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
    Returns

    true 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 with
    • theLength
      length of the string to compare with
    Returns

    true if strings are equal, false otherwise

  • 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
    Returns

    true 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
    Returns

    true 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 with
    • theLength
      length of the string to compare with
    Returns

    true 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
    Returns

    true 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
    Returns

    true 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 with
    • theLength
      length of the string to compare with
    Returns

    true if this string is lexicographically less than the given string

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

    Parameters (1)
    • theOther
      the ASCII string to compare with
    Returns

    true 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
    Returns

    true 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 with
    • theLength
      length of the string to compare with
    Returns

    true 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
    Returns

    true 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
    Returns

    true 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 beginning
    • theStartLength
      length of the string to check for
    Returns

    true 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 end
    • theEndLength
      length of the string to check for
    Returns

    true 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
    Returns

    true if this string ends with theEndString

  • IntegerValue(): number

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

    TCollection_AsciiStringaString("215"); intanInt=aString.IntegerValue(); //Result:anInt==215
    Returns

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

    Returns

    true 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.
    Returns

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

    Returns

    true 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:

    TCollection_AsciiStringaString("abcdef"); aString.LeftJustify(9,''); //Result:aString=="abcdef"
    Parameters (2)
    • theWidth
      the desired width
    • theFiller
      the character to fill with
  • Length(): number

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

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

    the number of characters in the string

  • Location(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:

    TCollection_AsciiStringaString("aabAaAa"); TCollection_AsciiStringaSearchString("Aa"); intanIndex=aString.Location(aSearchString,1,7); //Result:anIndex==4
    Parameters (3)
    • theOther
      the string to search for
    • theFromIndex
      the starting index for search
    • theToIndex
      the ending index for search
    Returns

    the 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:

    TCollection_AsciiStringaString("aabAa"); intanIndex=aString.Location(3,'a',1,5); //Result:anIndex==5
    Parameters (4)
    • theN
      the occurrence number to find
    • theC
      the character to search for
    • theFromIndex
      the starting index for search
    • theToIndex
      the ending index for search
    Returns

    the index of the nth occurrence, or 0 if not found

  • LowerCase(): void

    Converts this string to its lower-case equivalent.
    Example:

    TCollection_AsciiStringaString("HelloDolly"); aString.UpperCase(); //Result:aString=="HELLODOLLY" aString.LowerCase(); //Result:aString=="hellodolly"
  • Inserts the string other at the beginning of this ASCII string.
    Example:

    TCollection_AsciiStringanAlphabet("cde"); TCollection_AsciiStringaBegin("ab"); anAlphabet.Prepend(aBegin); //Result:anAlphabet=="abcde"
    Parameters (1)
    • theOther
      the string to prepend
  • RealValue(): number

    Converts an AsciiString containing a numeric expression to a Real.
    Example:

    TCollection_AsciiStringaString1("215"); doubleaReal1=aString1.RealValue(); //Result:aReal1==215.0 TCollection_AsciiStringaString2("3.14159267"); doubleaReal2=aString2.RealValue(); //Result:aReal2==3.14159267
    Returns

    the real value of the string

  • RemoveAll(theC: string, theCaseSensitive: boolean): void

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

    TCollection_AsciiStringaString("HellLLo"); aString.RemoveAll('L',true); //Result:aString=="Hello"
    Parameters (2)
    • theC
      the character to remove
    • theCaseSensitive
      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:

    TCollection_AsciiStringaString("Hello"); aString.Remove(2,2);//erases2charactersfromposition2 //Result:aString=="Hlo"
    Parameters (2)
    • theWhere
      the position to start erasing from
    • theHowMany
      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:

    TCollection_AsciiStringaString("abcdef"); aString.RightJustify(9,''); //Result:aString=="abcdef"
    Parameters (2)
    • theWidth
      the desired width
    • theFiller
      the character to fill with
  • 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
    Returns

    the 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
    Returns

    the 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 for
    • theWhatLength
      length of the string to search for
    Returns

    the position of first match, or -1 if not found

  • 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
    Returns

    the 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
    Returns

    the 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 for
    • theWhatLength
      length of the string to search for
    Returns

    the 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:

    TCollection_AsciiStringaString("Garbake"); aString.SetValue(6,'g'); //Result:aString=="Garbage"
    Parameters (2)
    • theWhere
      the position to replace at
    • theWhat
      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 replacement
    • theWhat
      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 replacement
    • theCString
      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 replacement
    • theString
      pointer to the string to replace with
    • theLength
      length of the string to replace with
  • Split(theWhere: number): TCollection_AsciiString

    Splits a AsciiString into two sub-strings.
    Example:

    TCollection_AsciiStringaString("abcdefg"); TCollection_AsciiStringaSecondPart=aString.Split(3); //Result:aString=="abc"andaSecondPart=="defg"
    Parameters (1)
    • theWhere
      the position to split at
    Returns

    the 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:

    TCollection_AsciiStringaString("abcdefg"); TCollection_AsciiStringaSubString=aString.SubString(3,6); //Result:aSubString=="cdef"
    Parameters (2)
    • theFromIndex
      the starting index
    • theToIndex
      the ending index
    Returns

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

    Returns

    the 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:

    TCollection_AsciiStringaString("Thisisamessage"); TCollection_AsciiStringaToken1=aString.Token(); //Result:aToken1=="This" TCollection_AsciiStringaToken2=aString.Token("",4); //Result:aToken2=="message" TCollection_AsciiStringaToken3=aString.Token("",2); //Result:aToken3=="is" TCollection_AsciiStringaToken4=aString.Token("",9); //Result:aToken4=="" TCollection_AsciiStringbString("1234;test:message,value"); TCollection_AsciiStringbToken1=bString.Token(";:,",4); //Result:bToken1=="value" TCollection_AsciiStringbToken2=bString.Token(";:,",2); //Result:bToken2=="test"
    Parameters (2)
    • theSeparators
      the separator characters
    • theWhichOne
      the token number to extract
  • Trunc(theHowMany: number): void

    Truncates this string to ahowmany characters.
    Example:

    TCollection_AsciiStringaString("HelloDolly"); aString.Trunc(3); //Result:aString=="Hel"
    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.

    Returns

    the 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:

    TCollection_AsciiStringaString("Hello"); charaChar=aString.Value(2); //Result:aChar=='e'
    Parameters (1)
    • theWhere
      the position to get character from
    Returns

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

    Returns

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

  • Initializes an ExtendedString with an integer value.

    Parameters (1)
    • theValue
      the integer value to convert to string
  • 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 convert
    • theIsMultiByte
      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 convert
    • theIsMultiByte
      flag indicating UTF-8 coding

Static methods(2)

  • 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 compare
    • theString2
      second string to compare
    Returns

    true 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:

    constTCollection_ExtendedString&anEmptyStr=TCollection_ExtendedString::EmptyString(); //UseanEmptyStrinsteadofTCollection_ExtendedString()
    Returns

    const reference to static empty string

Instance methods(78)

  • Appends the other extended string to this extended string. Note that this method is an alias of operator +=.
    Example:

    TCollection_ExtendedStringaString(u"Hello"); TCollection_ExtendedStringanotherString(u"World"); aString+=anotherString; //Result:aString==u"HelloWorld"
    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 append
    • theLength
      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
    Returns

    new 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
    Returns

    new string with integer appended

  • Appends a single extended (char16_t) character to this string and returns a new string.

    Parameters (1)
    • theChar
      the extended character to append
  • Appends the other extended string to this string and returns a new string.
    Example:

    TCollection_ExtendedStringaString(u"Hello"); TCollection_ExtendedStringanotherString(u"World"); TCollection_ExtendedStringaResult=aString+anotherString; //Result:aResult==u"HelloWorld"
    Parameters (1)
    • theOther
      the string to append
    Returns

    new string with theOther appended

  • Appends the other extended string to this string and returns a new string.
    Example:

    TCollection_ExtendedStringaString(u"Hello"); TCollection_ExtendedStringanotherString(u"World"); TCollection_ExtendedStringaResult=aString+anotherString; //Result:aResult==u"HelloWorld"
    Parameters (1)
    • theOther
      the string to append
    Returns

    new 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 append
    • theLength
      length of the string to append
    Returns

    new 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:

    TCollection_ExtendedStringaString(u"Histake"); aString.ChangeAll(u'H',u'M'); //Result:aString==u"Mistake"
    Parameters (2)
    • theChar
      the character to replace
    • theNewChar
      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:

    TCollection_ExtendedStringaString; TCollection_ExtendedStringanotherString(u"HelloWorld"); aString=anotherString;//operator= //Result:aString==u"HelloWorld"
    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 copy
    • theLength
      length of the string to copy
  • 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:

    TCollection_ExtendedStringaString(u"hynot?"); aString.Insert(1,u'W'); //Result:aString==u"Whynot?"
    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 insert
    • theLength
      length of the string to insert
  • IsEmpty(): boolean

    Returns True if this string contains no characters.

  • 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
    Returns

    true 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
    Returns

    true 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 with
    • theLength
      length of the string to compare with
    Returns

    true if strings are equal, false otherwise

  • 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
    Returns

    true 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
    Returns

    true 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 with
    • theLength
      length of the string to compare with
    Returns

    true if strings are different, false otherwise

  • Returns TRUE if this string is lexicographically less than theOther.

    Parameters (1)
    • theOther
      the char16_t string to compare with
    Returns

    true 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
    Returns

    true 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 with
    • theLength
      length of the string to compare with
    Returns

    true if this string is less than theOther

  • Returns TRUE if this string is lexicographically greater than theOther.

    Parameters (1)
    • theOther
      the char16_t string to compare with
    Returns

    true 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
    Returns

    true 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 with
    • theLength
      length of the string to compare with
    Returns

    true 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
    Returns

    true 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
    Returns

    true 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 for
    • theLength
      length of the string to check for
    Returns

    true 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
    Returns

    true 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
    Returns

    true 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 for
    • theLength
      length of the string to check for
    Returns

    true if this string ends with theEndString

  • IsAscii(): boolean

    Returns True if the ExtendedString contains only "Ascii Range" characters.

    Returns

    true 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).

    Returns

    the 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:

    TCollection_ExtendedStringaString(u"Hello"); aString.Remove(2,2);//erases2charactersfromposition2 //Result:aString==u"Hlo"
    Parameters (2)
    • theWhere
      the position to start erasing from (1-based)
    • theHowMany
      the number of characters to erase
  • Searches for theWhat null-terminated string from the beginning.

    Parameters (1)
    • theWhat
      the null-terminated string to search for
    Returns

    the 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
    Returns

    the 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 for
    • theLength
      length of the string to search for
    Returns

    the position of first match (1-based), or -1 if not found

  • Searches for theWhat null-terminated string from the end.

    Parameters (1)
    • theWhat
      the null-terminated string to search for
    Returns

    the 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
    Returns

    the 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 for
    • theLength
      length of the string to search for
    Returns

    the 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:

    TCollection_ExtendedStringaString(u"Garbake"); aString.SetValue(6,u'g'); //Result:aString==u"Garbage"
    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 with
    • theLength
      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:

    TCollection_ExtendedStringaString(u"abcdefg"); TCollection_ExtendedStringaSubString=aString.SubString(3,6); //Result:aSubString==u"cdef"
    Parameters (2)
    • theFromIndex
      the starting index (1-based)
    • theToIndex
      the ending index (1-based, inclusive)
    Returns

    the substring from theFromIndex to theToIndex

  • 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:
    TCollection_ExtendedStringaString(u"abcdefg"); TCollection_ExtendedStringaSecondPart=aString.Split(3); //Result:aString==u"abc"andaSecondPart==u"defg"
    Parameters (1)
    • theWhere
      the position to split at (0-based)
    Returns

    the 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:

    TCollection_ExtendedStringaString(u"Thisisamessage"); TCollection_ExtendedStringaToken1=aString.Token(); //Result:aToken1==u"This" TCollection_ExtendedStringaToken2=aString.Token(u"",4); //Result:aToken2==u"message" TCollection_ExtendedStringaToken3=aString.Token(u"",2); //Result:aToken3==u"is" TCollection_ExtendedStringaToken4=aString.Token(u"",9); //Result:aToken4==u"" TCollection_ExtendedStringbString(u"1234;test:message,value"); TCollection_ExtendedStringbToken1=bString.Token(u";:,",4); //Result:bToken1==u"value"
    Parameters (2)
    • theSeparators
      the separator characters
    • theWhichOne
      the token number to extract (1-based)
    Returns

    the extracted token

  • ToExtString(): string

    Returns pointer to ExtString (char16_t*).

    Returns

    the char16_t string representation

  • Trunc(theHowMany: number): void

    Truncates this string to theHowMany characters.
    Example:

    TCollection_ExtendedStringaString(u"HelloDolly"); aString.Trunc(3); //Result:aString==u"Hel"
    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:

    TCollection_ExtendedStringaString(u"Hello"); char16_taChar=aString.Value(2); //Result:aChar==u'e'
    Parameters (1)
    • theWhere
      the position to get character from (1-based)
    Returns

    the 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_AsciiString string composed with equivalent ASCII characters.

    Returns

    a 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];.

    Returns

    expected 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 string
    • theFiller
      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 string
    • theFiller
      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 string
    • theFiller
      the character to fill with
  • Capitalize(): void

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

    Remarks

    Note: Only ASCII characters (a-z, A-Z) are affected by case conversion.

  • 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 prepend
    • theLength
      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 for
    • theFromIndex
      the starting index for search (1-based)
    • theToIndex
      the ending index for search (1-based)
    Returns

    the 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 against
    • theFromIndex
      the starting index for search (1-based)
    • theToIndex
      the ending index for search (1-based)
    Returns

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

    Returns

    the integer value

  • IsIntegerValue(): boolean

    Returns True if this extended string contains an integer value.

    Returns

    true if string represents an integer value

  • RealValue(): number

    Converts this extended string containing a numeric expression to a Real.

    Returns

    the 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
    Returns

    true 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 with
    • theIsCaseSensitive
      flag indicating case sensitivity
    Returns

    true if strings contain same characters

    Remarks

    Note: 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)

Static methods(2)

Instance methods(56)

  • AssignCat(other: string): void

    Appends <other> to me.

    Parameters (1)
    • other
  • 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 ".

  • 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 = new TCollection_HAsciiString ("abcdef"); myAlphabet->Center(9,' '); assert ( !strcmp( myAlphabet->ToCString(), " abcdef ") );.

    Parameters (2)
    • Width
    • Filler
  • 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 = new TCollection_HAsciiString ("Hather"); myMistake->ChangeAll('H','F'); assert ( !strcmp( myMistake->ToCString(), "Father") );.

    Parameters (3)
    • aChar
    • NewChar
    • CaseSensitive
  • 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)
    • Set
    • FromIndex
    • ToIndex
  • 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)
    • Set
    • FromIndex
    • ToIndex
  • 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)
    • where
    • what
  • Insert(where: number, what: string): void

    Insert a HAsciiString at position <where>.

    Parameters (2)
    • where
    • what
  • Insert(where: number, what: TCollection_HAsciiString): void

    Insert a HAsciiString at position <where>.

    Parameters (2)
    • where
    • what
  • 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)
    • Index
    • other
  • 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)
    • Index
    • other
  • IsEmpty(): boolean

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

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

    Parameters (1)
    • other
  • 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.

  • Returns True if the string S not contains same characters than the string <me>.

    Parameters (1)
    • S
  • 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)
    • S
    • CaseSensitive
  • 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)
    • Width
    • Filler
  • 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)
    • other
    • FromIndex
    • ToIndex
  • 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)
    • N
    • C
    • FromIndex
    • ToIndex
  • LowerCase(): void

    Converts <me> to its lower-case equivalent.

  • 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)
    • C
    • CaseSensitive
  • 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)
    • where
    • ahowmany
  • 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)
    • Width
    • Filler
  • 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
  • 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
  • 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)
    • where
    • what
  • 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)
    • where
    • what
  • SetValue(where: number, what: TCollection_HAsciiString): void

    Replaces a part of <me> by another string.

    Parameters (2)
    • where
    • what
  • 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)
    • FromIndex
    • ToIndex
  • 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)
    • separators
    • whichone
  • 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.

  • Parameters (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)

Static methods(2)

Instance methods(25)

  • 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)
    • aChar
    • NewChar
  • 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)
    • where
    • what
  • Insert(where: number, what: TCollection_HExtendedString): void

    Insert a HExtendedString at position <where>.

    Parameters (2)
    • where
    • what
  • Returns TRUE if <me> is less than <other>.

    Parameters (1)
    • other
  • 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)
    • where
    • ahowmany
  • 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)
    • where
    • what
  • SetValue(where: number, what: TCollection_HExtendedString): void

    Replaces a part of <me> by another string.

    Parameters (2)
    • where
    • what
  • Splits a ExtendedString into two sub-strings. Example: aString contains "abcdefg" aString.Split(3) gives <me> = "abc" and returns "defg".

    Parameters (1)
    • where
  • 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)
    • separators
    • whichone
  • 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.

  • Parameters (1)
    • other