Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Unified Diff: src/inspector/StringUtil.h

Issue 2292573002: [inspector] Initial import of v8_inspector. (Closed)
Patch Set: format the code, disable cpplint Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/inspector/String16.cpp ('k') | src/inspector/StringUtil.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/inspector/StringUtil.h
diff --git a/src/inspector/StringUtil.h b/src/inspector/StringUtil.h
new file mode 100644
index 0000000000000000000000000000000000000000..8eb0679d3847890590191be366677e67154add1e
--- /dev/null
+++ b/src/inspector/StringUtil.h
@@ -0,0 +1,73 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8_INSPECTOR_STRINGUTIL_H_
+#define V8_INSPECTOR_STRINGUTIL_H_
+
+#include "src/inspector/Allocator.h"
+#include "src/inspector/String16.h"
+#include "src/inspector/public/StringBuffer.h"
+#include "src/inspector/public/StringView.h"
+
+#include <v8.h>
+
+namespace v8_inspector {
+
+namespace protocol {
+
+class Value;
+
+using String = v8_inspector::String16;
+using StringBuilder = v8_inspector::String16Builder;
+
+class StringUtil {
+ public:
+ static String substring(const String& s, unsigned pos, unsigned len) {
+ return s.substring(pos, len);
+ }
+ static String fromInteger(int number) { return String::fromInteger(number); }
+ static String fromDouble(double number) { return String::fromDouble(number); }
+ static const size_t kNotFound = String::kNotFound;
+ static void builderReserve(StringBuilder& builder, unsigned capacity) {
+ builder.reserveCapacity(capacity);
+ }
+};
+
+std::unique_ptr<protocol::Value> parseJSON(const StringView& json);
+std::unique_ptr<protocol::Value> parseJSON(const String16& json);
+
+} // namespace protocol
+
+std::unique_ptr<protocol::Value> toProtocolValue(v8::Local<v8::Context>,
+ v8::Local<v8::Value>,
+ int maxDepth = 1000);
+
+v8::Local<v8::String> toV8String(v8::Isolate*, const String16&);
+v8::Local<v8::String> toV8StringInternalized(v8::Isolate*, const String16&);
+v8::Local<v8::String> toV8StringInternalized(v8::Isolate*, const char*);
+v8::Local<v8::String> toV8String(v8::Isolate*, const StringView&);
+// TODO(dgozman): rename to toString16.
+String16 toProtocolString(v8::Local<v8::String>);
+String16 toProtocolStringWithTypeCheck(v8::Local<v8::Value>);
+String16 toString16(const StringView&);
+StringView toStringView(const String16&);
+bool stringViewStartsWith(const StringView&, const char*);
+
+class StringBufferImpl : public StringBuffer {
+ V8_INSPECTOR_DISALLOW_COPY(StringBufferImpl);
+
+ public:
+ // Destroys string's content.
+ static std::unique_ptr<StringBufferImpl> adopt(String16&);
+ const StringView& string() override { return m_string; }
+
+ private:
+ explicit StringBufferImpl(String16&);
+ String16 m_owner;
+ StringView m_string;
+};
+
+} // namespace v8_inspector
+
+#endif // V8_INSPECTOR_STRINGUTIL_H_
« no previous file with comments | « src/inspector/String16.cpp ('k') | src/inspector/StringUtil.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698