str.cpp

changeset 60
961663d05463
parent 30
31ff9aabd506
child 104
6e29bb0e83c5
--- a/str.cpp	Thu Mar 21 13:00:44 2013 +0200
+++ b/str.cpp	Thu Mar 21 16:25:03 2013 +0200
@@ -473,7 +473,7 @@
 }
 
 // ============================================================================
-std::vector<str> str::split (str del) {
+std::vector<str> str::split (str del, bool bNoBlanks) {
 	std::vector<str> res;
 	unsigned int a = 0;
 	
@@ -484,12 +484,15 @@
 		if (b == -1)
 			break;
 		
-		res.push_back (substr (a, b));
+		if (!bNoBlanks || (b - a))
+			res.push_back (substr (a, b));
+		
 		a = b + strlen (del);
 	}
 	
 	// Add the string at the right of the last separator
-	res.push_back (substr (a, len()));
+	if (!bNoBlanks || (len () - a))
+		res.push_back (substr (a, len ()));
 	return res;
 }
 

mercurial