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

Unified Diff: src/Utils.cpp

Issue 29449592: Issue 5183 - Provide async interface for FileSystem (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Make read write deal with binary buffers. Created July 6, 2017, 12:19 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/JsValue.cpp ('K') | « src/Utils.h ('k') | test/BaseJsTest.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/Utils.cpp
===================================================================
--- a/src/Utils.cpp
+++ b/src/Utils.cpp
@@ -22,38 +22,46 @@
#include <Windows.h>
#include <Shlwapi.h>
#endif
#include "Utils.h"
using namespace AdblockPlus;
-std::string Utils::Slurp(std::istream& stream)
-{
- std::stringstream content;
- content << stream.rdbuf();
- return content.str();
-}
-
std::string Utils::FromV8String(const v8::Handle<v8::Value>& value)
{
v8::String::Utf8Value stringValue(value);
if (stringValue.length())
return std::string(*stringValue, stringValue.length());
else
return std::string();
}
+std::vector<char> Utils::BufferFromV8String(const v8::Handle<v8::Value>& value)
+{
+ v8::String::Utf8Value stringValue(value);
+ if (stringValue.length())
+ return std::vector<char>(*stringValue, *stringValue + stringValue.length());
+ else
+ return std::vector<char>();
+}
+
v8::Local<v8::String> Utils::ToV8String(v8::Isolate* isolate, const std::string& str)
{
return v8::String::NewFromUtf8(isolate, str.c_str(),
v8::String::NewStringType::kNormalString, str.length());
}
+v8::Local<v8::String> Utils::ToV8String(v8::Isolate* isolate, const std::vector<char>& str)
+{
+ return v8::String::NewFromUtf8(isolate, str.data(),
+ v8::String::NewStringType::kNormalString, str.size());
+}
+
void Utils::ThrowExceptionInJS(v8::Isolate* isolate, const std::string& str)
{
isolate->ThrowException(Utils::ToV8String(isolate, str));
}
#ifdef _WIN32
std::wstring Utils::ToUtf16String(const std::string& str)
{
« src/JsValue.cpp ('K') | « src/Utils.h ('k') | test/BaseJsTest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld