Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
basis::CmdLine Class Reference

Manages command line definition and parsing of arguments. More...

#include <CmdLine.h>

+ Inheritance diagram for basis::CmdLine:
+ Collaboration diagram for basis::CmdLine:

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. More...
 
void add (Arg *a)
 An alternative add. Functionally identical. More...
 
 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 http://www.rad.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. More...
 
 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 http://www.rad.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. More...
 
std::string & getContact ()
 Get contact information. More...
 
std::string & getCopyright ()
 Get copyright notice. More...
 
std::string & getDescription ()
 Get program description. More...
 
std::vector< std::string > & getExamples ()
 Get usage example. More...
 
std::string & getLicense ()
 Get license information. More...
 
std::string & getProgramName ()
 Get name of program. More...
 
std::string & getProjectName ()
 Get name of project the program belongs to. More...
 
XorHandlergetXorHandler ()
 Get handler of XOR'd arguments. More...
 
void parse (int argc, const char *const *argv)
 Parses the command line. More...
 
void parse (std::vector< std::string > &args)
 Parses the command line. More...
 
void print_help () const
 Print help. More...
 
void print_usage () const
 Print short help, i.e., usage information. More...
 
void print_version () const
 Print version information. More...
 
void xorAdd (Arg &a, Arg &b)
 Add two Args that will be xor'd. More...
 
void xorAdd (std::vector< Arg *> &xors)
 Add a list of arguments that will be xor'd. More...
 
virtual ~CmdLine ()
 Destructor. More...
 

Protected Member Functions

void setup (bool stdargs)
 Set up command-line object. More...
 

Protected Attributes

std::string _contact
 Contact information. More...
 
std::string _copyright
 Program copyright. More...
 
std::vector< std::string > _examples
 Program usage example. More...
 
std::string _license
 Program license. More...
 
std::string _name
 Program name. More...
 
std::string _project
 Name of project. More...
 
XorHandler _xorHandler
 Customized XorHandler. More...
 

Detailed Description

Manages command line definition and parsing of arguments.

Copyright (c) 2011 University of Pennsylvania. All rights reserved.
See http://www.rad.upenn.edu/sbia/software/license.html or COPYING file.

Definition at line 37 of file CmdLine.h.

Constructor & Destructor Documentation

§ CmdLine() [1/2]

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 http://www.rad.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]nameProgram name. Should be a constant string which helps to identify the program, not the name of the executable as determined at runtime.
[in]projectName of project this program belongs to.
[in]descriptionProgram description.
[in]exampleUsage example.
[in]versionProgram version.
[in]copyrightCopyright notice.
[in]licenseLicense information.
[in]contactContact information.
[in]stdargsEnable/disable handling of standard arguments.

Definition at line 772 of file CmdLine.cxx.

§ CmdLine() [2/2]

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 http://www.rad.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]nameProgram name. Should be a constant string which helps to identify the program, not the name of the executable as determined at runtime.
[in]projectName of project this program belongs to.
[in]descriptionProgram description.
[in]examplesUsage examples.
[in]versionProgram version.
[in]copyrightCopyright notice.
[in]licenseLicense information.
[in]contactContact information.
[in]stdargsEnable/disable handling of standard arguments.

Definition at line 795 of file CmdLine.cxx.

§ ~CmdLine()

virtual basis::CmdLine::~CmdLine ( )
inlinevirtual

Destructor.

Definition at line 148 of file CmdLine.h.

Member Function Documentation

§ add() [1/2]

void basis::CmdLine::add ( Arg a)

Adds an argument to the list of arguments to be parsed.

Parameters
[in]aArgument to be added.

Definition at line 881 of file CmdLine.cxx.

§ add() [2/2]

void basis::CmdLine::add ( Arg a)

An alternative add. Functionally identical.

Parameters
[in]aArgument to be added.

Definition at line 887 of file CmdLine.cxx.

§ getContact()

std::string& basis::CmdLine::getContact ( )
inline

Get contact information.

Returns
Contact information.

Definition at line 277 of file CmdLine.h.

§ getCopyright()

std::string& basis::CmdLine::getCopyright ( )
inline

Get copyright notice.

Returns
Copyright information of program.

Definition at line 263 of file CmdLine.h.

§ getDescription()

std::string& basis::CmdLine::getDescription ( )
inline

Get program description.

Returns
Description of program this command-line object belongs to.

Definition at line 249 of file CmdLine.h.

§ getExamples()

std::vector<std::string>& basis::CmdLine::getExamples ( )
inline

Get usage example.

Returns
Example command-line usage.

Definition at line 256 of file CmdLine.h.

§ getLicense()

std::string& basis::CmdLine::getLicense ( )
inline

Get license information.

Returns
License information of program.

Definition at line 270 of file CmdLine.h.

§ getProgramName()

std::string& basis::CmdLine::getProgramName ( )
inline

Get name of program.

Returns
Name of program this command-line object belongs to.

Definition at line 235 of file CmdLine.h.

§ getProjectName()

std::string& basis::CmdLine::getProjectName ( )
inline

Get name of project the program belongs to.

Returns
Name of project this program belongs to.

Definition at line 242 of file CmdLine.h.

§ getXorHandler()

XorHandler& basis::CmdLine::getXorHandler ( )
inline

Get handler of XOR'd arguments.

Definition at line 282 of file CmdLine.h.

§ parse() [1/2]

void basis::CmdLine::parse ( int  argc,
const char *const *  argv 
)

Parses the command line.

Parameters
[in]argcNumber of arguments.
[in]argvArray of arguments.

Definition at line 937 of file CmdLine.cxx.

§ parse() [2/2]

void basis::CmdLine::parse ( std::vector< std::string > &  args)

Parses the command line.

Parameters
[in]argsA vector of strings representing the args. args[0] is still the program name.

Definition at line 945 of file CmdLine.cxx.

§ print_help()

void basis::CmdLine::print_help ( ) const

Print help.

Definition at line 908 of file CmdLine.cxx.

§ print_usage()

void basis::CmdLine::print_usage ( ) const

Print short help, i.e., usage information.

Definition at line 902 of file CmdLine.cxx.

§ print_version()

void basis::CmdLine::print_version ( ) const

Print version information.

Definition at line 916 of file CmdLine.cxx.

§ setup()

void basis::CmdLine::setup ( bool  stdargs)
protected

Set up command-line object.

Definition at line 818 of file CmdLine.cxx.

§ xorAdd() [1/2]

void basis::CmdLine::xorAdd ( Arg a,
Arg b 
)

Add two Args that will be xor'd.

If this method is used, add does not need to be called.

Parameters
[in]aArgument to be added and xor'd.
[in]bArgument to be added and xor'd.

Definition at line 893 of file CmdLine.cxx.

§ xorAdd() [2/2]

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]xorsList of Args to be added and xor'd.

Definition at line 922 of file CmdLine.cxx.

Member Data Documentation

§ _contact

std::string basis::CmdLine::_contact
protected

Contact information.

Definition at line 310 of file CmdLine.h.

§ _copyright

std::string basis::CmdLine::_copyright
protected

Program copyright.

Definition at line 308 of file CmdLine.h.

§ _examples

std::vector<std::string> basis::CmdLine::_examples
protected

Program usage example.

Definition at line 307 of file CmdLine.h.

§ _license

std::string basis::CmdLine::_license
protected

Program license.

Definition at line 309 of file CmdLine.h.

§ _name

std::string basis::CmdLine::_name
protected

Program name.

Definition at line 305 of file CmdLine.h.

§ _project

std::string basis::CmdLine::_project
protected

Name of project.

Definition at line 306 of file CmdLine.h.

§ _xorHandler

XorHandler basis::CmdLine::_xorHandler
protected

Customized XorHandler.

Definition at line 304 of file CmdLine.h.


The documentation for this class was generated from the following files: