yat  0.8.3pre
Public Member Functions | Protected Member Functions
theplu::yat::utility::OptionHelp Class Reference

Class for help option. More...

#include <yat/utility/OptionHelp.h>

Inheritance diagram for theplu::yat::utility::OptionHelp:
theplu::yat::utility::OptionSwitch theplu::yat::utility::Option

List of all members.

Public Member Functions

 OptionHelp (CommandLine &cmd, std::string name="h,help", std::string desc="display this help and exit")
 Constructor.
std::string & post_arguments (void)
std::string & synopsis (void)
std::string & usage (void)
bool value (void) const
 return value
std::string description (void) const
void description (const std::string &description)
 set description
std::string long_name (void) const
void parse (std::vector< std::string >::iterator &, const std::vector< std::string >::iterator &)
 parsing the commandline
bool present (void) const
 Get if option was found in cmd.
std::string print (void)
 print help output
void reset (void)
 sets present to false
char short_name (void) const
void validate (void)
 Validate the Option.

Protected Member Functions

const CommandLinecmd (void) const

Detailed Description

Class for help option.

When this option is found in parsing of commandline, it displays
a help output and exits. A typical output looks like:
     Usage: foo [OPTION]...

     SYNOPSIS

     Available options are:
     -h, --help      display this help and exit
     -v, --verbose   explain what is being done

     Some extra information explaining something.

The output consist of four blocks. The first block can be modified with usage(void) function. The second is block is typically a one-liner explaining the application and can be modified with the synopsis(void) function. The third block contain the description of the different options, see operator<<(std::ostream&, const CommandLine&) for further details. The last block can be modified with post_arguments(void) function.


Constructor & Destructor Documentation

theplu::yat::utility::OptionHelp::OptionHelp ( CommandLine cmd,
std::string  name = "h,help",
std::string  desc = "display this help and exit" 
)

Constructor.

Parameters:
cmdCommandline Option is associated with
namestring such as "help" for --help, "h" for -h or "h,help" (default) for having both short and long option name
descstring used in help display

Member Function Documentation

const CommandLine& theplu::yat::utility::Option::cmd ( void  ) const
protectedinherited
Returns:
const reference to CommandLine Option belongs to.
std::string theplu::yat::utility::Option::description ( void  ) const
inherited
Returns:
description
void theplu::yat::utility::Option::description ( const std::string &  description)
inherited

set description

Since:
New in yat 0.7
std::string theplu::yat::utility::Option::long_name ( void  ) const
inherited
Returns:
long name e.g. 'help' for --help option.

Text to be displayed after list of arguments.

bool theplu::yat::utility::Option::present ( void  ) const
inherited

Get if option was found in cmd.

Returns:
true if option has been detected in parsing
std::string theplu::yat::utility::Option::print ( void  )
inherited

print help output

This function calls the four virtual private functions print1, print2, print3, and print4. This allows an inherited class to implement one (or several) of these functions and keep the default output of the others. The default behavior is that:

char theplu::yat::utility::Option::short_name ( void  ) const
inherited
Returns:
short name e.g. 'h' for -h option.

Text to be displayed in help output after usage()

std::string& theplu::yat::utility::OptionHelp::usage ( void  )

First line to be displayed in help output. Default this string is set to "Usage: <program_name> [OPTION]...\n\n"

void theplu::yat::utility::Option::validate ( void  )
inherited

Validate the Option.

This function is called by CommandLine::parse() after all options have been detected and parsed (see Option::parse()).


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

Generated on Thu Dec 20 2012 03:13:00 for yat by  doxygen 1.8.0-20120409