AJA NTV2 SDK  17.1.1.1245
NTV2 SDK 17.1.1.1245
AJACommandLineParser Class Reference

#include <commandline.h>

Public Member Functions

 AJACommandLineParser (int flags=0)
 
 AJACommandLineParser (const std::string &name, int flags=0)
 
 AJACommandLineParser (const AJACommandLineParser &other)
 
 ~AJACommandLineParser ()
 
void operator= (const AJACommandLineParser &other)
 
void Reset (bool clearAll=false)
 
void Dump ()
 
bool OptionByName (const std::string &name, AJACommandLineOption &opt) const
 
bool AddSubParser (AJACommandLineParser *sp)
 
void ParseArgs (const AJAStringList &args)
 
void ParseArgs (int argc, const char *argv[])
 
void ParseArgs (int argc, char *argv[])
 
bool IsSet (const std::string &name) const
 
AJAVariant Value (const std::string &name, size_t index=0) const
 
AJAVariantList Values (const std::string &name) const
 
std::string ValueString (const std::string &name, size_t index=0) const
 
AJAStringList ValueStrings (const std::string &name) const
 
bool AddOption (const AJACommandLineOption &option)
 
bool AddOptions (const std::vector< AJACommandLineOption > &options)
 
bool AddHelpOption ()
 
std::string GetName () const
 
void SetUsageText (const std::string &usageText)
 
std::string GetUsageText () const
 
void SetHelpText (const std::string &helpText)
 
std::string GetHelpText () const
 
std::string GetCommandName ()
 
AJAStringList GetKnownOptions ()
 
AJAStringList GetUnknownOptions ()
 

Detailed Description

Class that represents a command line args parser.

Definition at line 139 of file commandline.h.

Constructor & Destructor Documentation

◆ AJACommandLineParser() [1/3]

AJACommandLineParser::AJACommandLineParser ( int  flags = 0)
explicit

Definition at line 144 of file commandline.cpp.

◆ AJACommandLineParser() [2/3]

AJACommandLineParser::AJACommandLineParser ( const std::string &  name,
int  flags = 0 
)
explicit

Definition at line 150 of file commandline.cpp.

◆ AJACommandLineParser() [3/3]

AJACommandLineParser::AJACommandLineParser ( const AJACommandLineParser other)

Definition at line 156 of file commandline.cpp.

◆ ~AJACommandLineParser()

AJACommandLineParser::~AJACommandLineParser ( )

Definition at line 161 of file commandline.cpp.

Member Function Documentation

◆ AddHelpOption()

bool AJACommandLineParser::AddHelpOption ( )

Add help option to this args parser. If -h/–help is specified from the command line, will print the help string.

Definition at line 486 of file commandline.cpp.

◆ AddOption()

bool AJACommandLineParser::AddOption ( const AJACommandLineOption option)

Add a command line option to this args parser. This method will fail if another option with the same name has already been added to this parser.

Parameters
[in]optionThe command line option to add.
Returns
true if option was added successfully, otherwise false.

Definition at line 451 of file commandline.cpp.

◆ AddOptions()

bool AJACommandLineParser::AddOptions ( const std::vector< AJACommandLineOption > &  options)

Add a list of command line options to this args parser. This method will fail if the list contains an option whose name has already been added to the args parser.

Parameters
[in]optionsThe list of command line options to add.
Returns
true if options are added successfully, otherwise false.

Definition at line 476 of file commandline.cpp.

◆ AddSubParser()

bool AJACommandLineParser::AddSubParser ( AJACommandLineParser sp)

Register another AJACommandLineParser instance with this parser.

Parameters
[in]spThe subparser to add.
Returns
Returns true if the subparser was added successfully, otherwise false.

Definition at line 240 of file commandline.cpp.

◆ Dump()

void AJACommandLineParser::Dump ( )

Definition at line 195 of file commandline.cpp.

◆ GetCommandName()

std::string AJACommandLineParser::GetCommandName ( )

Get the name of the command (if-any) represented by this args parser.

Returns
The command name string, if set, otherwise empty string.

Definition at line 632 of file commandline.cpp.

◆ GetHelpText()

std::string AJACommandLineParser::GetHelpText ( ) const

Get the help text string for this args parser.

Returns
The help text string, if set, otherwise empty string.

Definition at line 608 of file commandline.cpp.

◆ GetKnownOptions()

AJAStringList AJACommandLineParser::GetKnownOptions ( )

Get the list of known options parsed by this args parser from the command line.

Returns
A list of strings parsed from the command line recognized by this parser.

Definition at line 620 of file commandline.cpp.

◆ GetName()

std::string AJACommandLineParser::GetName ( ) const

Get the name of this command line args parser.

Returns
The name of the parser, if any has been set, otherwise empty string.

Definition at line 560 of file commandline.cpp.

◆ GetUnknownOptions()

AJAStringList AJACommandLineParser::GetUnknownOptions ( )

Get the list of unknown options parsed by this args parser from the command line.

Returns
A list of strings parsed from the command line not recognized by this parser.

Definition at line 637 of file commandline.cpp.

◆ GetUsageText()

std::string AJACommandLineParser::GetUsageText ( ) const

Get the usage text string for this args parser.

Returns
The usage text string, if set, otherwise empty string.

Definition at line 584 of file commandline.cpp.

◆ IsSet()

bool AJACommandLineParser::IsSet ( const std::string &  name) const

Tests if the specified arg was set on the command line.

Parameters
[in]nameThe arg name.
Returns
Returns true if the arg was set, otherwise false.

Definition at line 374 of file commandline.cpp.

◆ operator=()

void AJACommandLineParser::operator= ( const AJACommandLineParser other)

Definition at line 165 of file commandline.cpp.

◆ OptionByName()

bool AJACommandLineParser::OptionByName ( const std::string &  name,
AJACommandLineOption opt 
) const

Definition at line 223 of file commandline.cpp.

◆ ParseArgs() [1/3]

void AJACommandLineParser::ParseArgs ( const AJAStringList args)

Parse a list of strings containing command line args.

Parameters
[in]descThe list of arg strings.
Returns
Returns true if the command line args were parsed successfully, otherwise false.

Definition at line 271 of file commandline.cpp.

◆ ParseArgs() [2/3]

void AJACommandLineParser::ParseArgs ( int  argc,
char *  argv[] 
)

Parse a list of strings containing command line args.

Parameters
[in]argcThe arg count.
[in]argvThe list of arg strings.

Definition at line 362 of file commandline.cpp.

◆ ParseArgs() [3/3]

void AJACommandLineParser::ParseArgs ( int  argc,
const char *  argv[] 
)

Parse a list of strings containing command line args.

Parameters
[in]argcThe arg count.
[in]argvThe list of arg strings.

Definition at line 350 of file commandline.cpp.

◆ Reset()

void AJACommandLineParser::Reset ( bool  clearAll = false)

Definition at line 185 of file commandline.cpp.

◆ SetHelpText()

void AJACommandLineParser::SetHelpText ( const std::string &  helpText)

Set the help text string to print if help is invoked by the args parser.

Parameters
[in]nameThe help text string.

Definition at line 596 of file commandline.cpp.

◆ SetUsageText()

void AJACommandLineParser::SetUsageText ( const std::string &  usageText)

Set the usage text string to print if help is invoked by the args parser.

Parameters
[in]nameThe usage text string.

Definition at line 572 of file commandline.cpp.

◆ Value()

AJAVariant AJACommandLineParser::Value ( const std::string &  name,
size_t  index = 0 
) const

Get a variant representing the value of the specified arg name.

Parameters
[in]nameThe arg name.
[in]indexThe index of the value to get.
Returns
AJAVariant representing the arg value, if the arg was set, otherwise 0.

Definition at line 396 of file commandline.cpp.

◆ Values()

AJAVariantList AJACommandLineParser::Values ( const std::string &  name) const

Get a list of variants representing the values of the specified arg name.

Parameters
[in]nameThe arg name.
Returns
AJAVariantList of values, empty if no values set.

Definition at line 401 of file commandline.cpp.

◆ ValueString()

std::string AJACommandLineParser::ValueString ( const std::string &  name,
size_t  index = 0 
) const

Get the string value for the specified arg name.

Parameters
[in]nameThe arg name.
[in]indexThe index of value to get.
Returns
std::string value of the arg, if set, otherwise empty std::string.

Definition at line 414 of file commandline.cpp.

◆ ValueStrings()

AJAStringList AJACommandLineParser::ValueStrings ( const std::string &  name) const

Get a list of string values for the specified arg name.

Parameters
[in]nameThe arg name.
Returns
AJAStringList of string values, empty if no values set.

Definition at line 435 of file commandline.cpp.


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