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

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

Issue 5921969115496448: Issue 1115 - Some yahoo page not correctly shown on IE8 when ABP enabled (Closed)
Patch Set: x Created Jan. 29, 2015, 3:23 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 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 49
50 bool IsWindowsVistaOrLater(); 50 bool IsWindowsVistaOrLater();
51 bool IsWindows8OrLater(); 51 bool IsWindows8OrLater();
52 52
53 std::string ToUtf8String(const std::wstring& str); 53 std::string ToUtf8String(const std::wstring& str);
54 std::wstring ToUtf16String(const std::string& str); 54 std::wstring ToUtf16String(const std::string& str);
55 std::wstring GetDllDir(); 55 std::wstring GetDllDir();
56 std::wstring GetAppDataPath(); 56 std::wstring GetAppDataPath();
57 void ReplaceString(std::wstring& input, const std::wstring placeholder, const st d::wstring replacement); 57 void ReplaceString(std::wstring& input, const std::wstring placeholder, const st d::wstring replacement);
58 std::wstring GetQueryString(const std::wstring& url);
59 /// Splits the string using delimiter
Eric 2015/02/02 18:41:58 Might as well use a doxygen-style comment here.
sergei 2015/02/12 14:44:06 fixed. BTW, it's not necessary to have additional
Eric 2015/02/12 17:24:41 Minimizing whitespace is not always a virtue. I fi
60 void SplitString(const std::wstring& value, wchar_t delimiter,
61 const std::function<bool(std::wstring::const_iterator begin, std::wstring::con st_iterator end)>& tokenHandler);
62 /// For each parameter in the query string the function calls parameterHandler
63 /// until it returns false.
Eric 2015/02/02 18:41:58 /** * Applies a function to each name=value pair
sergei 2015/02/12 14:44:06 done
64 void ProcessQueryStringParameters(const std::wstring& urlQueryString,
65 const std::function<bool(const std::wstring& name, const std::wstring& value)> & parameterHandler);
58 66
59 template<class T> 67 template<class T>
60 T TrimString(T text) 68 T TrimString(T text)
61 { 69 {
62 // Via http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-st dstring 70 // Via http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-st dstring
63 T trimmed(text); 71 T trimmed(text);
64 std::function<bool(T::value_type)> isspace = std::bind(&std::isspace<T::value_ type>, std::placeholders::_1, std::locale::classic()); 72 std::function<bool(T::value_type)> isspace = std::bind(&std::isspace<T::value_ type>, std::placeholders::_1, std::locale::classic());
65 trimmed.erase(trimmed.begin(), std::find_if(trimmed.begin(), trimmed.end(), st d::not1(isspace))); 73 trimmed.erase(trimmed.begin(), std::find_if(trimmed.begin(), trimmed.end(), st d::not1(isspace)));
66 trimmed.erase(std::find_if(trimmed.rbegin(), trimmed.rend(), std::not1(isspace )).base(), trimmed.end()); 74 trimmed.erase(std::find_if(trimmed.rbegin(), trimmed.rend(), std::not1(isspace )).base(), trimmed.end());
67 return trimmed; 75 return trimmed;
68 } 76 }
69 77
70 #endif // UTILS_H 78 #endif // UTILS_H
OLDNEW

Powered by Google App Engine
This is Rietveld