yat  0.21pre
Public Member Functions | Protected Member Functions | List of all members
theplu::yat::utility::OptionVersion Class Reference

Class for version option. More...

#include <yat/utility/OptionVersion.h>

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

Public Member Functions

 OptionVersion (CommandLine &cmd, const std::string &prog, const std::string &version, const std::string &copyright_year, const std::vector< std::string > &authors, const std::string &package="", const std::string &name="v,version", const std::string &desc="output version information and exit")
 Constructor. More...
 
std::string & copyright_holder (void)
 
std::string & license (void)
 
bool value (void) const
 return value
 
std::string description (void) const
 
void description (const std::string &description)
 set description More...
 
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. More...
 
std::string print (void)
 print help output More...
 
void reset (void)
 sets present to false
 
char short_name (void) const
 
void validate (void)
 Validate the Option. More...
 

Protected Member Functions

const CommandLinecmd (void) const
 

Detailed Description

Class for version option.

When this option is found in parsing of commandline, it displays a version output and exits. A typical output looks like:

<prog> (<package>) <version>
Copyright (C) 2022 John Doe and Jane Doe
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Since
New in yat 0.20

Constructor & Destructor Documentation

◆ OptionVersion()

theplu::yat::utility::OptionVersion::OptionVersion ( CommandLine cmd,
const std::string &  prog,
const std::string &  version,
const std::string &  copyright_year,
const std::vector< std::string > &  authors,
const std::string &  package = "",
const std::string &  name = "v,version",
const std::string &  desc = "output version information and exit" 
)

Constructor.

Parameters
cmdCommandline object
progname of the program
versionstring typically taken from PACKAGE_VERSION or VERSION defined in config.h
copyright_yearYear in 'Copyright (C) Year...'
authorsauthors
packageif not empty, '(package) ' is added between program name and version
namedefault "v,version" implies object is associated with switches -v and –version
descstring output in help output (OptionHelp)

Member Function Documentation

◆ cmd()

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

◆ copyright_holder()

std::string& theplu::yat::utility::OptionVersion::copyright_holder ( void  )

Function to change the copyright holder. The default behaviour is to set copyright holder from authors passed in constructor. If the copyright holder is altered and additional line is added at the bottom:

Written by <authors>

◆ description() [1/2]

std::string theplu::yat::utility::Option::description ( void  ) const
inherited
Returns
description

◆ description() [2/2]

void theplu::yat::utility::Option::description ( const std::string &  description)
inherited

set description

Since
New in yat 0.7

◆ license()

std::string& theplu::yat::utility::OptionVersion::license ( void  )

Change the license information from the default

License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

◆ long_name()

std::string theplu::yat::utility::Option::long_name ( void  ) const
inherited
Returns
long name e.g. 'help' for –help option.

◆ present()

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

◆ print()

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:

◆ short_name()

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

◆ validate()

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 Wed Jan 25 2023 03:34:29 for yat by  doxygen 1.8.14