| 380 | } |
| 381 | |
| 382 | CLI11_INLINE std::vector<std::string> split_up(std::string str, char delimiter) { |
| 383 | |
| 384 | auto find_ws = [delimiter](char ch) { |
| 385 | return (delimiter == '\0') ? std::isspace<char>(ch, std::locale()) : (ch == delimiter); |
| 386 | }; |
| 387 | trim(str); |
| 388 | |
| 389 | std::vector<std::string> output; |
| 390 | while(!str.empty()) { |
| 391 | if(bracketChars.find_first_of(str[0]) != std::string::npos) { |
| 392 | auto bracketLoc = bracketChars.find_first_of(str[0]); |
| 393 | auto end = close_sequence(str, 0, matchBracketChars[bracketLoc]); |
| 394 | if(end >= str.size()) { |
| 395 | output.push_back(std::move(str)); |
| 396 | str.clear(); |
| 397 | } else { |
| 398 | output.push_back(str.substr(0, end + 1)); |
| 399 | if(end + 2 < str.size()) { |
| 400 | str = str.substr(end + 2); |
| 401 | } else { |
| 402 | str.clear(); |
| 403 | } |
| 404 | } |
| 405 | |
| 406 | } else { |
| 407 | auto it = std::find_if(std::begin(str), std::end(str), find_ws); |
| 408 | if(it != std::end(str)) { |
| 409 | std::string value = std::string(str.begin(), it); |
| 410 | output.push_back(value); |
| 411 | str = std::string(it + 1, str.end()); |
| 412 | } else { |
| 413 | output.push_back(str); |
| 414 | str.clear(); |
| 415 | } |
| 416 | } |
| 417 | trim(str); |
| 418 | } |
| 419 | return output; |
| 420 | } |
| 421 | |
| 422 | CLI11_INLINE std::size_t escape_detect(std::string &str, std::size_t offset) { |
| 423 | auto next = str[offset + 1]; |