Chromium Code Reviews| Index: Source/core/platform/ParsingUtilities.h |
| diff --git a/Source/core/platform/ParsingUtilities.h b/Source/core/platform/ParsingUtilities.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..dbd9dca64a150612edc792b43f10336230b740cd |
| --- /dev/null |
| +++ b/Source/core/platform/ParsingUtilities.h |
| @@ -0,0 +1,50 @@ |
| +// Copyright 2013 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 ParsingUtilities_h |
| +#define ParsingUtilities_h |
| + |
| +template<typename CharType> |
| +bool skipExactly(const CharType*& position, const CharType* end, CharType delimiter) |
| +{ |
| + if (position < end && *position == delimiter) { |
| + ++position; |
| + return true; |
| + } |
| + return false; |
| +} |
| + |
| +template<typename CharType, bool characterPredicate(CharType)> |
|
cbiesinger
2013/09/19 23:01:44
Couldn't you make CharType the second template arg
abarth-chromium
2013/09/20 16:08:07
+1
|
| +bool skipExactly(const CharType*& position, const CharType* end) |
| +{ |
| + if (position < end && characterPredicate(*position)) { |
| + ++position; |
| + return true; |
| + } |
| + return false; |
| +} |
| + |
| +template<typename CharType> |
| +void skipUntil(const CharType*& position, const CharType* end, CharType delimiter) |
| +{ |
| + while (position < end && *position != delimiter) |
| + ++position; |
| +} |
| + |
| +template<typename CharType, bool characterPredicate(CharType)> |
| +void skipUntil(const CharType*& position, const CharType* end) |
| +{ |
| + while (position < end && !characterPredicate(*position)) |
| + ++position; |
| +} |
| + |
| +template<typename CharType, bool characterPredicate(CharType)> |
| +void skipWhile(const CharType*& position, const CharType* end) |
| +{ |
| + while (position < end && characterPredicate(*position)) |
| + ++position; |
| +} |
| + |
| +#endif |
| + |