OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
566 } | 566 } |
567 last = i + 1; | 567 last = i + 1; |
568 } | 568 } |
569 } | 569 } |
570 if (last != source.length()) { | 570 if (last != source.length()) { |
571 fields->push_back(source.substr(last, source.length() - last)); | 571 fields->push_back(source.substr(last, source.length() - last)); |
572 } | 572 } |
573 return fields->size(); | 573 return fields->size(); |
574 } | 574 } |
575 | 575 |
576 size_t tokenize_with_empty_tokens(const std::string& source, | |
577 char delimiter, | |
578 std::vector<std::string>* fields) { | |
579 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.
| |
580 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
| |
581 size_t last = 0; | |
582 for (size_t i = 0; i < source.length(); ++i) { | |
583 if (source[i] == delimiter) { | |
584 fields->push_back(source.substr(last, i - last)); | |
585 last = i + 1; | |
586 } | |
587 } | |
588 fields->push_back(source.substr(last, source.length() - last)); | |
589 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
| |
590 } | |
591 | |
576 size_t tokenize_append(const std::string& source, char delimiter, | 592 size_t tokenize_append(const std::string& source, char delimiter, |
577 std::vector<std::string>* fields) { | 593 std::vector<std::string>* fields) { |
578 if (!fields) return 0; | 594 if (!fields) return 0; |
579 | 595 |
580 std::vector<std::string> new_fields; | 596 std::vector<std::string> new_fields; |
581 tokenize(source, delimiter, &new_fields); | 597 tokenize(source, delimiter, &new_fields); |
582 fields->insert(fields->end(), new_fields.begin(), new_fields.end()); | 598 fields->insert(fields->end(), new_fields.begin(), new_fields.end()); |
583 return fields->size(); | 599 return fields->size(); |
584 } | 600 } |
585 | 601 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
674 va_list args; | 690 va_list args; |
675 va_start(args, format); | 691 va_start(args, format); |
676 value.assign(buffer, vsprintfn(buffer, maxlen + 1, format, args)); | 692 value.assign(buffer, vsprintfn(buffer, maxlen + 1, format, args)); |
677 va_end(args); | 693 va_end(args); |
678 } | 694 } |
679 */ | 695 */ |
680 | 696 |
681 ///////////////////////////////////////////////////////////////////////////// | 697 ///////////////////////////////////////////////////////////////////////////// |
682 | 698 |
683 } // namespace rtc | 699 } // namespace rtc |
OLD | NEW |