BASIS  r3148
basis::CmdLine Class Reference

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

#include <CmdLine.h>

+ Collaboration diagram for basis::CmdLine:

List of all members.

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 &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.
 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.
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.
XorHandlergetXorHandler ()
 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.

Definition at line 33 of file CmdLine.h.


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]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 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]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 791 of file CmdLine.cxx.

virtual basis::CmdLine::~CmdLine ( ) [inline, virtual]

Destructor.

Definition at line 144 of file CmdLine.h.


Member Function Documentation

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 877 of file CmdLine.cxx.

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

An alternative add. Functionally identical.

Parameters:
[in]aArgument to be added.

Definition at line 883 of file CmdLine.cxx.

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

Get contact information.

Returns:
Contact information.

Definition at line 273 of file CmdLine.h.

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

Get copyright notice.

Returns:
Copyright information of program.

Definition at line 259 of file CmdLine.h.

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

Get program description.

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

Definition at line 245 of file CmdLine.h.

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

Get usage example.

Returns:
Example command-line usage.

Definition at line 252 of file CmdLine.h.

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

Get license information.

Returns:
License information of program.

Definition at line 266 of file CmdLine.h.

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

Get name of program.

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

Definition at line 231 of file CmdLine.h.

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 238 of file CmdLine.h.

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

Get handler of XOR'd arguments.

Definition at line 278 of file CmdLine.h.

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 933 of file CmdLine.cxx.

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 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.

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 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]xorsList 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]

Contact information.

Definition at line 306 of file CmdLine.h.

std::string basis::CmdLine::_copyright [protected]

Program copyright.

Definition at line 304 of file CmdLine.h.

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

Program usage example.

Definition at line 303 of file CmdLine.h.

std::string basis::CmdLine::_license [protected]

Program license.

Definition at line 305 of file CmdLine.h.

std::string basis::CmdLine::_name [protected]

Program name.

Definition at line 301 of file CmdLine.h.

std::string basis::CmdLine::_project [protected]

Name of project.

Definition at line 302 of file CmdLine.h.

Customized XorHandler.

Definition at line 300 of file CmdLine.h.


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