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

Side by Side Diff: mojo/public/cpp/bindings/string_traits_stl.h

Issue 1967703004: Mojo C++ bindings: add StringTraits and ArrayTraits for STL types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@27_update_users
Patch Set: Created 4 years, 7 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
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_STRING_TRAITS_STL_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_STRING_TRAITS_STL_H_
7
8 #include <string>
9
10 #include "mojo/public/cpp/bindings/string_traits.h"
11
12 namespace mojo {
13
14 template <>
15 struct StringTraits<std::string> {
16 static bool IsNull(const std::string& input) {
17 // std::string is always converted to non-null mojom string.
18 return false;
19 }
20
21 static void SetToNull(std::string* output) {
22 // std::string doesn't support null state. Set it to empty instead.
23 output->clear();
24 }
25
26 static size_t GetSize(const std::string& input) { return input.size(); }
27
28 static const char* GetData(const std::string& input) { return input.data(); }
29
30 static bool Read(StringDataView input, std::string* output) {
31 output->assign(input.storage(), input.size());
32 return true;
33 }
34 };
35
36 } // namespace mojo
37
38 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRING_TRAITS_STL_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/wtf_serialization.h ('k') | mojo/public/cpp/bindings/tests/struct_traits_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698