Chromium Code Reviews| 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) |
|
Mike West
2015/02/27 08:53:41
Can you use isASCIIWhitespace instead (in string_u
|
| +{ |
| + 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 |
| + |