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

Side by Side Diff: src/Utils.h

Issue 6112412478472192: Issue 1547 - Pass isolate to v8::API (Closed)
Patch Set: Created Nov. 10, 2014, 9:05 a.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 <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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 13 matching lines...) Expand all
24 #include <istream> 24 #include <istream>
25 #include <string> 25 #include <string>
26 #include <v8.h> 26 #include <v8.h>
27 27
28 namespace AdblockPlus 28 namespace AdblockPlus
29 { 29 {
30 namespace Utils 30 namespace Utils
31 { 31 {
32 std::string Slurp(std::istream& stream); 32 std::string Slurp(std::istream& stream);
33 std::string FromV8String(v8::Handle<v8::Value> value); 33 std::string FromV8String(v8::Handle<v8::Value> value);
34 v8::Local<v8::String> ToV8String(const std::string& str); 34 v8::Local<v8::String> ToV8String(v8::Isolate* isolate, const std::string& st r);
35 35
36 // Code for templated function has to be in a header file, can't be in .cpp 36 // Code for templated function has to be in a header file, can't be in .cpp
37 template<class T> 37 template<class T>
38 T TrimString(T text) 38 T TrimString(T text)
39 { 39 {
40 // Via http://stackoverflow.com/questions/216823/whats-the-best-way-to-tri m-stdstring 40 // Via http://stackoverflow.com/questions/216823/whats-the-best-way-to-tri m-stdstring
41 T trimmed(text); 41 T trimmed(text);
42 trimmed.erase(trimmed.begin(), std::find_if(trimmed.begin(), trimmed.end() , std::not1(std::ptr_fun<int, int>(std::isspace)))); 42 trimmed.erase(trimmed.begin(), std::find_if(trimmed.begin(), trimmed.end() , std::not1(std::ptr_fun<int, int>(std::isspace))));
43 trimmed.erase(std::find_if(trimmed.rbegin(), trimmed.rend(), std::not1(std ::ptr_fun<int, int>(std::isspace))).base(), trimmed.end()); 43 trimmed.erase(std::find_if(trimmed.rbegin(), trimmed.rend(), std::not1(std ::ptr_fun<int, int>(std::isspace))).base(), trimmed.end());
44 return trimmed; 44 return trimmed;
45 } 45 }
46 #ifdef _WIN32 46 #ifdef _WIN32
47 std::wstring ToUtf16String(const std::string& str); 47 std::wstring ToUtf16String(const std::string& str);
48 std::string ToUtf8String(const std::wstring& str); 48 std::string ToUtf8String(const std::wstring& str);
49 std::wstring CanonizeUrl(const std::wstring& url); 49 std::wstring CanonizeUrl(const std::wstring& url);
50 #endif 50 #endif
51 } 51 }
52 } 52 }
53 53
54 #endif 54 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld