Class ArgumentsParser
An argument parser for commands.
Implements
Namespace: TehGM.Wolfringo.Commands.Parsing
Assembly: Wolfringo.Commands.dll
Syntax
public class ArgumentsParser : IArgumentsParser
Constructors
| Improve this Doc View SourceArgumentsParser()
Create a new instance of default parser using default options.
Declaration
public ArgumentsParser()
ArgumentsParser(ArgumentsParserOptions)
Create a new instance of default parser.
Declaration
public ArgumentsParser(ArgumentsParserOptions options)
Parameters
Type | Name | Description |
---|---|---|
ArgumentsParserOptions | options | Options to use with this parser. |
Properties
| Improve this Doc View SourceBaseMarker
Base marker to use by default.
Declaration
public char BaseMarker { get; }
Property Value
Type | Description |
---|---|
Char |
Remarks
Base marker is used by default, and will be skipped inside of a nested block.
Base marker must be contained as a key in BlockMarkers.
Defaults to space.
BlockMarkers
Argument start and end markers.
Declaration
public IDictionary<char, char> BlockMarkers { get; }
Property Value
Type | Description |
---|---|
IDictionary<Char, Char> |
Remarks
By default, following markers are used to split arguments:
Start: ' ', End: ' '
Start: '"', End: '"'
Start: '(', End: ')'
Start: '[', End: ']'
InitialBlockSizeAllocation
Initial size allocated for an argument.
Declaration
public int InitialBlockSizeAllocation { get; }
Property Value
Type | Description |
---|---|
Int32 |
Remarks
ArgumentsParser uses a new list of Char for each argument, and allocates initial size. A good initial size is big enough to contain most commonly used arguments, but small enough to not allocate too much memory unnecessarily.
Defaults to 8.
Options
Options used by this parser.
Declaration
protected ArgumentsParserOptions Options { get; }
Property Value
Type | Description |
---|---|
ArgumentsParserOptions |
Methods
| Improve this Doc View SourceParseArguments(String, Int32)
Parses commands from input.
Declaration
public virtual IEnumerable<string> ParseArguments(string input, int startIndex)
Parameters
Type | Name | Description |
---|---|---|
String | input | Command input. |
Int32 | startIndex | Index at which to start parsing. |
Returns
Type | Description |
---|---|
IEnumerable<String> | Enumerable of found arguments. |
ParseBlock(String, ref Int32, Nullable<Char>, ref ICollection<String>)
Parses a block.
Declaration
protected virtual void ParseBlock(string input, ref int cursor, char? terminator, ref ICollection<string> results)
Parameters
Type | Name | Description |
---|---|---|
String | input | Entire command input. |
Int32 | cursor | Current parser position. |
Nullable<Char> | terminator | The character to end the block with. |
ICollection<String> | results | Parsed arguments. |