21 char sep,
const std::string& str, std::string::size_type limit) {
23 std::vector<std::string> out;
24 split(&out, sep, str, limit);
29 const char* sep,
const std::string& str, std::string::size_type limit) {
31 std::vector<std::string> out;
32 split(&out, sep, str, limit);
36 std::vector<std::string>
split(
const std::string& sep,
const std::string& str,
37 std::string::size_type limit) {
39 std::vector<std::string> out;
40 split(&out, sep, str, limit);
48 char sep,
const std::string& str,
49 std::string::size_type min_fields, std::string::size_type limit) {
51 std::vector<std::string> out;
52 split(&out, sep, str, min_fields, limit);
57 const char* sep,
const std::string& str,
58 std::string::size_type min_fields, std::string::size_type limit) {
60 std::vector<std::string> out;
61 split(&out, sep, str, min_fields, limit);
66 const std::string& sep,
const std::string& str,
67 std::string::size_type min_fields, std::string::size_type limit) {
69 std::vector<std::string> out;
70 split(&out, sep, str, min_fields, limit);
77 std::vector<std::string>&
split(
78 std::vector<std::string>* into,
79 char sep,
const std::string& str, std::string::size_type limit) {
82 if (limit == 0)
return *into;
84 std::string::const_iterator it = str.begin(), last = it;
86 for ( ; it != str.end(); ++it)
90 if (into->size() + 1 >= limit)
92 into->emplace_back(last, str.end());
96 into->emplace_back(last, it);
101 into->emplace_back(last, it);
108 std::vector<std::string>* into,
109 const char* sep,
size_t sep_size,
const std::string& str,
110 std::string::size_type limit) {
113 if (limit == 0)
return *into;
117 std::string::const_iterator it = str.begin();
118 while (it != str.end()) {
119 into->emplace_back(it, it + 1);
125 std::string::const_iterator it = str.begin(), last = it;
127 for ( ; it + sep_size < str.end(); ++it)
129 if (std::equal(sep, sep + sep_size, it))
131 if (into->size() + 1 >= limit)
133 into->emplace_back(last, str.end());
137 into->emplace_back(last, it);
138 last = it + sep_size;
142 into->emplace_back(last, str.end());
148 std::vector<std::string>* into,
149 const char* sep,
const std::string& str,
150 std::string::size_type limit) {
152 return split(into, sep, strlen(sep), str, limit);
156 std::vector<std::string>* into,
157 const std::string& sep,
const std::string& str,
158 std::string::size_type limit) {
160 return split(into, sep.data(), sep.size(), str, limit);
167 std::vector<std::string>* into,
168 char sep,
const std::string& str,
169 std::string::size_type min_fields, std::string::size_type limit) {
171 split(into, sep, str, limit);
173 if (into->size() < min_fields)
174 into->resize(min_fields);
180 std::vector<std::string>* into,
181 const char* sep,
const std::string& str,
182 std::string::size_type min_fields, std::string::size_type limit) {
184 split(into, sep, str, limit);
186 if (into->size() < min_fields)
187 into->resize(min_fields);
193 std::vector<std::string>* into,
194 const std::string& sep,
const std::string& str,
195 std::string::size_type min_fields, std::string::size_type limit) {
197 split(into, sep, str, limit);
199 if (into->size() < min_fields)
200 into->resize(min_fields);
std::vector< std::string > split(char sep, const std::string &str, std::string::size_type limit)
Split the given string at each separator character into distinct substrings.