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

Unified Diff: third_party/WebKit/public/platform/StringVectorCopier.h

Issue 2537953003: WebString: makes string16 conversions explicit (part 1: blink, content) (Closed)
Patch Set: fix Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/public/platform/StringVectorCopier.h
diff --git a/third_party/WebKit/public/platform/StringVectorCopier.h b/third_party/WebKit/public/platform/StringVectorCopier.h
new file mode 100644
index 0000000000000000000000000000000000000000..fe8231a9c638749d29dc6739ba849ccb1de53769
--- /dev/null
+++ b/third_party/WebKit/public/platform/StringVectorCopier.h
@@ -0,0 +1,42 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef StringVectorCopier_h
+#define StringVectorCopier_h
+
+#include "public/platform/WebString.h"
+#include "public/platform/WebVector.h"
+#include <utility>
+
+namespace blink {
+
+template <typename ARRAY>
+WebVector<WebString> CopyStringVectorFromUTF16(const ARRAY& input) {
+ WebVector<WebString> output(input.size());
+ std::transform(input.begin(), input.end(), output.begin(),
+ [](const typename ARRAY::value_type& s) {
+ return WebString::fromUTF16(s);
+ });
+ return output;
+}
+
+template <typename ARRAY>
+WebVector<WebString> CopyStringVectorFromUTF8(const ARRAY& input) {
+ WebVector<WebString> output(input.size());
+ std::transform(input.begin(), input.end(), output.begin(),
+ [](const std::string& s) { return WebString::fromUTF8(s); });
+ return output;
+}
+
+template <typename ARRAY>
+WebVector<WebString> CopyStringVectorFromLatin1(const ARRAY& input) {
+ WebVector<WebString> output(input.size());
+ std::transform(input.begin(), input.end(), output.begin(),
+ [](const std::string& s) { return WebString::fromLatin1(s); });
+ return output;
+}
+
+} // namespace blink
+
+#endif // StringVectorCopier_h
« no previous file with comments | « third_party/WebKit/public/platform/FilePathConversion.h ('k') | third_party/WebKit/public/platform/WebString.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698