Manages command line definition and parsing of arguments. More...
#include <CmdLine.h>
Classes | |
class | XorHandler |
Handles lists of Arg's that are to be XOR'd on the command-line. More... | |
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. | |
XorHandler & | getXorHandler () |
Get handler of XOR'd arguments. | |
void | parse (int argc, const char *const *argv) |
Parses the command line. | |
void | parse (std::vector< std::string > &args) |
Parses the command line. | |
void | print_help () const |
Print help. | |
void | print_usage () const |
Print short help, i.e., usage information. | |
void | print_version () const |
Print version information. | |
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. | |
XorHandler | _xorHandler |
Customized XorHandler. |
Detailed Description
Manages command line definition and parsing of arguments.
Copyright (c) 2011 University of Pennsylvania. All rights reserved.
See https://www.cbica.upenn.edu/sbia/software/license.html or COPYING file.
Constructor & Destructor Documentation
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.
- Parameters:
-
[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 768 of file CmdLine.cxx.
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.
- Parameters:
-
[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 791 of file CmdLine.cxx.
virtual basis::CmdLine::~CmdLine | ( | ) | [inline, virtual] |
Member Function Documentation
void basis::CmdLine::add | ( | Arg & | a | ) |
Adds an argument to the list of arguments to be parsed.
- Parameters:
-
[in] a Argument to be added.
Definition at line 877 of file CmdLine.cxx.
void basis::CmdLine::add | ( | Arg * | a | ) |
An alternative add. Functionally identical.
- Parameters:
-
[in] a Argument to be added.
Definition at line 883 of file CmdLine.cxx.
std::string& basis::CmdLine::getContact | ( | ) | [inline] |
std::string& basis::CmdLine::getCopyright | ( | ) | [inline] |
std::string& basis::CmdLine::getDescription | ( | ) | [inline] |
std::vector<std::string>& basis::CmdLine::getExamples | ( | ) | [inline] |
std::string& basis::CmdLine::getLicense | ( | ) | [inline] |
std::string& basis::CmdLine::getProgramName | ( | ) | [inline] |
std::string& basis::CmdLine::getProjectName | ( | ) | [inline] |
XorHandler& basis::CmdLine::getXorHandler | ( | ) | [inline] |
void basis::CmdLine::parse | ( | int | argc, |
const char *const * | argv | ||
) |
Parses the command line.
- Parameters:
-
[in] argc Number of arguments. [in] argv Array of arguments.
Definition at line 933 of file CmdLine.cxx.
void basis::CmdLine::parse | ( | std::vector< std::string > & | args | ) |
Parses the command line.
- Parameters:
-
[in] args A vector of strings representing the args. args[0] is still the program name.
Definition at line 941 of file CmdLine.cxx.
void basis::CmdLine::print_help | ( | ) | const |
Print help.
Definition at line 904 of file CmdLine.cxx.
void basis::CmdLine::print_usage | ( | ) | const |
Print short help, i.e., usage information.
Definition at line 898 of file CmdLine.cxx.
void basis::CmdLine::print_version | ( | ) | const |
Print version information.
Definition at line 912 of file CmdLine.cxx.
void basis::CmdLine::setup | ( | bool | stdargs | ) | [protected] |
Set up command-line object.
Definition at line 814 of file CmdLine.cxx.
Add two Args that will be xor'd.
If this method is used, add does not need to be called.
- Parameters:
-
[in] a Argument to be added and xor'd. [in] b Argument to be added and xor'd.
Definition at line 889 of file CmdLine.cxx.
void basis::CmdLine::xorAdd | ( | std::vector< Arg * > & | xors | ) |
Add a list of arguments that will be xor'd.
If this method is used, add does not need to be called.
- Parameters:
-
[in] xors List of Args to be added and xor'd.
Definition at line 918 of file CmdLine.cxx.
Member Data Documentation
std::string basis::CmdLine::_contact [protected] |
std::string basis::CmdLine::_copyright [protected] |
std::vector<std::string> basis::CmdLine::_examples [protected] |
std::string basis::CmdLine::_license [protected] |
std::string basis::CmdLine::_name [protected] |
std::string basis::CmdLine::_project [protected] |
XorHandler basis::CmdLine::_xorHandler [protected] |
Customized XorHandler.
The documentation for this class was generated from the following files: