From d0a403fd99e000f32467f66fe898d785f30435eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Bj=C3=B6rk?= Date: Tue, 15 Feb 2011 14:34:14 +0100 Subject: CMake: Move tokenize to cmSystemTools --- Source/cmSourceGroupCommand.cxx | 33 +-------------------------------- Source/cmSystemTools.cxx | 32 ++++++++++++++++++++++++++++++++ Source/cmSystemTools.h | 3 +++ 3 files changed, 36 insertions(+), 32 deletions(-) diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx index 27d90db..22f4d47 100644 --- a/Source/cmSourceGroupCommand.cxx +++ b/Source/cmSourceGroupCommand.cxx @@ -11,37 +11,6 @@ ============================================================================*/ #include "cmSourceGroupCommand.h" -inline std::vector tokenize(const std::string& str, - const std::string& sep) -{ - std::vector tokens; - std::string::size_type tokend = 0; - - do - { - std::string::size_type tokstart=str.find_first_not_of(sep, tokend); - if (tokstart==std::string::npos) - { - break; // no more tokens - } - tokend=str.find_first_of(sep,tokstart); - if (tokend==std::string::npos) - { - tokens.push_back(str.substr(tokstart)); - } - else - { - tokens.push_back(str.substr(tokstart,tokend-tokstart)); - } - } while (tokend!=std::string::npos); - - if (tokens.empty()) - { - tokens.push_back(""); - } - return tokens; -} - // cmSourceGroupCommand bool cmSourceGroupCommand ::InitialPass(std::vector const& args, cmExecutionStatus &) @@ -58,7 +27,7 @@ bool cmSourceGroupCommand delimiter = this->Makefile->GetDefinition("SOURCE_GROUP_DELIMITER"); } - std::vector folders = tokenize(args[0], delimiter); + std::vector folders = cmSystemTools::tokenize(args[0], delimiter); cmSourceGroup* sg = 0; sg = this->Makefile->GetSourceGroup(folders); diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 7bc89a4..9341a4c 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -2833,3 +2833,35 @@ bool cmSystemTools::RepeatedRemoveDirectory(const char* dir) } return false; } + +//---------------------------------------------------------------------------- +std::vector cmSystemTools::tokenize(const std::string& str, + const std::string& sep) +{ + std::vector tokens; + std::string::size_type tokend = 0; + + do + { + std::string::size_type tokstart=str.find_first_not_of(sep, tokend); + if (tokstart==std::string::npos) + { + break; // no more tokens + } + tokend=str.find_first_of(sep,tokstart); + if (tokend==std::string::npos) + { + tokens.push_back(str.substr(tokstart)); + } + else + { + tokens.push_back(str.substr(tokstart,tokend-tokstart)); + } + } while (tokend!=std::string::npos); + + if (tokens.empty()) + { + tokens.push_back(""); + } + return tokens; +} diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 6f9147c..5b5c768 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -439,6 +439,9 @@ public: /** Remove a directory; repeat a few times in case of locked files. */ static bool RepeatedRemoveDirectory(const char* dir); + /** Tokenize a string */ + static std::vector tokenize(const std::string& str, + const std::string& sep); private: static bool s_ForceUnixPaths; static bool s_RunCommandHideConsole; -- cgit v0.12