summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools.cpp13
-rw-r--r--tools.h2
2 files changed, 15 insertions, 0 deletions
diff --git a/tools.cpp b/tools.cpp
index e1d9a03..d30183f 100644
--- a/tools.cpp
+++ b/tools.cpp
@@ -37,4 +37,17 @@ string StringReplace( string const& text, string const& substring, string const&
return result;
}
+vector< string > StringSplit( string const& text, char delimiter )
+{
+ vector< string > result;
+ string::size_type last = 0, pos;
+ while ( ( pos = text.find( delimiter, last ) ) != string::npos ) {
+ result.push_back( text.substr( last, pos - last ) );
+ last = pos + 1;
+ }
+ if ( last < text.length() )
+ result.push_back( text.substr( last ) );
+ return result;
+}
+
}
diff --git a/tools.h b/tools.h
index c39075b..3b195dd 100644
--- a/tools.h
+++ b/tools.h
@@ -3,12 +3,14 @@
#include <ctime>
#include <string>
+#include <vector>
#include <vdr/thread.h>
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 );
+std::vector< std::string > StringSplit( std::string const& text, char delimiter );
class ReadLock
{