Chromium Code Reviews| 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++) | |
|
jww
2014/10/15 23:26:04
I find this inline post-increment extremely confus
Mike West
2014/10/16 06:17:22
Done.
| |
| 60 return false; | |
| 61 ++current; | |
| 62 } | |
| 63 if (*token) | |
| 64 return false; | |
| 65 | |
| 66 position = current; | |
| 67 return true; | |
| 68 } | |
| 69 | |
| 70 template <typename CharType> | |
| 55 void skipUntil(const CharType*& position, const CharType* end, CharType delimite r) | 71 void skipUntil(const CharType*& position, const CharType* end, CharType delimite r) |
| 56 { | 72 { |
| 57 while (position < end && *position != delimiter) | 73 while (position < end && *position != delimiter) |
| 58 ++position; | 74 ++position; |
| 59 } | 75 } |
| 60 | 76 |
| 61 template<typename CharType, bool characterPredicate(CharType)> | 77 template<typename CharType, bool characterPredicate(CharType)> |
| 62 void skipUntil(const CharType*& position, const CharType* end) | 78 void skipUntil(const CharType*& position, const CharType* end) |
| 63 { | 79 { |
| 64 while (position < end && !characterPredicate(*position)) | 80 while (position < end && !characterPredicate(*position)) |
| 65 ++position; | 81 ++position; |
| 66 } | 82 } |
| 67 | 83 |
| 68 template<typename CharType, bool characterPredicate(CharType)> | 84 template<typename CharType, bool characterPredicate(CharType)> |
| 69 void skipWhile(const CharType*& position, const CharType* end) | 85 void skipWhile(const CharType*& position, const CharType* end) |
| 70 { | 86 { |
| 71 while (position < end && characterPredicate(*position)) | 87 while (position < end && characterPredicate(*position)) |
| 72 ++position; | 88 ++position; |
| 73 } | 89 } |
| 74 | 90 |
| 75 template<typename CharType, bool characterPredicate(CharType)> | 91 template<typename CharType, bool characterPredicate(CharType)> |
| 76 void reverseSkipWhile(const CharType*& position, const CharType* start) | 92 void reverseSkipWhile(const CharType*& position, const CharType* start) |
| 77 { | 93 { |
| 78 while (position >= start && characterPredicate(*position)) | 94 while (position >= start && characterPredicate(*position)) |
| 79 --position; | 95 --position; |
| 80 } | 96 } |
| 81 | 97 |
| 82 #endif | 98 #endif |
| 83 | 99 |
| OLD | NEW |