Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef MOJO_COMMON_COMMON_TYPE_CONVERTERS_H_ | 5 #ifndef MOJO_COMMON_COMMON_TYPE_CONVERTERS_H_ |
| 6 #define MOJO_COMMON_COMMON_TYPE_CONVERTERS_H_ | 6 #define MOJO_COMMON_COMMON_TYPE_CONVERTERS_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <vector> | |
| 9 | 10 |
| 10 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 11 #include "base/strings/string_piece.h" | 12 #include "base/strings/string_piece.h" |
| 12 #include "mojo/common/mojo_common_export.h" | 13 #include "mojo/common/mojo_common_export.h" |
| 13 #include "mojo/public/cpp/bindings/array.h" | 14 #include "mojo/public/cpp/bindings/array.h" |
| 14 #include "mojo/public/cpp/bindings/string.h" | 15 #include "mojo/public/cpp/bindings/string.h" |
| 15 #include "mojo/public/cpp/bindings/type_converter.h" | 16 #include "mojo/public/cpp/bindings/type_converter.h" |
| 16 | 17 |
| 17 namespace mojo { | 18 namespace mojo { |
| 18 | 19 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 template <> | 55 template <> |
| 55 struct MOJO_COMMON_EXPORT TypeConverter<base::string16, Array<uint8_t>> { | 56 struct MOJO_COMMON_EXPORT TypeConverter<base::string16, Array<uint8_t>> { |
| 56 static base::string16 Convert(const Array<uint8_t>& input); | 57 static base::string16 Convert(const Array<uint8_t>& input); |
| 57 }; | 58 }; |
| 58 | 59 |
| 59 template <> | 60 template <> |
| 60 struct MOJO_COMMON_EXPORT TypeConverter<Array<uint8_t>, base::string16> { | 61 struct MOJO_COMMON_EXPORT TypeConverter<Array<uint8_t>, base::string16> { |
| 61 static Array<uint8_t> Convert(const base::string16& input); | 62 static Array<uint8_t> Convert(const base::string16& input); |
| 62 }; | 63 }; |
| 63 | 64 |
| 65 template <typename A, typename B> | |
| 66 struct TypeConverter<std::vector<A>, std::vector<B>> { | |
| 67 static std::vector<A> Convert(const std::vector<B>& input) { | |
| 68 std::vector<A> result; | |
| 69 result.reserve(input.size()); | |
| 70 for (const B& item : input) | |
| 71 result.push_back(mojo::ConvertTo<A>(item)); | |
| 72 return result; | |
| 73 }; | |
| 74 }; | |
|
dcheng
2016/08/15 18:18:15
Actually, let's not add this type converter please
Reilly Grant (use Gerrit)
2016/08/15 21:39:02
As discussed OOB I've moved this to a more private
| |
| 75 | |
| 64 } // namespace mojo | 76 } // namespace mojo |
| 65 | 77 |
| 66 #endif // MOJO_COMMON_COMMON_TYPE_CONVERTERS_H_ | 78 #endif // MOJO_COMMON_COMMON_TYPE_CONVERTERS_H_ |
| OLD | NEW |