Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/shared/Utils.h

Issue 6308231068516352: Fix issues with security tokens (Enhanced Protected Mode, Protected Mode etc) (Closed)
Patch Set: Created Nov. 15, 2013, 7:22 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
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 bool IsWindowsVistaOrLater(); 13 bool IsWindowsVistaOrLater();
14 bool IsWindows8();
14 15
15 std::string ToUtf8String(const std::wstring& str); 16 std::string ToUtf8String(const std::wstring& str);
16 std::wstring ToUtf16String(const std::string& str); 17 std::wstring ToUtf16String(const std::string& str);
17 std::wstring GetDllDir(); 18 std::wstring GetDllDir();
18 std::wstring GetAppDataPath(); 19 std::wstring GetAppDataPath();
19 void ReplaceString(std::wstring& input, const std::wstring placeholder, const st d::wstring replacement); 20 void ReplaceString(std::wstring& input, const std::wstring placeholder, const st d::wstring replacement);
20 21
21 template<class T> 22 template<class T>
22 T TrimString(T text) 23 T TrimString(T text)
23 { 24 {
24 // Via http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-st dstring 25 // Via http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-st dstring
25 T trimmed(text); 26 T trimmed(text);
26 std::function<bool(T::value_type)> isspace = std::bind(&std::isspace<T::value_ type>, std::placeholders::_1, std::locale::classic()); 27 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))); 28 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()); 29 trimmed.erase(std::find_if(trimmed.rbegin(), trimmed.rend(), std::not1(isspace )).base(), trimmed.end());
29 return trimmed; 30 return trimmed;
30 } 31 }
31 32
32 #endif // UTILS_H 33 #endif // UTILS_H
OLDNEW

Powered by Google App Engine
This is Rietveld