MCPcopy Create free account
hub / github.com/OpenDDS/OpenDDS / get_option

Function get_option

tools/inspect/Inspect.cpp:33–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31typedef std::pair<bool, ArgsIt> AfterOpt;
32
33AfterOpt get_option(Args& args, const std::string& opt)
34{
35 for (ArgsIt args_it = args.begin(); args_it != args.end(); ++args_it) {
36 if (*args_it == "--") {
37 // Remaining arguments should be interpreted as positional arguments
38 return AfterOpt(false, args.end());
39 }
40 if (opt.length() <= args_it->length()) {
41 const bool starts_with = args_it->substr(0, opt.length()) == opt;
42 const bool same_size = args_it->length() == opt.length();
43 if (starts_with && !same_size && args_it->at(opt.length()) == '=') {
44 // Form is OPT=VALUE, replace current with VALUE
45 *args_it = args_it->substr(opt.length() + 1);
46 return AfterOpt(true, args_it);
47 } else if (same_size && starts_with) {
48 // Form is OPT VALUE?, return next argument
49 return AfterOpt(true, args.erase(args_it));
50 }
51 }
52 }
53 return AfterOpt(false, args.end());
54}
55
56bool has_option(Args& args, const std::string& opt)
57{

Callers 2

has_optionFunction · 0.85
parse_argsFunction · 0.85

Calls 4

beginMethod · 0.45
endMethod · 0.45
lengthMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected