Changeset d161796fd1a9…
Parent e45e9f57b8ac…
by
Changes to 2 files · Browse files at d161796fd1a9 Showing diff from parent e45e9f57b8ac Diff from another changeset...
@@ -339,3 +339,19 @@ return true;
}
+
+void Tokenize(const std::string& str, std::vector<std::string>& tokens,
+ const std::string& delimiters)
+{
+ typedef std::string S;
+ S::size_type lastpos = str.find_first_not_of(delimiters, 0);
+ S::size_type pos = str.find_first_of(delimiters, lastpos);
+
+ while (S::npos != pos || S::npos != lastpos)
+ {
+ tokens.push_back(str.substr(lastpos, pos - lastpos));
+ lastpos = str.find_first_not_of(delimiters, pos);
+ pos = str.find_first_of(delimiters, lastpos);
+ }
+}
+
|
@@ -4,6 +4,7 @@ #include <malloc.h>
#include <windows.h>
#include <string>
+#include <vector>
#define _MBSTR(wstr) hf_wctomb((LPSTR)alloca(wcslen(wstr) + 1), (wstr),wcslen(wstr) + 1)
#define _WCSTR(str) hf_mbtowc((LPWSTR)alloca((strlen(str) + 1) * sizeof(WCHAR)),(str),strlen(str) + 1)
@@ -25,5 +26,7 @@int GetRegSZValue(HKEY hkey, const char* name, std::string& res);
int GetRegSZValueW(HKEY hkey, const wchar_t* name, std::wstring& res);
bool StartsWith(const std::string& a, const std::string& b);
+void Tokenize(const std::string& str, std::vector<std::string>& tokens,
+ const std::string& delimiters = " ");
#endif
|
Loading...