Joutsen.ArgumentsParsing v0.3.0+1-ga4c84ed
Public Member Functions | Properties | List of all members
Joutsen.ArgumentsParsing.TargetPropertyParser< ValueType > Class Template Reference

A literal parser that processes input literals for arguments that change properties on a target object. More...

Public Member Functions

 TargetPropertyParser (ArgumentReader< ValueType > reader, String name, bool isRequired, ValueType defaultValue, string propertyName, bool isFlag=false)
 Creates a new instance of the parser. 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...
 
object SetDefaultValue (object target, string name=null)
 Sets the default value of the argument to a target object. More...
 
override string ToString ()
 
void Reset ()
 Clears the parsers state if any in order to prepare it for a new run. 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...
 

Properties

ArgumentReader< ValueType > Reader [get]
 The instance that reads the argument literals from the input. More...
 
bool IsArgumentRequired [get]
 Determines if the argument is mandatory or optional. More...
 
String ArgumentName [get]
 The name of the argument that is processed by the parser. More...
 
bool IsFlag [get]
 Determines if this argument is nearly a flag (name only) or uses values. More...
 
ArgumentsListParser ParentParser [set]
 The list parser this literal parser belongs to. 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 literal parser that processes input literals for arguments that change properties on a target object.

Since
0.2.0

Constructor & Destructor Documentation

◆ TargetPropertyParser()

Joutsen.ArgumentsParsing.TargetPropertyParser< ValueType >.TargetPropertyParser ( ArgumentReader< ValueType >  reader,
String  name,
bool  isRequired,
ValueType  defaultValue,
string  propertyName,
bool  isFlag = false 
)

Creates a new instance of the parser.

Parameters
readerthe reader that extracts the argument literals from the input
namethe name of the argument that is processed by the parser
isRequiredtrue, if the argument is mandatory and needs to be present in the input, false otherwise
defaultValuethe value that is used to change the property in the target object if the argument is optional and was not found in the input
propertyNamethe name of the property that the parser modifies
isFlagdetermines if the parser is processing a flag or an argument which can have additional values

Member Function Documentation

◆ Parse()

virtual ParseResult Joutsen.ArgumentsParsing.TargetPropertyParser< ValueType >.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.

◆ Reset()

void Joutsen.ArgumentsParsing.TargetPropertyParser< ValueType >.Reset ( )

Clears the parsers state if any in order to prepare it for a new run.

Since
0.2.0

Implements Joutsen.ArgumentsParsing.ArgumentLiteralParser.

◆ SetDefaultValue()

object Joutsen.ArgumentsParsing.TargetPropertyParser< ValueType >.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.

◆ ToString()

override string Joutsen.ArgumentsParsing.TargetPropertyParser< ValueType >.ToString ( )

Property Documentation

◆ ArgumentName

String Joutsen.ArgumentsParsing.TargetPropertyParser< ValueType >.ArgumentName
get

The name of the argument that is processed by the parser.

◆ IsArgumentRequired

bool Joutsen.ArgumentsParsing.TargetPropertyParser< ValueType >.IsArgumentRequired
get

Determines if the argument is mandatory or optional.

◆ IsFlag

bool Joutsen.ArgumentsParsing.TargetPropertyParser< ValueType >.IsFlag
get

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

Since
0.2.0

Implements Joutsen.ArgumentsParsing.ArgumentLiteralParser.

◆ ParentParser

The list parser this literal parser belongs to.

Implements Joutsen.ArgumentsParsing.ArgumentLiteralParser.

◆ Reader

The instance that reads the argument literals from the input.