Joutsen.ArgumentsParsing  v0.2.1
Public Member Functions | Properties | List of all members
Joutsen.ArgumentsParsing.DisplayArgumentParser Class Reference

A literal parser that processes input literals for flag arguments which display output text when found in the input list. More...

Public Member Functions

 DisplayArgumentParser (string name, string alternative, DisplayException displayException)
 Create a new instance of this 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...
 

Properties

bool IsFlag [get]
 Identifies this parser as processing flags. More...
 
string Name [get]
 The name of the flag or more precisely the flag that is processed by this parser. More...
 
string Alternative [get]
 The alternative to the name of the flag that will be processed by the parser. More...
 
ArgumentsListParser ParentParser [set]
 
- 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 flag arguments which display output text when found in the input list.

Since
0.2.0

Constructor & Destructor Documentation

◆ DisplayArgumentParser()

Joutsen.ArgumentsParsing.DisplayArgumentParser.DisplayArgumentParser ( string  name,
string  alternative,
DisplayException  displayException 
)

Create a new instance of this parser.

Parameters
namethe flag or name that is processed by the parser
alternativethe alternative usually longer version of the flag that is processed by the parser. Optional, can be null.
displayExceptionthe exception that is raised if the flag or its alternative is found in the input

Member Function Documentation

◆ Parse()

virtual ParseResult Joutsen.ArgumentsParsing.DisplayArgumentParser.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.DisplayArgumentParser.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.DisplayArgumentParser.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.DisplayArgumentParser.ToString ( )

Property Documentation

◆ Alternative

string Joutsen.ArgumentsParsing.DisplayArgumentParser.Alternative
get

The alternative to the name of the flag that will be processed by the parser.

This is usually a longer version of the flag that is processed by the parser.

◆ IsFlag

bool Joutsen.ArgumentsParsing.DisplayArgumentParser.IsFlag
get

Identifies this parser as processing flags.

This property is always true.

◆ Name

string Joutsen.ArgumentsParsing.DisplayArgumentParser.Name
get

The name of the flag or more precisely the flag that is processed by this parser.

◆ ParentParser

ArgumentsListParser Joutsen.ArgumentsParsing.DisplayArgumentParser.ParentParser
set