PageRenderTime 35ms CodeModel.GetById 26ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

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