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

Method explode_string

single_include/tabulate/tabulate.hpp:7575–7601  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7573 }
7574
7575 static std::vector<std::string> explode_string(const std::string &input,
7576 const std::vector<std::string> &split_characters) {
7577 std::vector<std::string> result{};
7578 size_t start_index{0};
7579 while (true) {
7580 auto index = index_of_any(input, start_index, split_characters);
7581
7582 if (index == std::string::npos) {
7583 result.push_back(input.substr(start_index));
7584 return result;
7585 }
7586
7587 std::string word = input.substr(start_index, index - start_index);
7588 char next_character = input.substr(index, 1)[0];
7589 // Unlike whitespace, dashes and the like should stick to the word
7590 // occurring before it.
7591 if (isspace(next_character)) {
7592 result.push_back(word);
7593 result.push_back(std::string(1, next_character));
7594 } else {
7595 result.push_back(word + next_character);
7596 }
7597 start_index = index + 1;
7598 }
7599
7600 return result;
7601 }
7602
7603 // Element width and height
7604 optional<size_t> width_{};

Callers

nothing calls this directly

Calls 1

substrMethod · 0.45

Tested by

no test coverage detected