| 1053 | } |
| 1054 | |
| 1055 | static std::vector<std::string> explode_string(const std::string &input, |
| 1056 | const std::vector<std::string> &split_characters) { |
| 1057 | std::vector<std::string> result{}; |
| 1058 | size_t start_index{0}; |
| 1059 | while (true) { |
| 1060 | auto index = index_of_any(input, start_index, split_characters); |
| 1061 | |
| 1062 | if (index == std::string::npos) { |
| 1063 | result.push_back(input.substr(start_index)); |
| 1064 | return result; |
| 1065 | } |
| 1066 | |
| 1067 | std::string word = input.substr(start_index, index - start_index); |
| 1068 | char next_character = input.substr(index, 1)[0]; |
| 1069 | // Unlike whitespace, dashes and the like should stick to the word |
| 1070 | // occurring before it. |
| 1071 | if (isspace(next_character)) { |
| 1072 | result.push_back(word); |
| 1073 | result.push_back(std::string(1, next_character)); |
| 1074 | } else { |
| 1075 | result.push_back(word + next_character); |
| 1076 | } |
| 1077 | start_index = index + 1; |
| 1078 | } |
| 1079 | |
| 1080 | return result; |
| 1081 | } |
| 1082 | |
| 1083 | // Element width and height |
| 1084 | optional<size_t> width_{}; |