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_STRING_DATA_VIEW_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_STRING_DATA_VIEW_H_ 7 8 #include "mojo/public/cpp/bindings/lib/array_internal.h" 9 #include "mojo/public/cpp/bindings/lib/serialization_context.h" 10 11 namespace mojo { 12 13 // Access to the contents of a serialized string. 14 class StringDataView { 15 public: 16 StringDataView() {} 17 18 StringDataView(internal::String_Data* data, 19 internal::SerializationContext* context) 20 : data_(data) {} 21 22 bool is_null() const { return !data_; } 23 24 const char* storage() const { return data_->storage(); } 25 26 size_t size() const { return data_->size(); } 27 28 private: 29 internal::String_Data* data_ = nullptr; 30 }; 31 32 } // namespace mojo 33 34 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRING_DATA_VIEW_H_ 35