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

Delta Between Two Patch Sets: src/Utils.h

Issue 29449592: Issue 5183 - Provide async interface for FileSystem (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Left Patch Set: Updated patch after review. Created June 16, 2017, 9:52 p.m.
Right Patch Set: Rebase on master. Last changes. Created July 7, 2017, 1:36 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
« no previous file with change/comment | « src/Thread.h ('k') | src/Utils.cpp » ('j') | 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 /* 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-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #ifndef ADBLOCK_PLUS_UTILS_H 18 #ifndef ADBLOCK_PLUS_UTILS_H
19 #define ADBLOCK_PLUS_UTILS_H 19 #define ADBLOCK_PLUS_UTILS_H
20 20
21 #include <algorithm> 21 #include <algorithm>
22 #include <cctype> 22 #include <cctype>
23 #include <functional> 23 #include <functional>
24 #include <string> 24 #include <string>
25 #include <vector>
25 #include <v8.h> 26 #include <v8.h>
27
28 #include "AdblockPlus/JsValue.h"
26 29
27 namespace AdblockPlus 30 namespace AdblockPlus
28 { 31 {
29 namespace Utils 32 namespace Utils
30 { 33 {
31 std::string FromV8String(const v8::Handle<v8::Value>& value); 34 std::string FromV8String(const v8::Handle<v8::Value>& value);
35 StringBuffer StringBufferFromV8String(const v8::Handle<v8::Value>& value);
32 v8::Local<v8::String> ToV8String(v8::Isolate* isolate, const std::string& st r); 36 v8::Local<v8::String> ToV8String(v8::Isolate* isolate, const std::string& st r);
37 v8::Local<v8::String> StringBufferToV8String(v8::Isolate* isolate, const Str ingBuffer& bytes);
33 void ThrowExceptionInJS(v8::Isolate* isolate, const std::string& str); 38 void ThrowExceptionInJS(v8::Isolate* isolate, const std::string& str);
34 39
35 // Code for templated function has to be in a header file, can't be in .cpp 40 // Code for templated function has to be in a header file, can't be in .cpp
36 template<class T> 41 template<class T>
37 T TrimString(const T& text) 42 T TrimString(const T& text)
38 { 43 {
39 // Via http://stackoverflow.com/questions/216823/whats-the-best-way-to-tri m-stdstring 44 // Via http://stackoverflow.com/questions/216823/whats-the-best-way-to-tri m-stdstring
40 T trimmed(text); 45 T trimmed(text);
41 trimmed.erase(trimmed.begin(), std::find_if(trimmed.begin(), trimmed.end() , std::not1(std::ptr_fun<int, int>(std::isspace)))); 46 trimmed.erase(trimmed.begin(), std::find_if(trimmed.begin(), trimmed.end() , std::not1(std::ptr_fun<int, int>(std::isspace))));
42 trimmed.erase(std::find_if(trimmed.rbegin(), trimmed.rend(), std::not1(std ::ptr_fun<int, int>(std::isspace))).base(), trimmed.end()); 47 trimmed.erase(std::find_if(trimmed.rbegin(), trimmed.rend(), std::not1(std ::ptr_fun<int, int>(std::isspace))).base(), trimmed.end());
43 return trimmed; 48 return trimmed;
44 } 49 }
45 #ifdef _WIN32 50 #ifdef _WIN32
46 std::wstring ToUtf16String(const std::string& str); 51 std::wstring ToUtf16String(const std::string& str);
47 std::string ToUtf8String(const std::wstring& str); 52 std::string ToUtf8String(const std::wstring& str);
48 std::wstring CanonizeUrl(const std::wstring& url); 53 std::wstring CanonizeUrl(const std::wstring& url);
49 #endif 54 #endif
50 } 55 }
51 } 56 }
52 57
53 #endif 58 #endif
LEFTRIGHT

Powered by Google App Engine
This is Rietveld