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

Side by Side Diff: mojo/public/cpp/bindings/lib/array.cc

Issue 294833002: Mojo: more idiomatic C++ bindings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/public/cpp/bindings/array.h" 5 #include "mojo/public/cpp/bindings/array.h"
6 6
7 namespace mojo { 7 namespace mojo {
8 8
9 #if 0
9 // static 10 // static
10 String TypeConverter<String, std::string>::ConvertFrom(const std::string& input, 11 String TypeConverter<String, std::string>::ConvertFrom(const std::string& input,
11 Buffer* buf) { 12 Buffer* buf) {
12 String::Builder result(input.size(), buf); 13 String::Builder result(input.size(), buf);
13 if (!input.empty()) 14 if (!input.empty())
14 memcpy(&result[0], input.data(), input.size()); 15 memcpy(&result[0], input.data(), input.size());
15 return result.Finish(); 16 return result.Finish();
16 } 17 }
17 // static 18 // static
18 std::string TypeConverter<String, std::string>::ConvertTo(const String& input) { 19 std::string TypeConverter<String, std::string>::ConvertTo(const String& input) {
19 if (input.is_null() || input.size() == 0) 20 if (input.is_null() || input.size() == 0)
20 return std::string(); 21 return std::string();
21 22
22 return std::string(&input[0], &input[0] + input.size()); 23 return std::string(&input[0], &input[0] + input.size());
23 } 24 }
24 25
25 // static 26 // static
26 String TypeConverter<String, const char*>::ConvertFrom(const char* input, 27 String TypeConverter<String, const char*>::ConvertFrom(const char* input,
27 Buffer* buf) { 28 Buffer* buf) {
28 if (!input) 29 if (!input)
29 return String(); 30 return String();
30 31
31 size_t size = strlen(input); 32 size_t size = strlen(input);
32 String::Builder result(size, buf); 33 String::Builder result(size, buf);
33 if (size != 0) 34 if (size != 0)
34 memcpy(&result[0], input, size); 35 memcpy(&result[0], input, size);
35 return result.Finish(); 36 return result.Finish();
36 } 37 }
38 #endif
37 39
38 } // namespace mojo 40 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698