MCPcopy Create free account
hub / github.com/p-ranav/tabulate / explode_string

Method explode_string

single_include/tabulate/tabulate.hpp:7081–7107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7079 }
7080
7081 static std::vector<std::string> explode_string(const std::string &input,
7082 const std::vector<std::string> &split_characters) {
7083 std::vector<std::string> result{};
7084 size_t start_index{0};
7085 while (true) {
7086 auto index = index_of_any(input, start_index, split_characters);
7087
7088 if (index == std::string::npos) {
7089 result.push_back(input.substr(start_index));
7090 return result;
7091 }
7092
7093 std::string word = input.substr(start_index, index - start_index);
7094 char next_character = input.substr(index, 1)[0];
7095 // Unlike whitespace, dashes and the like should stick to the word
7096 // occurring before it.
7097 if (isspace(next_character)) {
7098 result.push_back(word);
7099 result.push_back(std::string(1, next_character));
7100 } else {
7101 result.push_back(word + next_character);
7102 }
7103 start_index = index + 1;
7104 }
7105
7106 return result;
7107 }
7108
7109 // Element width and height
7110 optional<size_t> width_{};

Callers

nothing calls this directly

Calls 1

substrMethod · 0.45

Tested by

no test coverage detected