Joutsen.ArgumentsParsing v0.3.0+1-ga4c84ed
Public Member Functions | Properties | List of all members
Joutsen.ArgumentsParsing.ArgumentLiteralParser Interface Reference

An interface for different kinds of parsers of string literals. More...

Public Member Functions

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

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

An interface for different kinds of parsers of string literals.

Remarks
Each implementation of this interface parses exactly one argument consisting of at least one and up to multiple values of the arguments list.
Since
0.1.0

Member Function Documentation

◆ Parse()

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

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.

Implemented in Joutsen.ArgumentsParsing.AbstractDisplayArgument, Joutsen.ArgumentsParsing.DisplayArgumentParser, Joutsen.ArgumentsParsing.TargetPropertyParser< ValueType >, Joutsen.ArgumentsParsing.Parsers.DefaultSubParser< TResultType >, and Joutsen.ArgumentsParsing.Parsers.MutuallyExclusiveArgumentsParser.

◆ Reset()

void Joutsen.ArgumentsParsing.ArgumentLiteralParser.Reset ( )

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

Since
0.2.0

Implemented in Joutsen.ArgumentsParsing.DisplayArgumentParser, and Joutsen.ArgumentsParsing.TargetPropertyParser< ValueType >.

◆ SetDefaultValue()

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

Implemented in Joutsen.ArgumentsParsing.AbstractDisplayArgument, Joutsen.ArgumentsParsing.DisplayArgumentParser, Joutsen.ArgumentsParsing.TargetPropertyParser< ValueType >, Joutsen.ArgumentsParsing.Parsers.DefaultSubParser< TResultType >, and Joutsen.ArgumentsParsing.Parsers.MutuallyExclusiveArgumentsParser.

Property Documentation

◆ IsFlag

bool Joutsen.ArgumentsParsing.ArgumentLiteralParser.IsFlag
get

◆ ParentParser

ArgumentsListParser Joutsen.ArgumentsParsing.ArgumentLiteralParser.ParentParser
set

The list parser this literal parser belongs to.

Implemented in Joutsen.ArgumentsParsing.DisplayArgumentParser, and Joutsen.ArgumentsParsing.TargetPropertyParser< ValueType >.