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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_NATIVE_STRUCT_DATA_VIEW_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_NATIVE_STRUCT_DATA_VIEW_H_
7
8 #include "mojo/public/cpp/bindings/lib/native_struct_data.h"
9 #include "mojo/public/cpp/bindings/lib/serialization_context.h"
10
11 namespace mojo {
12
13 class NativeStructDataView {
14 public:
15 using Data_ = internal::NativeStruct_Data;
16
17 NativeStructDataView() {}
18
19 NativeStructDataView(Data_* data, internal::SerializationContext* context)
20 : data_(data) {}
21
22 bool is_null() const { return !data_; }
23
24 size_t size() const { return data_->data.size(); }
25
26 uint8_t operator[](size_t index) const { return data_->data.at(index); }
27
28 const uint8_t* data() const { return data_->data.storage(); }
29
30 private:
31 Data_* data_ = nullptr;
32 };
33
34 } // namespace mojo
35
36 #endif // MOJO_PUBLIC_CPP_BINDINGS_NATIVE_STRUCT_DATA_VIEW_H_
OLDNEW
« 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