vlc | branch: master | Francois Cartegnie <[email protected]> | Sun Aug 2 16:22:59 2015 +0200| [cf3b1cf58452b0343803c57c4aad96bc49541af5] | committer: Francois Cartegnie
demux: adaptative: add tokenizer helper > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=cf3b1cf58452b0343803c57c4aad96bc49541af5 --- modules/demux/adaptative/tools/Helper.cpp | 16 ++++++++++++++++ modules/demux/adaptative/tools/Helper.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/modules/demux/adaptative/tools/Helper.cpp b/modules/demux/adaptative/tools/Helper.cpp index 40e10c6..435df4c 100644 --- a/modules/demux/adaptative/tools/Helper.cpp +++ b/modules/demux/adaptative/tools/Helper.cpp @@ -60,3 +60,19 @@ bool Helper::ifind(std::string haystack, std::string needle) transform(needle.begin(), needle.end(), needle.begin(), toupper); return haystack.find(needle) != std::string::npos; } + +std::list<std::string> Helper::tokenize(const std::string &str, char c) +{ + std::list<std::string> ret; + std::size_t prev = 0; + std::size_t cur = str.find_first_of(c, 0); + while(cur != std::string::npos) + { + ret.push_back(str.substr(prev, cur - prev)); + prev = cur + 1; + cur = str.find_first_of(c, cur + 1); + } + + ret.push_back(str.substr(prev)); + return ret; +} diff --git a/modules/demux/adaptative/tools/Helper.h b/modules/demux/adaptative/tools/Helper.h index 20357b2..24a6e92 100644 --- a/modules/demux/adaptative/tools/Helper.h +++ b/modules/demux/adaptative/tools/Helper.h @@ -26,6 +26,7 @@ #define HELPER_H_ #include <string> +#include <list> namespace adaptative { @@ -35,6 +36,7 @@ namespace adaptative static std::string combinePaths (const std::string &path1, const std::string &path2); static std::string getDirectoryPath (const std::string &path); static bool ifind (std::string haystack, std::string needle); + static std::list<std::string> tokenize(const std::string &, char); }; } _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
