Return the prefix of "*s" up to the next occurrence of "delim", or the whole remaining string if "delim" is not found. "*s" is advanced past the string returned plus the delimiter (if found).
| 69 | // the whole remaining string if "delim" is not found. "*s" is advanced |
| 70 | // past the string returned plus the delimiter (if found). |
| 71 | static StringPiece ConsumeNextPart(StringPiece* s, char delim) { |
| 72 | for (size_t offset = 0; offset < s->size(); offset++) { |
| 73 | if ((*s)[offset] == delim) { |
| 74 | StringPiece result(s->data(), offset); |
| 75 | s->remove_prefix(offset + 1); // +1: remove delim, as well |
| 76 | return result; |
| 77 | } |
| 78 | } |
| 79 | // No delimiter found: return rest of string |
| 80 | StringPiece result(s->data(), s->size()); |
| 81 | s->remove_prefix(s->size()); |
| 82 | return result; |
| 83 | } |
| 84 | |
| 85 | /* static */ |
| 86 | Status Rendezvous::ParseKey(StringPiece key, ParsedKey* out) { |