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_TRAITS_STRING16_H_ 6#define MOJO_PUBLIC_CPP_BINDINGS_STRING_TRAITS_STRING16_H_ 7 8#include "base/strings/string16.h" 9#include "mojo/public/cpp/bindings/bindings_export.h" 10#include "mojo/public/cpp/bindings/string_traits.h" 11 12namespace mojo { 13 14template <> 15struct MOJO_CPP_BINDINGS_EXPORT StringTraits<base::string16> { 16 static bool IsNull(const base::string16& input) { 17 // base::string16 is always converted to non-null mojom string. 18 return false; 19 } 20 21 static void SetToNull(base::string16* output) { 22 // Convert null to an "empty" base::string16. 23 output->clear(); 24 } 25 26 static void* SetUpContext(const base::string16& input); 27 static void TearDownContext(const base::string16& input, void* context); 28 29 static size_t GetSize(const base::string16& input, void* context); 30 static const char* GetData(const base::string16& input, void* context); 31 32 static bool Read(StringDataView input, base::string16* output); 33}; 34 35} // namespace mojo 36 37#endif // MOJO_PUBLIC_CPP_BINDINGS_STRING_TRAITS_STRING16_H_ 38