pdal::ProgramArgs
¶
-
class
pdal
::
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
-
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.
- Return
Reference to the new 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.def
: Default value of argument.
-
Arg &
add
(const std::string &name, const std::string &description, std::vector<std::string> &var)¶ Add a list-based (vector) string argument.
- Return
Reference to the new 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.
-
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
>
Arg &add
(const std::string &name, const std::string &description, std::vector<T> &var)¶ Add a list-based (vector) argument.
- Return
Reference to the new 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.
-
template<typename
T
>
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.
- Return
Reference to the new 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.
-
template<typename
T
>
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.
- Return
Reference to the new 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.def
: Default value of argument.
-
template<typename
T
>
Arg &add
(const std::string &name, const std::string description, T &var)¶ Add an argument to the list of arguments.
- Return
Reference to the new 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.
-
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.
-
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.
-
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.
-
void
reset
()¶ Reset the state of all arguments and bound variables as if no parsing had occurred.
-
std::string
commandLine
() const¶ Return a string suitable for use in a “usage” line for display to users as help.
-
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.
-
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.
-
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.
-
Arg &