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: address comments Created Feb. 13, 2015, 3:19 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 58
59 /**
60 * Returns the begging of the URL which includes the scheme and hierarchical
61 * part according to http://en.wikipedia.org/wiki/URI_scheme .
62 */
63 std::wstring GetSchemeAndHierarchicalPart(const std::wstring& url);
64
65 std::wstring GetQueryString(const std::wstring& url);
66 /**
67 * Splits a string into tokens separated by a delimiter.
68 * Applies a function to each token.
69 * Terminates early if the function returns false.
70 * Throws if `fn` is empty, see the reference of std::function::operator().
71 */
72 void ForEachToken(const std::wstring& value, wchar_t delimiter,
73 const std::function<bool(std::wstring::const_iterator begin, std::wstring::con st_iterator end)>& fn);
74
75 /**
76 * Applies a function to each name=value pair in a query string.
77 * Terminates early if the function returns false.
78 * Throws if `fn` is empty, see the reference of std::function::operator().
79 */
80 void ForEachQueryStringParameter(const std::wstring& urlQueryString,
81 const std::function<bool(const std::wstring& name, const std::wstring& value)> & fn);
82
59 template<class T> 83 template<class T>
60 T TrimString(T text) 84 T TrimString(T text)
61 { 85 {
62 // Via http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-st dstring 86 // Via http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-st dstring
63 T trimmed(text); 87 T trimmed(text);
64 std::function<bool(T::value_type)> isspace = std::bind(&std::isspace<T::value_ type>, std::placeholders::_1, std::locale::classic()); 88 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))); 89 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()); 90 trimmed.erase(std::find_if(trimmed.rbegin(), trimmed.rend(), std::not1(isspace )).base(), trimmed.end());
67 return trimmed; 91 return trimmed;
68 } 92 }
69 93
70 #endif // UTILS_H 94 #endif // UTILS_H
OLDNEW
« no previous file with comments | « src/plugin/PluginWbPassThrough.cpp ('k') | src/shared/Utils.cpp » ('j') | src/shared/Utils.cpp » ('J')

Powered by Google App Engine
This is Rietveld