summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuo Jinghua <sunmoon1997@gmail.com>2011-11-19 20:36:51 +0800
committerLuo Jinghua <sunmoon1997@gmail.com>2011-11-19 20:36:51 +0800
commit739782259fb31d1b56fa6a688857a21566374e1a (patch)
tree3ee1a447bb160b6efc6d4bfa48f468f5d127aafa
parent21df76991789e2177cfc57f399fcfa34fa695c4e (diff)
SexyAppFramework: Added Split() to Common
-rw-r--r--osframework/source/SexyAppFramework/Common.cpp21
-rw-r--r--osframework/source/SexyAppFramework/Common.h2
2 files changed, 23 insertions, 0 deletions
diff --git a/osframework/source/SexyAppFramework/Common.cpp b/osframework/source/SexyAppFramework/Common.cpp
index fd11918..7947763 100644
--- a/osframework/source/SexyAppFramework/Common.cpp
+++ b/osframework/source/SexyAppFramework/Common.cpp
@@ -1377,3 +1377,24 @@ int Sexy::GetEnvIntOption(const char *option, int value)
return atoi(s);
return value;
}
+
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+void Sexy::Split(const std::string& s, const std::string& delim,
+ std::vector<std::string>& ret)
+{
+ size_t last = 0;
+ size_t index = s.find_first_of(delim, last);
+
+ while (index != std::string::npos)
+ {
+ ret.push_back(s.substr(last, index - last));
+ last = index + 1;
+ index = s.find_first_of(delim, last);
+ }
+ if (index - last > 0)
+ {
+ ret.push_back(s.substr(last, index-last));
+ }
+}
+
diff --git a/osframework/source/SexyAppFramework/Common.h b/osframework/source/SexyAppFramework/Common.h
index ed4cd35..96b974c 100644
--- a/osframework/source/SexyAppFramework/Common.h
+++ b/osframework/source/SexyAppFramework/Common.h
@@ -198,6 +198,8 @@ namespace Sexy
const char* GetEnv(const char* name);
bool GetEnvOption(const char *option, bool value = false);
int GetEnvIntOption(const char *option, int value = 0);
+ void Split(const std::string& s, const std::string& delim,
+ std::vector<std::string>& ret);
inline void inlineUpper(std::string &theData)
{