MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / break_str_into_lines

Function break_str_into_lines

common/arg.cpp:150–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148}
149
150static 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
177std::string common_arg::to_string() const {
178 // params for printing to console

Callers 1

to_stringMethod · 0.85

Calls 3

lengthMethod · 0.80
push_backMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected