company logo

StringList :: indexOf - Find a string

The function returns the index position of the first occurrence of the string value passed in cString in the string list by searching forward.

Comparison depends on the string coding type of the calling string. When encoding types between strings differ, a copy of cString is created and recoded to the encoding type of the current string.

When the string has been found,the function returns the position (relative 0) of string within the string list. When the search string could not be found, the function returns -1.

Return value:  Position in collection ( int32  )

The position of an element in a collection is beginning with 0 for the first element.

Implementation details

  1. Find string (case sensitive)
    int32 StringList  :: indexOf ( odaba::String &cString )

    The function searches the string passed in cString from the top of the string list. Comparison is case sensitive.

    • cString - Constant string object

      When iPosition exceeds the string length or when the string is empty, the the function returns -1 (lower).

  2. to list
  3. Find string
    int32 StringList  :: indexOf ( odaba::String &cString, bool bCaseSensitive )

    The function searches the string passed in cString from the top of the string list. .

    When bCaseSensitive is true (default), the search is case sensitive; otherwise the search is case insensitive.

    • cString - Constant string object

      When iPosition exceeds the string length or when the string is empty, the the function returns -1 (lower).

    • bCaseSensitive - Case sensitive option

      The option indicates case sensitive data in text (true)

  4. to list
  5. Find string at position (case sensitive)
    int32 StringList  :: indexOf ( odaba::String &cString, int32 iPosition, bool bCaseSensitive )

    The function searches the string passed in cString beginning at position iPosition. When the passed position is greater than the size of the string list (size()) the function returns -1 (not found). When iPosition is less than zero the function throws an exception.

    When bCaseSensitive is true (default), the search is case sensitive; otherwise the search is case insensitive.

    • cString - Constant string object

      When iPosition exceeds the string length or when the string is empty, the the function returns -1 (lower).

    • iPosition - Position in collection

      The position of an element in a collection is beginning with 0 for the first element.

    • bCaseSensitive - Case sensitive option

      The option indicates case sensitive data in text (true)

  6. to list
  7. Find string at position
    int32 StringList  :: indexOf ( odaba::String &cString, int32 iPosition )

    The function searches the string passed in cString beginning at position iPosition. When the passed position is greater than the size of the string list (size()) the function returns -1 (not found). When iPosition is less than zero the function throws an exception.

    The search is case insensitive.

    • cString - Constant string object

      When iPosition exceeds the string length or when the string is empty, the the function returns -1 (lower).

    • iPosition - Position in collection

      The position of an element in a collection is beginning with 0 for the first element.

  8. to list