MCPcopy Create free account
hub / github.com/apache/trafficserver / handle_args

Function handle_args

src/tscore/ArgParser.cc:383–411  ·  view source on GitHub ↗

helper method to handle the arguments and put them nicely in arguments can be switched to ts::errata

Source from the content-addressed store, hash-verified

381// helper method to handle the arguments and put them nicely in arguments
382// can be switched to ts::errata
383static std::string
384handle_args(Arguments &ret, AP_StrVec &args, std::string const &name, unsigned arg_num, unsigned &index)
385{
386 ArgumentData data;
387 ret.append(name, data);
388 // handle the args
389 if (arg_num == MORE_THAN_ZERO_ARG_N || arg_num == MORE_THAN_ONE_ARG_N) {
390 // infinite arguments
391 if (arg_num == MORE_THAN_ONE_ARG_N && args.size() <= index + 1) {
392 return "at least one argument expected by " + name;
393 }
394 for (unsigned j = index + 1; j < args.size(); j++) {
395 ret.append_arg(name, args[j]);
396 }
397 args.erase(args.begin() + index, args.end());
398 return "";
399 }
400 // finite number of argument handling
401 for (unsigned j = 0; j < arg_num; j++) {
402 if (args.size() < index + j + 2 || args[index + j + 1].empty()) {
403 return std::to_string(arg_num) + " argument(s) expected by " + name;
404 }
405 ret.append_arg(name, args[index + j + 1]);
406 }
407 // erase the used arguments and append the data to the return structure
408 args.erase(args.begin() + index, args.begin() + index + arg_num + 1);
409 index -= 1;
410 return "";
411}
412
413// Append the args of option to parsed data. Return true if there is any option called
414void

Callers 2

append_option_dataMethod · 0.85
parseMethod · 0.85

Calls 8

append_argMethod · 0.80
to_stringFunction · 0.50
appendMethod · 0.45
sizeMethod · 0.45
eraseMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected