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

Method to_string

common/arg.cpp:177–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175}
176
177std::string common_arg::to_string() const {
178 // params for printing to console
179 const static int n_leading_spaces = 40;
180 const static int n_char_per_line_help = 70; // TODO: detect this based on current console
181 std::string leading_spaces(n_leading_spaces, ' ');
182
183 std::ostringstream ss;
184 auto all_args = get_args(); // also contains args_neg
185 for (const auto & arg : all_args) {
186 if (arg == all_args.front()) {
187 if (all_args.size() == 1) {
188 ss << arg;
189 } else {
190 // first arg is usually abbreviation, we need padding to make it more beautiful
191 auto tmp = std::string(arg) + ", ";
192 auto spaces = std::string(std::max(0, 7 - (int)tmp.size()), ' ');
193 ss << tmp << spaces;
194 }
195 } else {
196 ss << arg << (arg != all_args.back() ? ", " : "");
197 }
198 }
199 if (value_hint) ss << " " << value_hint;
200 if (value_hint_2) ss << " " << value_hint_2;
201 if (ss.tellp() > n_leading_spaces - 3) {
202 // current line is too long, add new line
203 ss << "\n" << leading_spaces;
204 } else {
205 // padding between arg and help, same line
206 ss << std::string(leading_spaces.size() - ss.tellp(), ' ');
207 }
208 const auto help_lines = break_str_into_lines(help, n_char_per_line_help);
209 for (const auto & line : help_lines) {
210 ss << (&line == &help_lines.front() ? "" : leading_spaces) << line << "\n";
211 }
212 return ss.str();
213}
214
215std::vector<std::string> common_arg::get_args() const {
216 std::vector<std::string> result;

Callers 4

load_from_cacheMethod · 0.45
common_params_parse_exFunction · 0.45

Calls 5

stringClass · 0.85
maxFunction · 0.85
break_str_into_linesFunction · 0.85
sizeMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected