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

Unified Diff: mojo/public/cpp/bindings/native_struct_data_view.h

Issue 2165233003: Mojo C++ bindings: provide data view for all object types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 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 | « mojo/public/cpp/bindings/map_data_view.h ('k') | mojo/public/cpp/bindings/string_data_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/native_struct_data_view.h
diff --git a/mojo/public/cpp/bindings/native_struct_data_view.h b/mojo/public/cpp/bindings/native_struct_data_view.h
new file mode 100644
index 0000000000000000000000000000000000000000..613bd7a0b0e8b870f4da7ac82146770ffd1cc02c
--- /dev/null
+++ b/mojo/public/cpp/bindings/native_struct_data_view.h
@@ -0,0 +1,36 @@
+// Copyright 2016 The Chromium 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 MOJO_PUBLIC_CPP_BINDINGS_NATIVE_STRUCT_DATA_VIEW_H_
+#define MOJO_PUBLIC_CPP_BINDINGS_NATIVE_STRUCT_DATA_VIEW_H_
+
+#include "mojo/public/cpp/bindings/lib/native_struct_data.h"
+#include "mojo/public/cpp/bindings/lib/serialization_context.h"
+
+namespace mojo {
+
+class NativeStructDataView {
+ public:
+ using Data_ = internal::NativeStruct_Data;
+
+ NativeStructDataView() {}
+
+ NativeStructDataView(Data_* data, internal::SerializationContext* context)
+ : data_(data) {}
+
+ bool is_null() const { return !data_; }
+
+ size_t size() const { return data_->data.size(); }
+
+ uint8_t operator[](size_t index) const { return data_->data.at(index); }
+
+ const uint8_t* data() const { return data_->data.storage(); }
+
+ private:
+ Data_* data_ = nullptr;
+};
+
+} // namespace mojo
+
+#endif // MOJO_PUBLIC_CPP_BINDINGS_NATIVE_STRUCT_DATA_VIEW_H_
« no previous file with comments | « mojo/public/cpp/bindings/map_data_view.h ('k') | mojo/public/cpp/bindings/string_data_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698