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

Delta Between Two Patch Sets: src/shared/Utils.h

Issue 4806567450902528: Issue 1794 - add handling of std::vector<std::string> by Communication::{Input,Output}Buffer (Closed)
Left Patch Set: change tests Created Jan. 27, 2015, 3:27 p.m.
Right Patch Set: remove WriteStrings and ReadStrings Created Feb. 9, 2015, 2:04 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Right: Side by side diff | Download
LEFTRIGHT
(no file at all)
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 #include <vector>
8 9
9 #define WM_ALREADY_UP_TO_DATE WM_APP+1 10 #define WM_ALREADY_UP_TO_DATE WM_APP+1
10 #define WM_UPDATE_CHECK_ERROR WM_APP+2 11 #define WM_UPDATE_CHECK_ERROR WM_APP+2
11 #define WM_DOWNLOADING_UPDATE WM_APP+3 12 #define WM_DOWNLOADING_UPDATE WM_APP+3
12 13
13 // 14 //
14 // Application Package Authority. 15 // Application Package Authority.
15 // 16 //
16 17
17 #define SECURITY_APP_PACKAGE_AUTHORITY {0,0,0,0,0,15} 18 #define SECURITY_APP_PACKAGE_AUTHORITY {0,0,0,0,0,15}
(...skipping 10 matching lines...) Expand all
28 // 29 //
29 30
30 #define SECURITY_BUILTIN_PACKAGE_ANY_PACKAGE (0x00000001L) 31 #define SECURITY_BUILTIN_PACKAGE_ANY_PACKAGE (0x00000001L)
31 32
32 33
33 bool IsWindowsVistaOrLater(); 34 bool IsWindowsVistaOrLater();
34 bool IsWindows8OrLater(); 35 bool IsWindows8OrLater();
35 36
36 std::string ToUtf8String(const std::wstring& str); 37 std::string ToUtf8String(const std::wstring& str);
37 std::wstring ToUtf16String(const std::string& str); 38 std::wstring ToUtf16String(const std::string& str);
39 std::vector<std::wstring> ToUtf16Strings(const std::vector<std::string>& value);
Eric 2015/02/09 16:18:57 Where's the other half of the pair ToUtf8Strings?
sergei 2015/02/09 16:55:37 We don't need, it would be a dead code.
38 std::wstring GetDllDir(); 40 std::wstring GetDllDir();
39 std::wstring GetAppDataPath(); 41 std::wstring GetAppDataPath();
40 void ReplaceString(std::wstring& input, const std::wstring placeholder, const st d::wstring replacement); 42 void ReplaceString(std::wstring& input, const std::wstring placeholder, const st d::wstring replacement);
41 43
42 template<class T> 44 template<class T>
43 T TrimString(T text) 45 T TrimString(T text)
44 { 46 {
45 // Via http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-st dstring 47 // Via http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-st dstring
46 T trimmed(text); 48 T trimmed(text);
47 std::function<bool(T::value_type)> isspace = std::bind(&std::isspace<T::value_ type>, std::placeholders::_1, std::locale::classic()); 49 std::function<bool(T::value_type)> isspace = std::bind(&std::isspace<T::value_ type>, std::placeholders::_1, std::locale::classic());
48 trimmed.erase(trimmed.begin(), std::find_if(trimmed.begin(), trimmed.end(), st d::not1(isspace))); 50 trimmed.erase(trimmed.begin(), std::find_if(trimmed.begin(), trimmed.end(), st d::not1(isspace)));
49 trimmed.erase(std::find_if(trimmed.rbegin(), trimmed.rend(), std::not1(isspace )).base(), trimmed.end()); 51 trimmed.erase(std::find_if(trimmed.rbegin(), trimmed.rend(), std::not1(isspace )).base(), trimmed.end());
50 return trimmed; 52 return trimmed;
51 } 53 }
52 54
53 #endif // UTILS_H 55 #endif // UTILS_H
LEFTRIGHT

Powered by Google App Engine
This is Rietveld