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

A reader that processes a value from the input literals allowing only a limited number of resulting values. More...

Public Member Functions

 ChoiceArgumentReader (Set< ValueType > choices)
 Creates a new instance of the reader for a number of allowed result values which implement the IConvertible interface. More...
 
 ChoiceArgumentReader (Set< ValueType > choices, SimpleTypeConverter< string, ValueType > converter)
 Creates a new instance of the reader for a number of allowed result values which can be converted by a custom converter. More...
 
override ArgumentReadResult< ValueType > Read (ArgumentsIterator args, string name, int offset=0)
 Reads literals from the input to create a resulting value. More...
 
- Public Member Functions inherited from Joutsen.ArgumentsParsing.ValueArgumentReader< ValueType >
 ValueArgumentReader ()
 Creates a new instance for resulting types which implement the IConvertible interface. More...
 
 ValueArgumentReader (SimpleTypeConverter< string, ValueType > converter)
 Creates a new instance using a custom converter to produce the result value. More...
 
 ValueArgumentReader (SimpleTypeConverter< string, ValueType > converter, String startDelimiter, String endDelimiter, String partConnector, bool keepDelimiters)
 Creates a new instance using a custom converter for delimited values to produce the result value. More...
 
virtual ArgumentReadResult< ValueType > Read (ArgumentsIterator args, string name, int offset=0)
 Reads literals from the input to create a resulting value. More...
 
ArgumentReadResult< ValueType > Read (ArgumentsIterator args, string name, int offset=0)
 Reads literals from the input. More...
 

Properties

Set< ValueType > Choices [get]
 The allowed values for the read result. More...
 
- Properties inherited from Joutsen.ArgumentsParsing.ValueArgumentReader< ValueType >
virtual String ValueStartDelimiter [get, set]
 The delimiter that determines the start of a delimited value. More...
 
virtual String ValueEndDelimiter [get, set]
 The delimiter that determines the end of a delimited value. More...
 
virtual String ValuePartsConnector [get, set]
 The value that is added between the different literals read from the input when reading a delimited value. More...
 
virtual bool KeepDelimiters [get, set]
 Determines if the resulting value should contain the delimiters or not. More...
 
Set< String > ArgumentPrefixes [set]
 The prefixes of the arguments used by the parser. More...
 
virtual SimpleTypeConverter< string, ValueType > TypeConverter [get, set]
 The converter used to change the read literals into a different type. More...
 
- Properties inherited from Joutsen.ArgumentsParsing.ArgumentReader< ValueType >
Set< String > ArgumentPrefixes [set]
 The prefixes of the arguments used by the parser. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Joutsen.ArgumentsParsing.ValueArgumentReader< ValueType >
virtual ArgumentReadResult< ValueType > ReadToEndDelimiter (ArgumentsIterator arguments, string name, int offset)
 Reads multiple literals from the input until the end delimiter is found. More...
 
virtual ValueType GetParsedValue (StringBuilder fullArgument, String name)
 Combines multiple literals into a single result value. More...
 
virtual ValueType GetParsedValue (string value, string argumentName)
 Converts a read value into the target type. More...
 
- Protected Attributes inherited from Joutsen.ArgumentsParsing.ValueArgumentReader< ValueType >
SimpleTypeConverter< string, ValueType > _converter
 The converter used to change the read literals into a different type. More...
 

Detailed Description

A reader that processes a value from the input literals allowing only a limited number of resulting values.

Remarks
This reader supports reading multiple values enclosed by delimiters into a single result value. The different values can be put together separated by a configured value and the delimiters can either be stripped or remain in the resulting value. When using the reader for multiple delimited values the resulting value needs to be a valid result.
Since
0.2.0

Constructor & Destructor Documentation

◆ ChoiceArgumentReader() [1/2]

Joutsen.ArgumentsParsing.ChoiceArgumentReader< ValueType >.ChoiceArgumentReader ( Set< ValueType >  choices)

Creates a new instance of the reader for a number of allowed result values which implement the IConvertible interface.

◆ ChoiceArgumentReader() [2/2]

Joutsen.ArgumentsParsing.ChoiceArgumentReader< ValueType >.ChoiceArgumentReader ( Set< ValueType >  choices,
SimpleTypeConverter< string, ValueType >  converter 
)

Creates a new instance of the reader for a number of allowed result values which can be converted by a custom converter.

Member Function Documentation

◆ Read()

override ArgumentReadResult< ValueType > Joutsen.ArgumentsParsing.ChoiceArgumentReader< ValueType >.Read ( ArgumentsIterator  args,
string  name,
int  offset = 0 
)
virtual

Reads literals from the input to create a resulting value.

Parameters
argsthe input list of literal values represented by an iterator
namethe name of the argument whose values to read as found in the input
offsetan optional additional offset of literals where to start reading from the input
Returns
the value read from the input and the number of literals used in the process
Exceptions
ArgumentParseExceptionif a value cannot be converted to the ValueType, if a delimited value is not 'closed' correctly or if the resulting value does not match one of the allowed values

Reimplemented from Joutsen.ArgumentsParsing.ValueArgumentReader< ValueType >.

Property Documentation

◆ Choices

Set<ValueType> Joutsen.ArgumentsParsing.ChoiceArgumentReader< ValueType >.Choices
get

The allowed values for the read result.