pdal::ProgramArgs

pdal::ProgramArgs#

class ProgramArgs#

Parses command lines, provides validation and stores found values in bound variables.

Add arguments with add. When all arguments have been added, use parse to validate command line and assign values to variables bound with add.

Public Functions

inline Arg &add(const std::string &name, const std::string description, std::string &var, std::string def)#

Add a string argument to the list of arguments.

Parameters:
  • name – Name of argument. Argument names are specified as “longname[,shortname]”, where shortname is an optional one-character abbreviation.

  • description – Description of the argument.

  • var – Reference to variable to bind to argument.

  • def – Default value of argument.

Returns:

Reference to the new argument.

inline Arg &add(const std::string &name, const std::string &description, std::vector<std::string> &var)#

Add a list-based (vector) string argument.

Parameters:
  • name – Name of argument. Argument names are specified as “longname[,shortname]”, where shortname is an optional one-character abbreviation.

  • description – Description of the argument.

  • var – Reference to variable to bind to argument.

Returns:

Reference to the new argument.

inline bool set(const std::string &name) const#

Return whether the argument (as specified by it’s longname) had its value set during parsing.

template<typename T>
inline Arg &add(const std::string &name, const std::string &description, std::vector<T> &var)#

Add a list-based (vector) argument.

Parameters:
  • name – Name of argument. Argument names are specified as “longname[,shortname]”, where shortname is an optional one-character abbreviation.

  • description – Description of the argument.

  • var – Reference to variable to bind to argument.

Returns:

Reference to the new argument.

template<typename T>
inline Arg &add(const std::string &name, const std::string &description, std::vector<T> &var, std::vector<T> def)#

Add a list-based (vector) argument with a default.

Parameters:
  • name – Name of argument. Argument names are specified as “longname[,shortname]”, where shortname is an optional one-character abbreviation.

  • description – Description of the argument.

  • var – Reference to variable to bind to argument.

Returns:

Reference to the new argument.

template<typename T>
inline Arg &add(const std::string &name, const std::string description, T &var, T def)#

Add an argument to the list of arguments with a default.

Parameters:
  • name – Name of argument. Argument names are specified as “longname[,shortname]”, where shortname is an optional one-character abbreviation.

  • description – Description of the argument.

  • var – Reference to variable to bind to argument.

  • def – Default value of argument.

Returns:

Reference to the new argument.

template<typename T>
inline Arg &add(const std::string &name, const std::string description, T &var)#

Add an argument to the list of arguments.

Parameters:
  • name – Name of argument. Argument names are specified as “longname[,shortname]”, where shortname is an optional one-character abbreviation.

  • description – Description of the argument.

  • var – Reference to variable to bind to argument.

Returns:

Reference to the new argument.

inline void parseSimple(std::vector<std::string> &s)#

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.

Parameters:

s – List of strings that constitute the argument list.

inline void parse(const std::vector<std::string> &s)#

Parse a command line as specified by its argument list.

Parsing validates the argument vector and assigns values to variables bound to added arguments.

Parameters:

s – List of strings that constitute the argument list.

inline void addSynonym(const std::string &name, const std::string &synonym)#

Add a synonym for an argument.

Parameters:
  • name – Longname of existing arugment.

  • synonym – Synonym for argument.

inline void reset()#

Reset the state of all arguments and bound variables as if no parsing had occurred.

inline std::string commandLine() const#

Return a string suitable for use in a “usage” line for display to users as help.

inline void dump(std::ostream &out, size_t indent, size_t totalWidth) const#

Write a formatted description of arguments to an output stream.

Write a list of the names and descriptions of arguments suitable for display as help information.

Parameters:
  • out – Stream to which output should be written.

  • indent – Number of characters to indent all text.

  • totalWidth – Total width to assume for formatting output. Typically this is the width of a terminal window.

inline void dump2(std::ostream &out, size_t nameIndent, size_t descripIndent, size_t totalWidth) const#

Write a verbose description of arguments to an output stream.

Each argument is on its own line. The argument’s description follows on subsequent lines.

Parameters:
  • out – Stream to which output should be written.

  • nameIndent – Number of characters to indent argument lines.

  • descripIndent – Number of characters to indent description lines.

  • totalWidth – Total line width.

inline void dump3(std::ostream &out) const#

Write a JSON array of arguments to an output stream.

Parameters:

out – Stream to which output should be written.