1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "net/tools/balsa/split.h"
11 #include "base/strings/string_piece.h"
15 // Yea, this could be done with less code duplication using
16 // template magic, I know.
17 void SplitStringPieceToVector(const base::StringPiece& full,
19 std::vector<base::StringPiece>* vec,
20 bool omit_empty_strings) {
22 if (full.empty() || delim[0] == '\0')
25 if (delim[1] == '\0') {
26 base::StringPiece::const_iterator s = full.begin();
27 base::StringPiece::const_iterator e = s;
28 for (;e != full.end(); ++e) {
30 if (e != s || !omit_empty_strings) {
31 vec->push_back(base::StringPiece(s, e - s));
39 if (e != s || !omit_empty_strings) {
40 vec->push_back(base::StringPiece(s, e - s));
44 base::StringPiece::const_iterator s = full.begin();
45 base::StringPiece::const_iterator e = s;
46 for (;e != full.end(); ++e) {
47 bool one_matched = false;
48 for (const char *d = delim; *d != '\0'; ++d) {
55 if (e != s || !omit_empty_strings) {
56 vec->push_back(base::StringPiece(s, e - s));
64 if (e != s || !omit_empty_strings) {
65 vec->push_back(base::StringPiece(s, e - s));