MCPcopy Create free account
hub / github.com/PDAL/PDAL / parseSimple

Method parseSimple

pdal/util/ProgramArgs.hpp:1196–1243  ·  view source on GitHub ↗

Parse a command line as specified by its argument vector. No validation occurs and only argument value exceptions are raised, but assignments are made to bound variables where possible. \param s List of strings that constitute the argument list. */

Source from the content-addressed store, hash-verified

1194 \param s List of strings that constitute the argument list.
1195 */
1196 void parseSimple(std::vector<std::string>& s)
1197 {
1198 ArgValList vals(s);
1199
1200 for (size_t i = 0; i < vals.size();)
1201 {
1202 const std::string& arg = vals[i];
1203 // This may be the value, or it may not. We're passing it along
1204 // just in case. If there is no value, pass along "" to make
1205 // clear that there is none.
1206 std::string value((i != vals.size() - 1) ? vals[i + 1] : "");
1207 try
1208 {
1209 int matched = parseArg(arg, value);
1210 if (!matched)
1211 i++;
1212 else
1213 while (matched--)
1214 vals.consume(i++);
1215 }
1216 catch (arg_val_error&)
1217 {
1218 throw;
1219 }
1220 catch (arg_error&)
1221 {
1222 i++;
1223 }
1224 }
1225
1226 // Go through args and assign those unset to items from the command
1227 // line not already consumed.
1228 for (auto ai = m_args.begin(); ai != m_args.end(); ++ai)
1229 {
1230 Arg *arg = ai->get();
1231 try
1232 {
1233 arg->assignPositional(vals);
1234 }
1235 catch (arg_val_error&)
1236 {
1237 throw;
1238 }
1239 catch (arg_error&)
1240 {}
1241 }
1242 s = vals.unconsumedArgs();
1243 }
1244
1245 /**
1246 Parse a command line as specified by its argument list. Parsing

Callers 4

executeMethod · 0.80
TESTFunction · 0.80
doSwitchesMethod · 0.80
doSwitchesMethod · 0.80

Calls 7

consumeMethod · 0.80
unconsumedArgsMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
getMethod · 0.45
assignPositionalMethod · 0.45

Tested by 1

TESTFunction · 0.64