ALox  V. 2402 R. 0
Home ALox for C++ ALox for C# ALox for Java Download
Public Fields | Public Methods | Protected Fields | List of all members
CLIArgs Class Reference
Inheritance diagram for CLIArgs:
[legend]
Collaboration diagram for CLIArgs:
[legend]

Class Description


Specialization of abstract interface class ConfigurationPlugin, which takes all command line parameters in the constructor and reads variable values from those parameters on request. Its priority value usually is Configuration.PrioCLIArgs, which is higher than all other default plug-ins provided.

Variable categories are used as a prefix together with an underscore '_'. This means, if variable LOCALE in category ALIB is accessed, the command line parameter –ALIB_LOCALE=xyz is read.

Category and Variable names are insensitive in respect to character case.

Command line variables may be passed with either one hyphen ('-') or two ('–'). Both are accepted.

An application can specify one or more "default categories" by adding their string names to public field DefaultCategories. Variables of these categories are recognized by the plug-in also when given without the prefix of category name and underscore '_'.

Furthermore, an application may set public field AllowedMinimumShortCut to a value greater than 0. In this case, the plug-in recognizes variables in CLI arguments already when at least this amount of characters is provided. In other words, when reading an argument as many characters of the variable name as possible are 'consumed' and if a minimum number is given with AllowedMinimumShortCut, such minimum is sufficient. If the remaining part of the argument string is either empty or continues with an equal sign '=', then the variable is recognized (with an empty value or the value after the equal sign).
Fields AllowedMinimumShortCut and DefaultCategories may also be used in combination.

Public Fields

int AllowedMinimumShortCut = 0
 
List< String > DefaultCategories = new List<String>()
 
- Public Fields inherited from ConfigurationPlugin
XTernalizer StringConverter
 

Public Methods

override bool Load (Variable variable, bool searchOnly=false)
 
void SetArgs (String[] args)
 
- Public Methods inherited from ConfigurationPlugin
virtual bool Store (Variable variable)
 
virtual bool Store (Variable variable, Object externalizedValue)
 

Protected Fields

String[] args
 
- Protected Fields inherited from ConfigurationPlugin
XTernalizer defaultStringConverter = new XTernalizer()
 

Additional Inherited Members

- Protected Methods inherited from ConfigurationPlugin
 ConfigurationPlugin ()
 

Member Function Documentation

◆ Load()

override bool Load ( Variable  variable,
bool  searchOnly = false 
)
inlinevirtual

Searches the variable in the command line parameters.

Parameters
variableThe variable to retrieve.
searchOnlyIf true, the variable is not read. Defaults to false.
Returns
true if variable was found, false if not.

Implements ConfigurationPlugin.

◆ SetArgs()

void SetArgs ( String[]  args)
inline

Sets the command line argument list. Needs to be called once after construction. Should not be invoked directly. Rather use Configuration.SetCommandLineArgs.

Note
In standard application scenarios, this method is invoked by method ALIB.Init for the singleton of this class found in ALIB.Config.
Parameters
argsParameters taken from standard C# method main() (the list of command line arguments). Defaults to null.

Member Data Documentation

◆ AllowedMinimumShortCut

int AllowedMinimumShortCut = 0

If this field is set to a value greater than 0, this plug-in recognizes variables in CLI arguments already when at least this amount of characters is provided. If the remaining part of the argument string is either empty or continues with an equal sign '=', then the variable is recognized.

◆ args

String [] args
protected

The list of command line arguments.

◆ DefaultCategories

List<String> DefaultCategories = new List<String>()

An application can specify one or more "default categories" by adding the category names here. Variables of these categories are recognized by the plug-in also when given without the prefix of category_.


The documentation for this class was generated from the following file: