| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 template<typename CharType, bool characterPredicate(CharType)> | 44 template<typename CharType, bool characterPredicate(CharType)> |
| 45 bool skipExactly(const CharType*& position, const CharType* end) | 45 bool skipExactly(const CharType*& position, const CharType* end) |
| 46 { | 46 { |
| 47 if (position < end && characterPredicate(*position)) { | 47 if (position < end && characterPredicate(*position)) { |
| 48 ++position; | 48 ++position; |
| 49 return true; | 49 return true; |
| 50 } | 50 } |
| 51 return false; | 51 return false; |
| 52 } | 52 } |
| 53 | 53 |
| 54 template<typename CharType> | 54 template <typename CharType> |
| 55 bool skipToken(const CharType*& position, const CharType* end, const char* token
) |
| 56 { |
| 57 const CharType* current = position; |
| 58 while (current < end && *token) { |
| 59 if (*current != *token) |
| 60 return false; |
| 61 ++current; |
| 62 ++token; |
| 63 } |
| 64 if (*token) |
| 65 return false; |
| 66 |
| 67 position = current; |
| 68 return true; |
| 69 } |
| 70 |
| 71 template <typename CharType> |
| 55 void skipUntil(const CharType*& position, const CharType* end, CharType delimite
r) | 72 void skipUntil(const CharType*& position, const CharType* end, CharType delimite
r) |
| 56 { | 73 { |
| 57 while (position < end && *position != delimiter) | 74 while (position < end && *position != delimiter) |
| 58 ++position; | 75 ++position; |
| 59 } | 76 } |
| 60 | 77 |
| 61 template<typename CharType, bool characterPredicate(CharType)> | 78 template<typename CharType, bool characterPredicate(CharType)> |
| 62 void skipUntil(const CharType*& position, const CharType* end) | 79 void skipUntil(const CharType*& position, const CharType* end) |
| 63 { | 80 { |
| 64 while (position < end && !characterPredicate(*position)) | 81 while (position < end && !characterPredicate(*position)) |
| 65 ++position; | 82 ++position; |
| 66 } | 83 } |
| 67 | 84 |
| 68 template<typename CharType, bool characterPredicate(CharType)> | 85 template<typename CharType, bool characterPredicate(CharType)> |
| 69 void skipWhile(const CharType*& position, const CharType* end) | 86 void skipWhile(const CharType*& position, const CharType* end) |
| 70 { | 87 { |
| 71 while (position < end && characterPredicate(*position)) | 88 while (position < end && characterPredicate(*position)) |
| 72 ++position; | 89 ++position; |
| 73 } | 90 } |
| 74 | 91 |
| 75 template<typename CharType, bool characterPredicate(CharType)> | 92 template<typename CharType, bool characterPredicate(CharType)> |
| 76 void reverseSkipWhile(const CharType*& position, const CharType* start) | 93 void reverseSkipWhile(const CharType*& position, const CharType* start) |
| 77 { | 94 { |
| 78 while (position >= start && characterPredicate(*position)) | 95 while (position >= start && characterPredicate(*position)) |
| 79 --position; | 96 --position; |
| 80 } | 97 } |
| 81 | 98 |
| 82 #endif | 99 #endif |
| 83 | 100 |
| OLD | NEW |