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