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

Unified Diff: Source/platform/CommaDelimitedParser.cpp

Issue 961773002: Add a comma delimited syntax parser and use it for Accept-CH (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Removed useless constructor Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: Source/platform/CommaDelimitedParser.cpp
diff --git a/Source/platform/CommaDelimitedParser.cpp b/Source/platform/CommaDelimitedParser.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..694babbe520dfde1be638cf7bbce7882698f0e09
--- /dev/null
+++ b/Source/platform/CommaDelimitedParser.cpp
@@ -0,0 +1,32 @@
+// Copyright 2015 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.
+
+#include "config.h"
+#include "platform/CommaDelimitedParser.h"
+
+namespace blink {
+
+static bool isWhitespace(UChar chr)
+{
+ return (chr == ' ') || (chr == '\t');
+}
+
+CommaDelimitedParser::CommaDelimitedParser(String input)
+{
+ Vector<String> results;
+ input.split(",", results);
+ for (auto& value : results)
+ m_map.add(value.stripWhiteSpace(isWhitespace), true);
+}
+
+bool CommaDelimitedParser::contains(String field)
+{
+ auto i = m_map.find(field);
+ if (i == m_map.end())
+ return false;
+ return i->value;
+}
+
+} // namespace blink
+

Powered by Google App Engine
This is Rietveld 408576698