diff options
Diffstat (limited to 'src/Fl_String.cxx')
| -rw-r--r-- | src/Fl_String.cxx | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/Fl_String.cxx b/src/Fl_String.cxx index 693a88286..e285519ff 100644 --- a/src/Fl_String.cxx +++ b/src/Fl_String.cxx @@ -466,6 +466,21 @@ Fl_String &Fl_String::operator+=(char c) { } /** + Find a string inside this string. + \param[in] needle find this string + \param[in] start_pos start looking at this position + \return the offset of the text inside this string, if it was found + \return Fl_String::npos if the needle was not found + */ +int Fl_String::find(const Fl_String &needle, int start_pos) const { + if ((start_pos < 0) || (start_pos >= size_)) return npos; + const char *haystack = data() + start_pos; + const char *found = strstr(haystack, needle.c_str()); + if (!found) return npos; + return (int)(found - data()); +} + +/** Replace part of the string with a C-style string or data. \param[in] at erase and insert at this index \param[in] n_del number of bytes to erase |
