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

Method setValue

pdal/util/ProgramArgs.hpp:404–435  ·  view source on GitHub ↗

Set a an argument's value from a string. Throws an arg_error exception if \a s can't be converted to the argument's type. Values must be provided for with the option name. \note Not intended to be called from user code. \param s Value to set. */

Source from the content-addressed store, hash-verified

402 \param s Value to set.
403 */
404 virtual void setValue(const std::string& s)
405 {
406 if (m_set)
407 {
408 throw arg_val_error("Attempted to set value twice for argument '" +
409 m_longname + "'.");
410 }
411 if (s.empty())
412 {
413 throw arg_val_error("Argument '" + m_longname +
414 "' needs a value and none was provided.");
415 }
416
417 m_rawVal = s;
418 auto status = Utils::fromString(s, m_var);
419 if (!status)
420 {
421 std::string error(m_error);
422
423 if (error.empty())
424 {
425 if (status.what().size())
426 error = "Invalid value for argument '" + m_longname +
427 "': " + status.what();
428 else
429 error = "Invalid value '" + s + "' for argument '" +
430 m_longname + "'.";
431 }
432 throw arg_val_error(error);
433 }
434 m_set = true;
435 }
436
437 /**
438 Reset the argument's state.

Callers 2

parseLongArgMethod · 0.45
parseShortArgMethod · 0.45

Calls 4

fromStringFunction · 0.70
emptyMethod · 0.45
sizeMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected