summaryrefslogtreecommitdiff
path: root/mojo/public/cpp/bindings/native_struct_data_view.h
diff options
context:
space:
mode:
authorHidehiko Abe <hidehiko@google.com>2018-04-23 19:57:41 -0700
committerandroid-build-merger <android-build-merger@google.com>2018-04-23 19:57:41 -0700
commit0ab20ac2283987e63b0e7c1318db2a5cf7c668d2 (patch)
treebd2d04362f66c36d4279f7a9735ba21ea3a2a021 /mojo/public/cpp/bindings/native_struct_data_view.h
parente389a13ad8648d89ac670ca06f68c9b32976351c (diff)
parentb268b43ac6fdbc4f3a2ed1429b99ace424906090 (diff)
downloadlibchrome-0ab20ac2283987e63b0e7c1318db2a5cf7c668d2.tar.gz
Migrate libmojo repository into libchrome, part 2.
am: b268b43ac6 Change-Id: I7b2c3d7cfed03673c33eb497be20e238bd0aac33
Diffstat (limited to 'mojo/public/cpp/bindings/native_struct_data_view.h')
-rw-r--r--mojo/public/cpp/bindings/native_struct_data_view.h36
1 files changed, 36 insertions, 0 deletions
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 0000000000..613bd7a0b0
--- /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_