OLD | NEW |
1 #ifndef UTILS_H | 1 #ifndef UTILS_H |
2 #define UTILS_H | 2 #define UTILS_H |
3 | 3 |
4 #include <algorithm> | 4 #include <algorithm> |
5 #include <locale> | 5 #include <locale> |
6 #include <functional> | 6 #include <functional> |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #define WM_ALREADY_UP_TO_DATE WM_APP+1 | 9 #define WM_ALREADY_UP_TO_DATE WM_APP+1 |
10 #define WM_UPDATE_CHECK_ERROR WM_APP+2 | 10 #define WM_UPDATE_CHECK_ERROR WM_APP+2 |
11 #define WM_DOWNLOADING_UPDATE WM_APP+3 | 11 #define WM_DOWNLOADING_UPDATE WM_APP+3 |
12 | 12 |
| 13 // |
| 14 // Application Package Authority. |
| 15 // |
| 16 |
| 17 #define SECURITY_APP_PACKAGE_AUTHORITY {0,0,0,0,0,15} |
| 18 |
| 19 #define SECURITY_APP_PACKAGE_BASE_RID (0x00000002L) |
| 20 #define SECURITY_BUILTIN_APP_PACKAGE_RID_COUNT (2L) |
| 21 #define SECURITY_APP_PACKAGE_RID_COUNT (8L) |
| 22 #define SECURITY_CAPABILITY_BASE_RID (0x00000003L) |
| 23 #define SECURITY_BUILTIN_CAPABILITY_RID_COUNT (2L) |
| 24 #define SECURITY_CAPABILITY_RID_COUNT (5L) |
| 25 |
| 26 // |
| 27 // Built-in Packages. |
| 28 // |
| 29 |
| 30 #define SECURITY_BUILTIN_PACKAGE_ANY_PACKAGE (0x00000001L) |
| 31 |
| 32 |
13 bool IsWindowsVistaOrLater(); | 33 bool IsWindowsVistaOrLater(); |
| 34 bool IsAppContainersSupported(); |
14 | 35 |
15 std::string ToUtf8String(const std::wstring& str); | 36 std::string ToUtf8String(const std::wstring& str); |
16 std::wstring ToUtf16String(const std::string& str); | 37 std::wstring ToUtf16String(const std::string& str); |
17 std::wstring GetDllDir(); | 38 std::wstring GetDllDir(); |
18 std::wstring GetAppDataPath(); | 39 std::wstring GetAppDataPath(); |
19 void ReplaceString(std::wstring& input, const std::wstring placeholder, const st
d::wstring replacement); | 40 void ReplaceString(std::wstring& input, const std::wstring placeholder, const st
d::wstring replacement); |
20 | 41 |
21 template<class T> | 42 template<class T> |
22 T TrimString(T text) | 43 T TrimString(T text) |
23 { | 44 { |
24 // Via http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-st
dstring | 45 // Via http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-st
dstring |
25 T trimmed(text); | 46 T trimmed(text); |
26 std::function<bool(T::value_type)> isspace = std::bind(&std::isspace<T::value_
type>, std::placeholders::_1, std::locale::classic()); | 47 std::function<bool(T::value_type)> isspace = std::bind(&std::isspace<T::value_
type>, std::placeholders::_1, std::locale::classic()); |
27 trimmed.erase(trimmed.begin(), std::find_if(trimmed.begin(), trimmed.end(), st
d::not1(isspace))); | 48 trimmed.erase(trimmed.begin(), std::find_if(trimmed.begin(), trimmed.end(), st
d::not1(isspace))); |
28 trimmed.erase(std::find_if(trimmed.rbegin(), trimmed.rend(), std::not1(isspace
)).base(), trimmed.end()); | 49 trimmed.erase(std::find_if(trimmed.rbegin(), trimmed.rend(), std::not1(isspace
)).base(), trimmed.end()); |
29 return trimmed; | 50 return trimmed; |
30 } | 51 } |
31 | 52 |
32 #endif // UTILS_H | 53 #endif // UTILS_H |
OLD | NEW |