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

Method fromCmdlineFile

pdal/Options.cpp:242–277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

240
241
242Options Options::fromCmdlineFile(const std::string& filename,
243 const std::string& s)
244{
245 Options options;
246 StringList args = Utils::simpleWordexp(s);
247
248 for (size_t i = 0; i < args.size(); ++i)
249 {
250 std::string option = args[i];
251 std::string value;
252 if (i + 1 < args.size())
253 value = args[i + 1];
254
255 if (option.size() < 3)
256 throw pdal_error("Invalid option '" + option + "' in option "
257 "file '" + filename + "'.");
258 if (option[0] != '-' || option[1] != '-')
259 throw pdal_error("Option '" + option + "' missing leading \"--\" "
260 "in option file '" + filename + "'.");
261
262 std::string::size_type pos = 2;
263 std::string::size_type count = Option::parse(option, pos);
264 std::string optionName = option.substr(2, count);
265 pos += count;
266 if (option[pos++] == '=')
267 value = option.substr(pos);
268 else
269 i++;
270 if (value.empty())
271 throw pdal_error("No value found for option '" + option + "' in "
272 "option file '" + filename + "'.");
273 Option o(optionName, value);
274 options.add(o);
275 }
276 return options;
277}
278
279std::ostream& operator << (std::ostream& out, const Option& op)
280{

Callers

nothing calls this directly

Calls 4

parseFunction · 0.70
sizeMethod · 0.45
emptyMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected