PCL
pcl::Argument Class Reference

A command-line argument. More...

#include <Arguments.h>

Public Member Functions

 Argument ()
 
 Argument (const Argument &)=default
 
 Argument (const char16_type *argv)
 
 Argument (const String &argv)
 
 Argument (const String &argv, const StringList &items)
 
String Id () const
 
bool IsItemList () const
 
bool IsLiteral () const
 
bool IsNumeric () const
 
bool IsString () const
 
bool IsSwitch () const
 
bool IsValid () const
 
StringListItems ()
 
const StringListItems () const
 
double NumericValue () const
 
Argumentoperator= (const Argument &)=default
 
bool operator== (const Argument &x) const
 
String StringValue () const
 
bool SwitchState () const
 
String Token () const
 

Detailed Description

Argument implements a command-line argument that can be used with the ParseArguments() function.

Command-line arguments can be parametric and non-parametric arguments (also known as item arguments).

1. Parametric Arguments

Parametric arguments specify modifiers or parameter values of different types to their receiving processes. Syntactically, parametric arguments are formalized as:

-<arg_id>[<arg_value>]

where the starting hypen character '-' is the standard parameter prefix. <arg_id> is the argument identifier and <arg_value> is an optional argument value specification. For example, in the following parametric arguments:

-n=17 –use-all-processors

the argument identifiers are 'n' and '-use-all-processors', respectively, and '=17' is an argument value specification.

We consider four types of parametric arguments: literal, switch, numeric and string arguments.

1.1 Literal Arguments

Literal arguments are parametric arguments that don't have a particular value. They are modifiers that act as functions of their existence. For example, in the following arguments:

-c -x=10 -b="none" –verbose

'-c' and '–verbose' are literal arguments.

1.2 Switch Arguments

Switch arguments are parametric arguments that can only have a boolean enabled/disabled state. Switch arguments are of the form:

-<arg_id>+|-

where the + suffix means 'enabled' and the - suffix means 'disabled'. For example, here are some switch arguments:

-u+ -color- –mySwitchArgument+

It is customary to allow the use of switch arguments also as literal arguments. When switch arguments are used as literal arguments, a default 'enabled' or 'disabled' state is assumed, depending on the functionality and purpose of each argument. When switch arguments can also be literal, they are formalized as:

-<arg_id>[+|-]

indicating that the + and - suffixes are optional.

1.3 Numeric Arguments

A numeric argument has an integer or floating-point numeric value. Numeric arguments are formalized as:

-<arg_id>=<numeric_constant>

where <numeric_constant> is a valid representation of an integer or floating-point real constant, following the applicable syntax rules of the C language. Integer constants can have the '0x' standard prefix to indicate hexadecimal values.

1.4 String Arguments

A string argument has a literal value represented as a string of ISO 8859-1 characters. String arguments are formalized as:

-<arg_id>=<string_constant>

where <string_constant> is any sequence of ISO 8859-1 characters, optionally enclosed by double quotes. For example:

-s=foo -s1="bar"

are two string arguments with 'foo' and 'bar' values, respectively. When the <string_constant> string includes white spaces, the enclosing quotes are not optional, as in:

-aStringArg="this is a string literal"

or otherwise the above sequence would be interpreted as a single string argument (aStringArg=this) and four additional, non-parametric arguments.

2. Non-Parametric Arguments

Non-parametric arguments specify objects that their receiving processes can act on or use in any way. Non-parametric arguments are formalized as:

<arg_value>

where <arg_value> is any sequence of ISO 8859-1 characters. Note that the absence of a standard parameter prefix (the hypen character, '-') characterizes non-parametric arguments. For example, in the following arguments:

-mode="auto" *.js -z foo.scp

'*.js' and 'foo.scp' are two non-parametric arguments.

Each non-parametric argument can be expanded into a list of items. For example, the '*.js' argument above would be expanded into a list of all files with the .js suffix in the current directory, provided that the argument is parsed as a wild file path specification.

See also
ParseArguments(), ArgumentItemMode, ArgumentOption

Definition at line 195 of file Arguments.h.

Constructor & Destructor Documentation

◆ Argument() [1/5]

pcl::Argument::Argument ( )
inline

Constructs an empty Argument object.

Definition at line 202 of file Arguments.h.

◆ Argument() [2/5]

pcl::Argument::Argument ( const String argv)
inline

Constructs an Argument object and parses the specified argv string.

Definition at line 210 of file Arguments.h.

References pcl::GenericString< T, R, A >::c_str().

◆ Argument() [3/5]

pcl::Argument::Argument ( const char16_type argv)
inline

Constructs an Argument object and parses the specified argv string.

Definition at line 218 of file Arguments.h.

◆ Argument() [4/5]

pcl::Argument::Argument ( const String argv,
const StringList items 
)
inline

Constructs an Argument object and interprets that the specified argv string corresponds to a non-parametric argument corresponding to the items list of items.

Definition at line 228 of file Arguments.h.

◆ Argument() [5/5]

pcl::Argument::Argument ( const Argument )
default

Copy constructor.

Member Function Documentation

◆ Id()

String pcl::Argument::Id ( ) const
inline

Returns the argument's parameter identifier, if this argument has been parsed and it is a parametric argument, or an empty string otherwise.

Definition at line 290 of file Arguments.h.

◆ IsItemList()

bool pcl::Argument::IsItemList ( ) const
inline

Returns true iff this argument has been parsed and it is a non-parametric argument, also known as an item argument.

Definition at line 300 of file Arguments.h.

◆ IsLiteral()

bool pcl::Argument::IsLiteral ( ) const
inline

Returns true iff this argument has been parsed and it is a literal argument.

Definition at line 331 of file Arguments.h.

◆ IsNumeric()

bool pcl::Argument::IsNumeric ( ) const
inline

Returns true iff this argument has been parsed and it is a numeric argument.

Definition at line 358 of file Arguments.h.

◆ IsString()

bool pcl::Argument::IsString ( ) const
inline

Returns true iff this argument has been parsed and it is a string argument.

Definition at line 376 of file Arguments.h.

◆ IsSwitch()

bool pcl::Argument::IsSwitch ( ) const
inline

Returns true iff this argument has been parsed and it is a switch argument.

Definition at line 340 of file Arguments.h.

◆ IsValid()

bool pcl::Argument::IsValid ( ) const
inline

Returns true iff this argument has successfully parsed a token string.

Definition at line 270 of file Arguments.h.

◆ Items() [1/2]

StringList& pcl::Argument::Items ( )
inline

Returns a reference to the list of items that have been generated after expansion of a non-parametric argument. The returned list can be freely modified, and it's empty if this argument is parametric, or if it has not been parsed yet.

Definition at line 322 of file Arguments.h.

◆ Items() [2/2]

const StringList& pcl::Argument::Items ( ) const
inline

Returns a reference to the (constant) list of items that have been generated after expansion of a non-parametric argument. The returned list cannot be modified, and it's empty if this argument is parametric, or if it has not been parsed yet.

Definition at line 311 of file Arguments.h.

◆ NumericValue()

double pcl::Argument::NumericValue ( ) const
inline

Returns the numeric value of this argument, if it has been parsed and it is a numeric argument, or zero otherwise.

Definition at line 367 of file Arguments.h.

◆ operator=()

Argument& pcl::Argument::operator= ( const Argument )
default

Copy assignment operator. Returns a reference to this object.

◆ operator==()

bool pcl::Argument::operator== ( const Argument x) const
inline

Equality operator. Returns true if this Argument object is equal to the specified x instance.

Definition at line 249 of file Arguments.h.

References pcl::ProcessParameterType::IsNumeric().

◆ StringValue()

String pcl::Argument::StringValue ( ) const
inline

Returns the string value of this argument, if it has been parsed and it is a string argument, or an empty string otherwise.

Definition at line 385 of file Arguments.h.

◆ SwitchState()

bool pcl::Argument::SwitchState ( ) const
inline

Returns the switch state of this argument, if it has been parsed and it is a switch argument, or false otherwise.

Definition at line 349 of file Arguments.h.

◆ Token()

String pcl::Argument::Token ( ) const
inline

Returns the token string corresponding to this argument. The token is the exact string that has been parsed by this Argument instance. If no token has been parsed by this instance, an empty string is returned.

Definition at line 280 of file Arguments.h.


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