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

Side by Side Diff: src/Utils.h

Issue 10805001: Fixed: FileSystem;:Write should take an istream instance for input, not ostream (Closed)
Patch Set: Created May 24, 2013, 9:35 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
« no previous file with comments | « src/FileSystemJsObject.cpp ('k') | src/Utils.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 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 <v8.h>
22 #include <algorithm> 21 #include <algorithm>
23 #include <cctype> 22 #include <cctype>
24 #include <functional> 23 #include <functional>
24 #include <istream>
25 #include <string>
26 #include <v8.h>
25 27
26 namespace AdblockPlus 28 namespace AdblockPlus
27 { 29 {
28 namespace Utils 30 namespace Utils
29 { 31 {
30 std::string Slurp(std::ios& stream); 32 std::string Slurp(std::istream& stream);
31 std::string FromV8String(v8::Handle<v8::Value> value); 33 std::string FromV8String(v8::Handle<v8::Value> value);
32 v8::Local<v8::String> ToV8String(const std::string& str); 34 v8::Local<v8::String> ToV8String(const std::string& str);
33 35
34 // 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
35 template <class T> 37 template <class T>
36 T TrimString(T text) 38 T TrimString(T text)
37 { 39 {
38 // 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
39 T trimmed(text); 41 T trimmed(text);
40 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))));
41 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());
42 return trimmed; 44 return trimmed;
43 } 45 }
44 #ifdef _WIN32 46 #ifdef _WIN32
45 std::wstring ToUtf16String(const std::string& str); 47 std::wstring ToUtf16String(const std::string& str);
46 std::string ToUtf8String(const std::wstring& str); 48 std::string ToUtf8String(const std::wstring& str);
47 std::wstring CanonizeUrl(const std::wstring& url); 49 std::wstring CanonizeUrl(const std::wstring& url);
48 #endif 50 #endif
49 } 51 }
50 } 52 }
51 53
52 #endif 54 #endif
OLDNEW
« no previous file with comments | « src/FileSystemJsObject.cpp ('k') | src/Utils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld