From 8d278564f8350647964b5b9ccf3a6183ac7e2f0e Mon Sep 17 00:00:00 2001 From: Sascha Volkenandt Date: Fri, 5 Jan 2007 19:55:13 +0000 Subject: - added function StringSplit --- tools.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tools.cpp') 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; +} + } -- cgit v1.2.3