/win32/shellext/TortoiseUtils.h

https://bitbucket.org/tortoisehg/hgtk/ · C Header · 42 lines · 36 code · 6 blank · 0 comment · 4 complexity · eb29bc6e9cdbfe2abb2d8dfd3c046eda MD5 · raw file

  1. #ifndef _TORTOISE_UTILS_H_
  2. #define _TORTOISE_UTILS_H_
  3. #include <malloc.h>
  4. #include <windows.h>
  5. #include <string>
  6. #include <vector>
  7. #define _MBSTR(wstr) hf_wctomb((LPSTR)alloca(wcslen(wstr) + 1), (wstr),wcslen(wstr) + 1)
  8. #define _WCSTR(str) hf_mbtowc((LPWSTR)alloca((strlen(str) + 1) * sizeof(WCHAR)),(str),strlen(str) + 1)
  9. LPWSTR hf_mbtowc(LPWSTR lpw, LPCSTR lpa, int nChars);
  10. LPSTR hf_wctomb(LPSTR lpa, LPCWSTR lpw, int nChars);
  11. std::string GetTHgProgRoot();
  12. std::string GetTemporaryFile(LPCSTR prefix="THG");
  13. bool IsDirectory(const std::string&);
  14. std::string DirName(const std::string&);
  15. std::string BaseName(const std::string&);
  16. bool LaunchCommand(const std::string& command, const std::string& cwd);
  17. HICON GetTortoiseIcon(const std::string & iconname);
  18. std::string GetHgRepoRoot(const std::string& path);
  19. bool IsHgRepo(const std::string& path);
  20. FILE* fopenReadRenameAllowed(const char* path);
  21. int GetRegSZValue(HKEY hkey, const char* name, std::string& res);
  22. int GetRegSZValueW(HKEY hkey, const wchar_t* name, std::wstring& res);
  23. bool StartsWith(const std::string& a, const std::string& b);
  24. void Tokenize(const std::string& str, std::vector<std::string>& tokens,
  25. const std::string& delimiters = " ");
  26. template <typename C, typename T>
  27. bool contains(const C& c, const T& t)
  28. {
  29. for (C::const_iterator i = c.begin(); i != c.end(); ++i)
  30. {
  31. if (*i == t)
  32. return true;
  33. }
  34. return false;
  35. }
  36. #endif