Split fmtp on semicolons not spaces as per RFC6871

BUG=4617
R=pthatcher@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/47169004

Cr-Commit-Position: refs/heads/master@{#9193}
This commit is contained in:
Donald Curtis
2015-05-15 09:21:23 -07:00
parent 20f3f942a0
commit 0e07f92043
5 changed files with 138 additions and 49 deletions

View File

@ -607,6 +607,25 @@ size_t tokenize(const std::string& source, char delimiter, char start_mark,
return tokenize_append(remain_source, delimiter, fields);
}
bool tokenize_first(const std::string& source, const char delimiter,
std::string* token, std::string* rest) {
// Find the first delimiter
size_t left_pos = source.find(delimiter);
if (left_pos == std::string::npos) {
return false;
}
// Look for additional occurrances of delimiter.
size_t right_pos = left_pos + 1;
while(source[right_pos] == delimiter) {
right_pos++;
}
*token = source.substr(0, left_pos);
*rest = source.substr(right_pos);
return true;
}
size_t split(const std::string& source, char delimiter,
std::vector<std::string>* fields) {
DCHECK(fields);