MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / parseFlagsWithFilenames

Method parseFlagsWithFilenames

lib/config/flags.cc:50–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50std::vector<std::string> FlagGroup::parseFlagsWithFilenames(int argc,
51 const char* argv[],
52 std::function<bool(const std::string&)> callback)
53{
54 if (_initialised)
55 throw std::runtime_error("called parseFlags() twice");
56
57 /* Recursively accumulate a list of all flags. */
58
59 all_flags.clear();
60 flags_by_name.clear();
61 std::function<void(FlagGroup*)> recurse;
62 recurse = [&](FlagGroup* group)
63 {
64 if (group->_initialised)
65 return;
66
67 for (FlagGroup* subgroup : group->_groups)
68 recurse(subgroup);
69
70 for (Flag* flag : group->_flags)
71 {
72 for (const auto& name : flag->names())
73 {
74 if (flags_by_name.find(name) != flags_by_name.end())
75 error("two flags use the name '{}'", name);
76 flags_by_name[name] = flag;
77 }
78
79 all_flags.push_back(flag);
80 }
81
82 group->_initialised = true;
83 };
84 recurse(this);
85 recurse(&helpGroup);
86
87 /* Now actually parse them. */
88
89 std::vector<std::string> filenames;
90 int index = 1;
91 while (index < argc)
92 {
93 std::string thisarg = argv[index];
94 std::string thatarg = (index < (argc - 1)) ? argv[index + 1] : "";
95
96 std::string key;
97 std::string value;
98 bool usesthat = false;
99
100 if (thisarg.size() == 0)
101 {
102 /* Ignore this argument. */
103 }
104 else if (thisarg[0] != '-')
105 {
106 /* This is a filename. Pass it to the callback, and if not consumed
107 * queue it. */

Callers

nothing calls this directly

Calls 13

errorFunction · 0.85
beginsWithFunction · 0.85
namesMethod · 0.80
applyOptionMethod · 0.80
applyDefaultOptionsMethod · 0.80
validateAndThrowMethod · 0.80
clearMethod · 0.45
findMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected