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

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

Issue 11427013: Appear fast for IE (Closed)
Left Patch Set: Created Aug. 7, 2013, 5:44 a.m.
Right Patch Set: Comments addressed Created Aug. 7, 2013, 4:01 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
« src/plugin/PluginTabBase.cpp ('K') | « src/plugin/PluginTabBase.cpp ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
9 8
10 bool IsWindowsVistaOrLater(); 9 bool IsWindowsVistaOrLater();
11 10
12 std::string ToUtf8String(const std::wstring& str); 11 std::string ToUtf8String(const std::wstring& str);
13 std::wstring ToUtf16String(const std::string& str); 12 std::wstring ToUtf16String(const std::string& str);
14 std::wstring GetDllDir(); 13 std::wstring GetDllDir();
15 std::wstring GetAppDataPath(); 14 std::wstring GetAppDataPath();
16 void ReplaceString(std::wstring& input, const std::wstring placeholder, const st d::wstring replacement); 15 void ReplaceString(std::wstring& input, const std::wstring placeholder, const st d::wstring replacement);
17 16
18 template<class T> 17 template<class T>
19 T TrimString(T text) 18 T TrimString(T text)
20 { 19 {
21 // Via http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-st dstring 20 // Via http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-st dstring
22 T trimmed(text); 21 T trimmed(text);
23 std::function<bool(T::value_type)> isspace = std::bind(&std::isspace<T::value_ type>, std::placeholders::_1, std::locale::classic()); 22 std::function<bool(T::value_type)> isspace = std::bind(&std::isspace<T::value_ type>, std::placeholders::_1, std::locale::classic());
24 trimmed.erase(trimmed.begin(), std::find_if(trimmed.begin(), trimmed.end(), st d::not1(isspace))); 23 trimmed.erase(trimmed.begin(), std::find_if(trimmed.begin(), trimmed.end(), st d::not1(isspace)));
25 trimmed.erase(std::find_if(trimmed.rbegin(), trimmed.rend(), std::not1(isspace )).base(), trimmed.end()); 24 trimmed.erase(std::find_if(trimmed.rbegin(), trimmed.rend(), std::not1(isspace )).base(), trimmed.end());
26 return trimmed; 25 return trimmed;
27 } 26 }
28 27
29 #endif // UTILS_H 28 #endif // UTILS_H
LEFTRIGHT

Powered by Google App Engine
This is Rietveld