tclap  1.4.0
Public Member Functions | Protected Member Functions | List of all members
TCLAP::StdOutput Class Reference

A class that isolates any output from the CmdLine object so that it may be easily modified. More...

#include <StdOutput.h>

Inheritance diagram for TCLAP::StdOutput:
Inheritance graph
[legend]
Collaboration diagram for TCLAP::StdOutput:
Collaboration graph
[legend]

Public Member Functions

virtual void usage (CmdLineInterface &c)
 Prints the usage to stdout. More...
 
virtual void version (CmdLineInterface &c)
 Prints the version to stdout. More...
 
virtual void failure (CmdLineInterface &c, ArgException &e)
 Prints (to stderr) an error message, short usage Can be overridden to produce alternative behavior. More...
 
- Public Member Functions inherited from TCLAP::CmdLineOutput
virtual ~CmdLineOutput ()
 Virtual destructor. More...
 

Protected Member Functions

void _shortUsage (CmdLineInterface &c, std::ostream &os) const
 Writes a brief usage message with short args. More...
 
void _longUsage (CmdLineInterface &c, std::ostream &os) const
 Writes a longer usage message with long and short args, provides descriptions and prints message. More...
 
void spacePrint (std::ostream &os, const std::string &s, int maxWidth, int indentSpaces, int secondLineOffset) const
 This function inserts line breaks and indents long strings according the params input. More...
 

Detailed Description

A class that isolates any output from the CmdLine object so that it may be easily modified.

Definition at line 46 of file StdOutput.h.

Member Function Documentation

◆ _longUsage()

void TCLAP::StdOutput::_longUsage ( CmdLineInterface c,
std::ostream &  os 
) const
inlineprotected

Writes a longer usage message with long and short args, provides descriptions and prints message.

Parameters
c- The CmdLine object the output is generated for.
os- The stream to write the message to.

Definition at line 379 of file StdOutput.h.

References TCLAP::ArgGroup::begin(), TCLAP::CountVisibleArgs(), TCLAP::ArgGroup::end(), TCLAP::CmdLineInterface::getArgGroups(), TCLAP::Arg::getDescription(), TCLAP::CmdLineInterface::getMessage(), TCLAP::Arg::hasLabel(), TCLAP::ArgGroup::isExclusive(), TCLAP::ArgGroup::isRequired(), TCLAP::Arg::isRequired(), TCLAP::Arg::longID(), spacePrint(), and TCLAP::Arg::visibleInHelp().

Referenced by usage().

Here is the call graph for this function:

◆ _shortUsage()

void TCLAP::StdOutput::_shortUsage ( CmdLineInterface _cmd,
std::ostream &  os 
) const
inlineprotected

Writes a brief usage message with short args.

Usage statements should look like the manual pages.

Parameters
c- The CmdLine object the output is generated for.
os- The stream to write the message to.

Options w/o operands come first, in alphabetical order inside a single set of braces, upper case before lower case (AaBbCc...). Next are options with operands, in the same order, each in braces. Then required arguments in the order they are specified, followed by optional arguments in the order they are specified. A bar (`|') separates either/or options/arguments, and multiple options/arguments which are specified together are placed in a single set of braces.

Use getprogname() instead of hardcoding the program name.

"usage: f [-aDde] [-b b_arg] [-m m_arg] req1 req2 [opt1 [opt2]]\n" "usage: f [-a | -b] [-c [-de] [-n number]]\n"

Definition at line 224 of file StdOutput.h.

References TCLAP::ArgGroup::begin(), TCLAP::cmpSwitch(), TCLAP::internal::CompareOptions(), TCLAP::internal::CompareShortID(), TCLAP::CountVisibleArgs(), TCLAP::ArgGroup::end(), TCLAP::Arg::flagStartString(), TCLAP::CmdLineInterface::getArgGroups(), TCLAP::Arg::getName(), TCLAP::CmdLineInterface::getProgramName(), TCLAP::Arg::hasLabel(), TCLAP::Arg::ignoreNameString(), TCLAP::ArgGroup::isRequired(), TCLAP::Arg::isRequired(), TCLAP::Arg::isValueRequired(), TCLAP::internal::IsVisibleLongSwitch(), TCLAP::internal::IsVisibleOption(), TCLAP::internal::IsVisibleShortSwitch(), TCLAP::Arg::shortID(), spacePrint(), and TCLAP::Arg::visibleInHelp().

Referenced by failure(), and usage().

Here is the call graph for this function:

◆ failure()

void TCLAP::StdOutput::failure ( CmdLineInterface c,
ArgException e 
)
inlinevirtual

Prints (to stderr) an error message, short usage Can be overridden to produce alternative behavior.

Parameters
c- The CmdLine object the output is generated for.
e- The ArgException that caused the failure.

Implements TCLAP::CmdLineOutput.

Definition at line 122 of file StdOutput.h.

References _shortUsage(), TCLAP::ArgException::argId(), TCLAP::ArgException::error(), TCLAP::CmdLineInterface::getProgramName(), TCLAP::CmdLineInterface::hasHelpAndVersion(), TCLAP::Arg::nameStartString(), and usage().

Here is the call graph for this function:

◆ spacePrint()

void TCLAP::StdOutput::spacePrint ( std::ostream &  os,
const std::string &  s,
int  maxWidth,
int  indentSpaces,
int  secondLineOffset 
) const
inlineprotected

This function inserts line breaks and indents long strings according the params input.

It will only break lines at spaces, commas and pipes.

Parameters
os- The stream to be printed to.
s- The string to be printed.
maxWidth- The maxWidth allowed for the output line.
indentSpaces- The number of spaces to indent the first line.
secondLineOffset- The number of spaces to indent the second and all subsequent lines in addition to indentSpaces.

Definition at line 489 of file StdOutput.h.

Referenced by _longUsage(), and _shortUsage().

◆ usage()

void TCLAP::StdOutput::usage ( CmdLineInterface c)
inlinevirtual

Prints the usage to stdout.

Can be overridden to produce alternative behavior.

Parameters
c- The CmdLine object the output is generated for.

Implements TCLAP::CmdLineOutput.

Definition at line 110 of file StdOutput.h.

References _longUsage(), and _shortUsage().

Referenced by failure().

Here is the call graph for this function:

◆ version()

void TCLAP::StdOutput::version ( CmdLineInterface c)
inlinevirtual

Prints the version to stdout.

Can be overridden to produce alternative behavior.

Parameters
c- The CmdLine object the output is generated for.

Implements TCLAP::CmdLineOutput.

Definition at line 101 of file StdOutput.h.

References TCLAP::CmdLineInterface::getProgramName(), and TCLAP::CmdLineInterface::getVersion().

Here is the call graph for this function:

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