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

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

Issue 10897028: Create a shared dictionary class for plugin and engine (Closed)
Patch Set: Created June 7, 2013, 12:42 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>
5 #include <locale>
6 #include <functional>
4 #include <string> 7 #include <string>
5 8
6 std::string ToUtf8String(std::wstring str); 9 std::string ToUtf8String(const std::wstring& str);
10 std::wstring ToUtf16String(const std::string& str);
11 std::wstring GetDllDir();
7 std::wstring GetAppDataPath(); 12 std::wstring GetAppDataPath();
8 13
14 template<class T>
15 T TrimString(T text)
16 {
17 // Via http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-st dstring
18 T trimmed(text);
19 std::function<bool(T::value_type)> isspace = std::bind(&std::isspace<T::value_ type>, std::placeholders::_1, std::locale::classic());
20 trimmed.erase(trimmed.begin(), std::find_if(trimmed.begin(), trimmed.end(), st d::not1(isspace)));
21 trimmed.erase(std::find_if(trimmed.rbegin(), trimmed.rend(), std::not1(isspace )).base(), trimmed.end());
22 return trimmed;
23 }
24
9 #endif // UTILS_H 25 #endif // UTILS_H
OLDNEW
« src/shared/Dictionary.cpp ('K') | « src/shared/Dictionary.cpp ('k') | src/shared/Utils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld