Index: webrtc/base/stringencode.cc |
diff --git a/webrtc/base/stringencode.cc b/webrtc/base/stringencode.cc |
index c48c52634c98e1a427b42640810fd4f46f2b6864..7bf05bc0dba55f360fac2ffddb2c10374f9ceba0 100644 |
--- a/webrtc/base/stringencode.cc |
+++ b/webrtc/base/stringencode.cc |
@@ -573,6 +573,22 @@ size_t tokenize(const std::string& source, char delimiter, |
return fields->size(); |
} |
+size_t tokenize_with_empty_tokens(const std::string& source, |
+ char delimiter, |
+ std::vector<std::string>* fields) { |
+ DCHECK(fields); |
tommi
2015/09/16 21:51:01
since fields is deferenced anyway, this isn't need
Taylor Brandstetter
2015/09/24 00:25:05
Done.
|
+ fields->clear(); |
tommi
2015/09/16 21:51:01
I'd prefer DCHECK(fields->empty()) instead. |fiel
Taylor Brandstetter
2015/09/24 00:25:05
There's a function specifically called "tokenize_a
|
+ size_t last = 0; |
+ for (size_t i = 0; i < source.length(); ++i) { |
+ if (source[i] == delimiter) { |
+ fields->push_back(source.substr(last, i - last)); |
+ last = i + 1; |
+ } |
+ } |
+ fields->push_back(source.substr(last, source.length() - last)); |
+ return fields->size(); |
tommi
2015/09/16 21:51:01
if source is empty, won't fields->size() return 1?
Taylor Brandstetter
2015/09/24 00:25:05
This is actually the behavior I wanted, in this si
|
+} |
+ |
size_t tokenize_append(const std::string& source, char delimiter, |
std::vector<std::string>* fields) { |
if (!fields) return 0; |