| OLD | NEW |
| (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 StringVectorCopier_h |
| 6 #define StringVectorCopier_h |
| 7 |
| 8 #include "public/platform/WebString.h" |
| 9 #include "public/platform/WebVector.h" |
| 10 #include <utility> |
| 11 |
| 12 namespace blink { |
| 13 |
| 14 template <typename ARRAY> |
| 15 WebVector<WebString> CopyStringVectorFromUTF16(const ARRAY& input) { |
| 16 WebVector<WebString> output(input.size()); |
| 17 std::transform(input.begin(), input.end(), output.begin(), |
| 18 [](const typename ARRAY::value_type& s) { |
| 19 return WebString::fromUTF16(s); |
| 20 }); |
| 21 return output; |
| 22 } |
| 23 |
| 24 template <typename ARRAY> |
| 25 WebVector<WebString> CopyStringVectorFromUTF8(const ARRAY& input) { |
| 26 WebVector<WebString> output(input.size()); |
| 27 std::transform(input.begin(), input.end(), output.begin(), |
| 28 [](const std::string& s) { return WebString::fromUTF8(s); }); |
| 29 return output; |
| 30 } |
| 31 |
| 32 template <typename ARRAY> |
| 33 WebVector<WebString> CopyStringVectorFromLatin1(const ARRAY& input) { |
| 34 WebVector<WebString> output(input.size()); |
| 35 std::transform(input.begin(), input.end(), output.begin(), |
| 36 [](const std::string& s) { return WebString::fromLatin1(s); }); |
| 37 return output; |
| 38 } |
| 39 |
| 40 } // namespace blink |
| 41 |
| 42 #endif // StringVectorCopier_h |
| OLD | NEW |