summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas "Pixel" Noble <pixel@nobis-crew.org>2014-06-17 01:05:58 -0700
committerNicolas "Pixel" Noble <pixel@nobis-crew.org>2014-06-17 01:05:58 -0700
commitdcc119c81ff77a08b8fbef30c17d8053143a765c (patch)
tree6033907722e59b75b266d0f4db1013ac613e4591
parent519d57deadc46bd5b48b37cd1a28882425d8e204 (diff)
Adding replace_all to Balau::String.
-rw-r--r--includes/BString.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/includes/BString.h b/includes/BString.h
index 392f720..a321a30 100644
--- a/includes/BString.h
+++ b/includes/BString.h
@@ -11,6 +11,7 @@
#include <stdlib.h>
#include <string>
#include <vector>
+#include <algorithm>
#ifdef _MSC_VER
#ifdef _WIN64
@@ -86,6 +87,7 @@ class String : private std::string {
String lower() const { String c = *this; return c.do_lower(); }
String iconv(const String & from, const String & to) const { String c = *this; c.do_iconv(from.to_charp(), to.to_charp()); return c; }
String iconv(const char * from, const char * to) const { String c = *this; c.do_iconv(from, to); return c; }
+ String replace_all(char from, char to) const { String c = *this; c.do_replace_all(from, to); return c; }
String & do_ltrim();
String & do_rtrim();
@@ -94,6 +96,7 @@ class String : private std::string {
String & do_lower();
String & do_iconv(const String & from, const String & to) { return do_iconv(from.to_charp(), to.to_charp()); }
String & do_iconv(const char * from, const char * to);
+ String & do_replace_all(char from, char to) { std::replace(begin(), end(), from, to); return *this; }
String & operator=(const String & v) { *((std::string *) this) = std::string::assign(v); return *this; }
String & operator=(const char * v) { *((std::string *) this) = std::string::assign(v); return *this; }