| Index: mojo/public/cpp/bindings/string_traits.h
|
| diff --git a/mojo/public/cpp/bindings/string_traits.h b/mojo/public/cpp/bindings/string_traits.h
|
| index c046854c2fb2b39acba1471ac2d91fd2f0d1060c..f0c4275c26497b3df8396efd866c05c8a4901078 100644
|
| --- a/mojo/public/cpp/bindings/string_traits.h
|
| +++ b/mojo/public/cpp/bindings/string_traits.h
|
| @@ -5,8 +5,34 @@
|
| #ifndef MOJO_PUBLIC_CPP_BINDINGS_STRING_TRAITS_H_
|
| #define MOJO_PUBLIC_CPP_BINDINGS_STRING_TRAITS_H_
|
|
|
| +#include "base/logging.h"
|
| +#include "mojo/public/cpp/bindings/lib/array_internal.h"
|
| +
|
| namespace mojo {
|
|
|
| +// Access to a string inside a mojo message.
|
| +class StringDataView {
|
| + public:
|
| + explicit StringDataView(internal::String_Data* data) : data_(data) {}
|
| +
|
| + // Whether the data represents a null string.
|
| + // Note: Must not access the following methods if this method returns true.
|
| + bool is_null() const { return !data_; }
|
| +
|
| + const char* storage() const {
|
| + DCHECK(!is_null());
|
| + return data_->storage();
|
| + }
|
| +
|
| + size_t size() const {
|
| + DCHECK(!is_null());
|
| + return data_->size();
|
| + }
|
| +
|
| + private:
|
| + internal::String_Data* data_;
|
| +};
|
| +
|
| // This must be specialized for any UserType to be serialized/deserialized as
|
| // a mojom string.
|
| //
|
|
|