| 760 | } |
| 761 | |
| 762 | static std::vector<std::string> explode_string(const std::string &input, |
| 763 | const std::vector<std::string> &split_characters) { |
| 764 | std::vector<std::string> result{}; |
| 765 | size_t start_index{0}; |
| 766 | while (true) { |
| 767 | auto index = index_of_any(input, start_index, split_characters); |
| 768 | |
| 769 | if (index == std::string::npos) { |
| 770 | result.push_back(input.substr(start_index)); |
| 771 | return result; |
| 772 | } |
| 773 | |
| 774 | std::string word = input.substr(start_index, index - start_index); |
| 775 | char next_character = input.substr(index, 1)[0]; |
| 776 | // Unlike whitespace, dashes and the like should stick to the word |
| 777 | // occurring before it. |
| 778 | if (isspace(next_character)) { |
| 779 | result.push_back(word); |
| 780 | result.push_back(std::string(1, next_character)); |
| 781 | } else { |
| 782 | result.push_back(word + next_character); |
| 783 | } |
| 784 | start_index = index + 1; |
| 785 | } |
| 786 | |
| 787 | return result; |
| 788 | } |
| 789 | |
| 790 | // Element width and height |
| 791 | optional<size_t> width_{}; |