Manages command line definition and parsing of arguments. More...
#include <CmdLine.h>
Public Member Functions | |
void | add (Arg &a) |
Adds an argument to the list of arguments to be parsed. | |
void | add (Arg *a) |
An alternative add. Functionally identical. | |
CmdLine (const std::string &name, const std::string &project, const std::string &description, const std::string &example, const std::string &version, const std::string ©right="Copyright (c) University of Pennsylvania."" All rights reserved.", const std::string &license="See https://www.cbica.upenn.edu/sbia/software/license.html"" or COPYING file.", const std::string &contact="SBIA Group <sbia-software at uphs.upenn.edu>", bool stdargs=true) | |
Constructor. | |
CmdLine (const std::string &name, const std::string &project, const std::string &description, const std::vector< std::string > &examples, const std::string &version, const std::string ©right="Copyright (c) University of Pennsylvania."" All rights reserved.", const std::string &license="See https://www.cbica.upenn.edu/sbia/software/license.html"" or COPYING file.", const std::string &contact="SBIA Group <sbia-software at uphs.upenn.edu>", bool stdargs=true) | |
Constructor. | |
std::string & | getContact () |
Get contact information. | |
std::string & | getCopyright () |
Get copyright notice. | |
std::string & | getDescription () |
Get program description. | |
std::vector< std::string > & | getExamples () |
Get usage example. | |
std::string & | getLicense () |
Get license information. | |
std::string & | getProgramName () |
Get name of program. | |
std::string & | getProjectName () |
Get name of project the program belongs to. | |
void | parse (int argc, const char *const *argv) |
Parses the command line. | |
void | parse (std::vector< std::string > &args) |
Parses the command line. | |
void | xorAdd (Arg &a, Arg &b) |
Add two Args that will be xor'd. | |
void | xorAdd (std::vector< Arg * > &xors) |
Add a list of arguments that will be xor'd. | |
virtual | ~CmdLine () |
Destructor. | |
Protected Member Functions | |
void | setup (bool stdargs) |
Set up command-line object. | |
Protected Attributes | |
std::string | _contact |
Contact information. | |
std::string | _copyright |
Program copyright. | |
std::vector< std::string > | _examples |
Program usage example. | |
std::string | _license |
Program license. | |
std::string | _name |
Program name. | |
std::string | _project |
Name of project. |
Manages command line definition and parsing of arguments.
See Parsing the Command-line Arguments in C++ for an example use of this class.
Copyright (c) 2011 University of Pennsylvania. All rights reserved.
See https://www.cbica.upenn.edu/sbia/software/license.html or COPYING file.
Definition at line 39 of file basis/CmdLine.h.
sbia::basis::CmdLine::CmdLine | ( | const std::string & | name, |
const std::string & | project, | ||
const std::string & | description, | ||
const std::string & | example, | ||
const std::string & | version, | ||
const std::string & | copyright = "Copyright (c) University of Pennsylvania." " All rights reserved." , |
||
const std::string & | license = "See https://www.cbica.upenn.edu/sbia/software/license.html" " or COPYING file." , |
||
const std::string & | contact = "SBIA Group <sbia-software at uphs.upenn.edu>" , |
||
bool | stdargs = true |
||
) |
Constructor.
[in] | name | Program name. Should be a constant string which helps to identify the program, not the name of the executable as determined at runtime. |
[in] | project | Name of project this program belongs to. |
[in] | description | Program description. |
[in] | example | Usage example. |
[in] | version | Program version. |
[in] | copyright | Copyright notice. |
[in] | license | License information. |
[in] | contact | Contact information. |
[in] | stdargs | Enable/disable handling of standard arguments. |
Definition at line 701 of file CmdLine.cxx.
sbia::basis::CmdLine::CmdLine | ( | const std::string & | name, |
const std::string & | project, | ||
const std::string & | description, | ||
const std::vector< std::string > & | examples, | ||
const std::string & | version, | ||
const std::string & | copyright = "Copyright (c) University of Pennsylvania." " All rights reserved." , |
||
const std::string & | license = "See https://www.cbica.upenn.edu/sbia/software/license.html" " or COPYING file." , |
||
const std::string & | contact = "SBIA Group <sbia-software at uphs.upenn.edu>" , |
||
bool | stdargs = true |
||
) |
Constructor.
[in] | name | Program name. Should be a constant string which helps to identify the program, not the name of the executable as determined at runtime. |
[in] | project | Name of project this program belongs to. |
[in] | description | Program description. |
[in] | examples | Usage examples. |
[in] | version | Program version. |
[in] | copyright | Copyright notice. |
[in] | license | License information. |
[in] | contact | Contact information. |
[in] | stdargs | Enable/disable handling of standard arguments. |
Definition at line 723 of file CmdLine.cxx.
void sbia::basis::CmdLine::add | ( | Arg & | a | ) | [virtual] |
Adds an argument to the list of arguments to be parsed.
[in] | a | Argument to be added. |
Reimplemented from TCLAP::CmdLine.
Definition at line 811 of file CmdLine.cxx.
void sbia::basis::CmdLine::add | ( | Arg * | a | ) | [virtual] |
An alternative add. Functionally identical.
[in] | a | Argument to be added. |
Reimplemented from TCLAP::CmdLine.
Definition at line 817 of file CmdLine.cxx.
std::string& sbia::basis::CmdLine::getContact | ( | ) | [inline] |
Get contact information.
Definition at line 218 of file basis/CmdLine.h.
std::string& sbia::basis::CmdLine::getCopyright | ( | ) | [inline] |
Get copyright notice.
Definition at line 204 of file basis/CmdLine.h.
std::string& sbia::basis::CmdLine::getDescription | ( | ) | [inline] |
Get program description.
Definition at line 190 of file basis/CmdLine.h.
std::vector<std::string>& sbia::basis::CmdLine::getExamples | ( | ) | [inline] |
Get usage example.
Definition at line 197 of file basis/CmdLine.h.
std::string& sbia::basis::CmdLine::getLicense | ( | ) | [inline] |
Get license information.
Definition at line 211 of file basis/CmdLine.h.
std::string& sbia::basis::CmdLine::getProgramName | ( | ) | [inline, virtual] |
Get name of program.
Reimplemented from TCLAP::CmdLine.
Definition at line 176 of file basis/CmdLine.h.
std::string& sbia::basis::CmdLine::getProjectName | ( | ) | [inline] |
Get name of project the program belongs to.
Definition at line 183 of file basis/CmdLine.h.
void sbia::basis::CmdLine::parse | ( | int | argc, |
const char *const * | argv | ||
) | [virtual] |
Parses the command line.
[in] | argc | Number of arguments. |
[in] | argv | Array of arguments. |
Reimplemented from TCLAP::CmdLine.
Definition at line 848 of file CmdLine.cxx.
void sbia::basis::CmdLine::parse | ( | std::vector< std::string > & | args | ) |
Parses the command line.
[in] | args | A vector of strings representing the args. args[0] is still the program name. |
Reimplemented from TCLAP::CmdLine.
Definition at line 854 of file CmdLine.cxx.
Add two Args that will be xor'd.
If this method is used, add does not need to be called.
[in] | a | Argument to be added and xor'd. |
[in] | b | Argument to be added and xor'd. |
Reimplemented from TCLAP::CmdLine.
Definition at line 823 of file CmdLine.cxx.
void sbia::basis::CmdLine::xorAdd | ( | std::vector< Arg * > & | xors | ) | [virtual] |
Add a list of arguments that will be xor'd.
If this method is used, add does not need to be called.
[in] | xors | List of Args to be added and xor'd. |
Reimplemented from TCLAP::CmdLine.
Definition at line 832 of file CmdLine.cxx.