Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.0, 1.0.1, and 1.0.2

shellext: add new Tokenize function to TortoiseUtils

Changeset d161796fd1a9

Parent e45e9f57b8ac

by Adrian Buehlmann

Changes to 2 files · Browse files at d161796fd1a9 Showing diff from parent e45e9f57b8ac Diff from another changeset...

 
339
340
341
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
@@ -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
5
6
 
7
8
9
 
25
26
27
 
 
28
29
 
4
5
6
7
8
9
10
 
26
27
28
29
30
31
32
@@ -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