OLD | NEW |
(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_ |
OLD | NEW |