From 46108978fb72b40c7feeb52c2a7abbd437f8751d Mon Sep 17 00:00:00 2001 From: ghost Date: Tue, 17 Feb 2009 00:35:44 +0100 Subject: [PATCH 1/1] move replace_all function to base/string.h --- lib/base/estring.cpp | 9 +++++++++ lib/base/estring.h | 1 + lib/gui/esubtitle.cpp | 9 --------- lib/gui/esubtitle.h | 1 - 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/base/estring.cpp b/lib/base/estring.cpp index 5d15ddce..f1d50ccc 100644 --- a/lib/base/estring.cpp +++ b/lib/base/estring.cpp @@ -633,3 +633,12 @@ void makeUpper(std::string &s) { std::transform(s.begin(), s.end(), s.begin(), (int(*)(int)) toupper); } + +std::string replace_all(const std::string &in, const std::string &entity, const std::string &symbol) +{ + std::string out = in; + std::string::size_type loc = 0; + while (( loc = out.find(entity, loc)) != std::string::npos ) + out.replace(loc, entity.length(), symbol); + return out; +} diff --git a/lib/base/estring.h b/lib/base/estring.h index 68e0970f..d61489eb 100644 --- a/lib/base/estring.h +++ b/lib/base/estring.h @@ -18,6 +18,7 @@ int isUTF8(const std::string &string); std::string removeDVBChars(const std::string &s); void makeUpper(std::string &s); +std::string replace_all(const std::string &in, const std::string &entity, const std::string &symbol); inline std::string convertDVBUTF8(const std::string &string, int table=0, int tsidonid=0) // with default ISO8859-1/Latin1 { diff --git a/lib/gui/esubtitle.cpp b/lib/gui/esubtitle.cpp index 085a749a..ca5c20d7 100644 --- a/lib/gui/esubtitle.cpp +++ b/lib/gui/esubtitle.cpp @@ -114,15 +114,6 @@ void eSubtitleWidget::setPixmap(ePtr &pixmap, gRegion changed) invalidate(changed); } -std::string eSubtitleWidget::replace_all(const std::string &in, const std::string &entity, const std::string &symbol) -{ - std::string out = in; - std::string::size_type loc = 0; - while (( loc = out.find(entity, loc)) != std::string::npos ) - out.replace(loc, entity.length(), symbol); - return out; -} - int eSubtitleWidget::event(int event, void *data, void *data2) { switch (event) diff --git a/lib/gui/esubtitle.h b/lib/gui/esubtitle.h index 1635e6de..c88df0e6 100644 --- a/lib/gui/esubtitle.h +++ b/lib/gui/esubtitle.h @@ -58,7 +58,6 @@ private: gRegion m_visible_region; ePtr m_pixmap; // pixmap to paint on next evtPaint - std::string replace_all(const std::string &in, const std::string &entity, const std::string &symbol); }; #endif -- 2.30.2