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

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

Issue 11276031: FRP wrappers. "Update" menu item. (Closed)
Patch Set: GetAppLocale is now retrieved directly from the browser. Get documentation link change. Manual Upda… Created Aug. 5, 2013, 8:03 a.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 9
10 bool IsWindowsVistaOrLater(); 10 bool IsWindowsVistaOrLater();
11 11
12 std::string ToUtf8String(const std::wstring& str); 12 std::string ToUtf8String(const std::wstring& str);
13 std::wstring ToUtf16String(const std::string& str); 13 std::wstring ToUtf16String(const std::string& str);
14 std::wstring GetDllDir(); 14 std::wstring GetDllDir();
15 std::wstring GetAppDataPath(); 15 std::wstring GetAppDataPath();
16 void ReplaceString(std::wstring& input, const std::wstring placeholder, const st d::wstring replacement);
16 17
17 template<class T> 18 template<class T>
18 T TrimString(T text) 19 T TrimString(T text)
19 { 20 {
20 // Via http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-st dstring 21 // Via http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-st dstring
21 T trimmed(text); 22 T trimmed(text);
22 std::function<bool(T::value_type)> isspace = std::bind(&std::isspace<T::value_ type>, std::placeholders::_1, std::locale::classic()); 23 std::function<bool(T::value_type)> isspace = std::bind(&std::isspace<T::value_ type>, std::placeholders::_1, std::locale::classic());
23 trimmed.erase(trimmed.begin(), std::find_if(trimmed.begin(), trimmed.end(), st d::not1(isspace))); 24 trimmed.erase(trimmed.begin(), std::find_if(trimmed.begin(), trimmed.end(), st d::not1(isspace)));
24 trimmed.erase(std::find_if(trimmed.rbegin(), trimmed.rend(), std::not1(isspace )).base(), trimmed.end()); 25 trimmed.erase(std::find_if(trimmed.rbegin(), trimmed.rend(), std::not1(isspace )).base(), trimmed.end());
25 return trimmed; 26 return trimmed;
26 } 27 }
27 28
28 #endif // UTILS_H 29 #endif // UTILS_H
OLDNEW
« src/plugin/PluginClass.cpp ('K') | « src/plugin/Resource.h ('k') | src/shared/Utils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld