Logo Search packages:      
Sourcecode: osb-jscore version File versions  Download package

int KJS::UString::find ( const UString f,
int  pos = 0 
) const

Returns:
Position of first occurrence of f starting at position pos. -1 if the search was not successful.

Definition at line 989 of file ustring.cpp.

References data(), and size().

{
  int sz = size();
  int fsz = f.size();
  if (sz < fsz)
    return -1;
  if (pos < 0)
    pos = 0;
  if (fsz == 0)
    return pos;
  const UChar *end = data() + sz - fsz;
  long fsizeminusone = (fsz - 1) * sizeof(UChar);
  const UChar *fdata = f.data();
  for (const UChar *c = data() + pos; c <= end; c++)
    if (*c == *fdata && !memcmp(c + 1, fdata + 1, fsizeminusone))
      return (c-data());

  return -1;
}


Generated by  Doxygen 1.6.0   Back to index