sources/mystring.cpp

changeset 110
cad1163333b9
parent 109
e4966d7e615d
child 129
a556ce001e26
--- a/sources/mystring.cpp	Sat Jan 09 18:09:32 2016 +0200
+++ b/sources/mystring.cpp	Sun Jan 10 19:38:11 2016 +0200
@@ -54,7 +54,19 @@
 
 // -------------------------------------------------------------------------------------------------
 //
-String String::strip (const List<char>& unwanted)
+String String::strip (char unwanted) const
+{
+	String result (m_string);
+
+	for (int pos = 0; (pos = result.find (unwanted)) != -1;)
+		result.remove_at (pos--);
+
+	return result;
+}
+
+// -------------------------------------------------------------------------------------------------
+//
+String String::strip (const List<char>& unwanted) const
 {
 	String result (m_string);
 
@@ -221,6 +233,18 @@
 
 // -------------------------------------------------------------------------------------------------
 //
+int String::find (char ch, int a) const
+{
+	int pos = m_string.find (ch, a);
+
+	if (pos == int (std::string::npos))
+		return -1;
+
+	return pos;
+}
+
+// -------------------------------------------------------------------------------------------------
+//
 int String::find_last (const char* c, int a) const
 {
 	if (a == -1 or a >= length())

mercurial