| 146 | } |
| 147 | |
| 148 | static std::vector<std::string> break_str_into_lines(std::string input, size_t max_char_per_line) { |
| 149 | std::vector<std::string> result; |
| 150 | std::istringstream iss(input); |
| 151 | std::string line; |
| 152 | auto add_line = [&](const std::string& l) { |
| 153 | if (l.length() <= max_char_per_line) { |
| 154 | result.push_back(l); |
| 155 | } else { |
| 156 | std::istringstream line_stream(l); |
| 157 | std::string word, current_line; |
| 158 | while (line_stream >> word) { |
| 159 | if (current_line.length() + !current_line.empty() + word.length() > max_char_per_line) { |
| 160 | if (!current_line.empty()) result.push_back(current_line); |
| 161 | current_line = word; |
| 162 | } else { |
| 163 | current_line += (!current_line.empty() ? " " : "") + word; |
| 164 | } |
| 165 | } |
| 166 | if (!current_line.empty()) result.push_back(current_line); |
| 167 | } |
| 168 | }; |
| 169 | while (std::getline(iss, line)) { |
| 170 | add_line(line); |
| 171 | } |
| 172 | return result; |
| 173 | } |
| 174 | |
| 175 | std::string common_arg::to_string() const { |
| 176 | // params for printing to console |