Joutsen.ArgumentsParsing v0.3.0+1-ga4c84ed
Public Member Functions | Protected Member Functions | Protected Attributes | Properties | List of all members
Joutsen.ArgumentsParsing.AbstractDisplayArgument Class Reference

A base class that can be used to easily create implementations of DisplayArgument. More...

Public Member Functions

 AbstractDisplayArgument (String name, String alternative, DisplayException displayException, String help)
 Creates a new instance. More...
 
string Usage (string name=null)
 Fetches the usage description of this argument. More...
 
string Description (string name=null, string alternative=null)
 Fetches the description of this argument. More...
 
virtual ArgumentLiteralParser GetParser ()
 Fetchs the literal parser for this argument. More...
 
object SetDefaultValue (object target, string name=null)
 Sets the default value of the argument to a target object. More...
 
virtual ParseResult Parse (ArgumentsIterator args, object target, string name=null)
 Parses the relevant argument in the list and modifies the target object with it. More...
 
string Description (string name=null, string alternative=null)
 Fetches the description of this argument. More...
 
string Usage (string name=null)
 Fetches the usage description of this argument. More...
 
ArgumentLiteralParser GetParser ()
 Fetchs the literal parser for this argument. More...
 
ParseResult Parse (ArgumentsIterator args, object target, string name=null)
 Parses the relevant argument in the list and modifies the target object with it. More...
 
void Reset ()
 Clears the parsers state if any in order to prepare it for a new run. More...
 
object SetDefaultValue (object target, string name=null)
 Sets the default value of the argument to a target object. More...
 

Protected Member Functions

virtual bool MatchesArgument (String argument)
 Checks if an input value matches the argument's name or alternative name. More...
 

Protected Attributes

String help
 
DisplayArgumentParser parser
 

Properties

bool IsRequired [get]
 
virtual bool IsFlag [get]
 Determines if this argument is nearly a flag (name only) or uses values. More...
 
string Name [get]
 The name that identifies the argument in the input list. More...
 
string Alternative [get]
 The alternative name that identifies the argument in the input list. More...
 
- Properties inherited from Joutsen.ArgumentsParsing.DisplayArgument
String Name [get]
 The name that identifies the argument in the input list. More...
 
String Alternative [get]
 The alternative name that identifies the argument in the input list. More...
 
- Properties inherited from Joutsen.ArgumentsParsing.ArgumentLiteralParser
ArgumentsListParser ParentParser [set]
 The list parser this literal parser belongs to. More...
 
bool IsFlag [get]
 Determines if this argument is nearly a flag (name only) or uses values. More...
 

Detailed Description

A base class that can be used to easily create implementations of DisplayArgument.

Since
0.2.0

Constructor & Destructor Documentation

◆ AbstractDisplayArgument()

Joutsen.ArgumentsParsing.AbstractDisplayArgument.AbstractDisplayArgument ( String  name,
String  alternative,
DisplayException  displayException,
String  help 
)

Creates a new instance.

Parameters
namethe name that identifies the argument in the input list
alternativethe alternative name that identifies the argument in the input list
helpadditional description that will be part of this arguments description

Member Function Documentation

◆ Description()

string Joutsen.ArgumentsParsing.AbstractDisplayArgument.Description ( string  name = null,
string  alternative = null 
)

Fetches the description of this argument.

Parameters
namefor arguments that are identified by their name in the input string, the name to incorporate into the description
alternativefor arguments that are identified by their alternative name in the input string, the alternative name to incorporate into the description
Returns
the description

Implements Joutsen.ArgumentsParsing.ParserArgument.

◆ GetParser()

virtual ArgumentLiteralParser Joutsen.ArgumentsParsing.AbstractDisplayArgument.GetParser ( )
virtual

Fetchs the literal parser for this argument.

Implements Joutsen.ArgumentsParsing.ParserArgument.

◆ MatchesArgument()

virtual bool Joutsen.ArgumentsParsing.AbstractDisplayArgument.MatchesArgument ( String  argument)
protectedvirtual

Checks if an input value matches the argument's name or alternative name.

◆ Parse()

virtual ParseResult Joutsen.ArgumentsParsing.AbstractDisplayArgument.Parse ( ArgumentsIterator  args,
object  target,
string  name = null 
)
virtual

Parses the relevant argument in the list and modifies the target object with it.

Parameters
argsthe list of input strings that need to be parsed
targetthe receiver of the parsed values
namean optional name of the argument that is being parsed. This is usually only used for arguments that are identified by their name.
Returns
the modified target object and the arguments that still need to be parsed as a PareseResult instance.

Implements Joutsen.ArgumentsParsing.ArgumentLiteralParser.

◆ SetDefaultValue()

object Joutsen.ArgumentsParsing.AbstractDisplayArgument.SetDefaultValue ( object  target,
string  name = null 
)

Sets the default value of the argument to a target object.

Parameters
targetthe receiver of the default value
namean optional name of this argument. This is usually only used for arguments that are identified by their name.
Returns
the modified target object
Remarks
This method is used for optional arguments which were not parsed because of a value in the input list. Implementations should raise an exception if the argument is mandatory or return the unmodified target object if they do not offer a default value.
Since
0.2.0

Implements Joutsen.ArgumentsParsing.ArgumentLiteralParser.

◆ Usage()

string Joutsen.ArgumentsParsing.AbstractDisplayArgument.Usage ( string  name = null)

Fetches the usage description of this argument.

Parameters
namefor arguments that are identified by their name in the input string, the name to incorporate into the description
Returns
the usage description

Implements Joutsen.ArgumentsParsing.ParserArgument.

Member Data Documentation

◆ help

String Joutsen.ArgumentsParsing.AbstractDisplayArgument.help
protected

◆ parser

DisplayArgumentParser Joutsen.ArgumentsParsing.AbstractDisplayArgument.parser
protected

Property Documentation

◆ Alternative

string Joutsen.ArgumentsParsing.AbstractDisplayArgument.Alternative
get

The alternative name that identifies the argument in the input list.

Implements Joutsen.ArgumentsParsing.DisplayArgument.

◆ IsFlag

virtual bool Joutsen.ArgumentsParsing.AbstractDisplayArgument.IsFlag
get

Determines if this argument is nearly a flag (name only) or uses values.

Since
0.2.0

Implements Joutsen.ArgumentsParsing.ArgumentLiteralParser.

◆ IsRequired

bool Joutsen.ArgumentsParsing.AbstractDisplayArgument.IsRequired
get

◆ Name

string Joutsen.ArgumentsParsing.AbstractDisplayArgument.Name
get

The name that identifies the argument in the input list.

Implements Joutsen.ArgumentsParsing.DisplayArgument.