summaryrefslogtreecommitdiff
path: root/lib/mystring/find_last_of.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mystring/find_last_of.cc')
-rw-r--r--lib/mystring/find_last_of.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/mystring/find_last_of.cc b/lib/mystring/find_last_of.cc
new file mode 100644
index 0000000..b8f8831
--- /dev/null
+++ b/lib/mystring/find_last_of.cc
@@ -0,0 +1,24 @@
+#include "mystring.h"
+#include <string.h>
+
+int mystring::find_last_of(const char* setstr, size_t setlen,
+ size_t offset) const
+{
+ if(offset == (size_t)-1)
+ offset = rep->length-1;
+ for(int i = offset; i >= 0; --i) {
+ if(memchr(setstr, rep->buf[i], setlen))
+ return i;
+ }
+ return -1;
+}
+
+int mystring::find_last_of(const char* setstr, size_t offset) const
+{
+ return find_last_of(setstr, strlen(setstr), offset);
+}
+
+int mystring::find_last_of(const mystring& setstr, size_t offset) const
+{
+ return find_last_of(setstr.rep->buf, setstr.rep->length, offset);
+}