From 8c41befcea4aba66fa9312191740a012ca78b588 Mon Sep 17 00:00:00 2001 From: Sascha Volkenandt Date: Fri, 5 Jan 2007 12:37:47 +0000 Subject: - added function StringReplace --- pagelib/tools.cpp | 11 +++++++++++ pagelib/tools.h | 1 + 2 files changed, 12 insertions(+) (limited to 'pagelib') diff --git a/pagelib/tools.cpp b/pagelib/tools.cpp index aeaba36..e1d9a03 100644 --- a/pagelib/tools.cpp +++ b/pagelib/tools.cpp @@ -26,4 +26,15 @@ string FormatDateTime( char const* format, time_t time ) return result; } +string StringReplace( string const& text, string const& substring, string const& replacement ) +{ + string result = text; + string::size_type pos = 0; + while ( ( pos = result.find( substring, pos ) ) != string::npos ) { + result.replace( pos, substring.length(), replacement ); + pos += replacement.length(); + } + return result; +} + } diff --git a/pagelib/tools.h b/pagelib/tools.h index f9eb33a..c39075b 100644 --- a/pagelib/tools.h +++ b/pagelib/tools.h @@ -8,6 +8,7 @@ namespace vdrlive { std::string FormatDateTime( char const* format, time_t time ); +std::string StringReplace( std::string const& text, std::string const& substring, std::string const& replacement ); class ReadLock { -- cgit v1.2.3