summaryrefslogtreecommitdiff
path: root/src/inspector/node_string.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/inspector/node_string.cc')
-rw-r--r--src/inspector/node_string.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/inspector/node_string.cc b/src/inspector/node_string.cc
index cb9e90c20e..a79df9e817 100644
--- a/src/inspector/node_string.cc
+++ b/src/inspector/node_string.cc
@@ -85,6 +85,28 @@ double toDouble(const char* buffer, size_t length, bool* ok) {
return d;
}
+std::unique_ptr<Value> parseMessage(const std::string& message, bool binary) {
+ if (binary) {
+ return Value::parseBinary(
+ reinterpret_cast<const uint8_t*>(message.data()),
+ message.length());
+ }
+ return parseJSON(message);
+}
+
+ProtocolMessage jsonToMessage(String message) {
+ return message;
+}
+
+ProtocolMessage binaryToMessage(std::vector<uint8_t> message) {
+ return std::string(reinterpret_cast<const char*>(message.data()),
+ message.size());
+}
+
+String fromUTF8(const uint8_t* data, size_t length) {
+ return std::string(reinterpret_cast<const char*>(data), length);
+}
+
} // namespace StringUtil
} // namespace protocol
} // namespace inspector