ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
CLIVariablesPlugin Class Reference

Description:

Specialization of abstract interface class ConfigurationPlugin, which reads command line parameters from namespace globals alib::ARG_C and alib::ARG_VN / ARG_VW on request. Its priority value usually is alib::config,Priority,Priority::CLI "config,Priority,Priority::CLI", which is higher than all other default plug-ins provided.

To recognize variables, the separation character '/' of the configuration tree is converted to underscore character '_'. For example, the ALib locale variable with path ALIB/LOCALE is recognized as ALIB_LOCALE

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 name prefix of category name and underscore '_'.

Friends

class alib::config,detail::nextCLIArg "config,detail::nextCLIArg" (Used for implementation of iterator.)

Definition at line 108 of file config/plugins.hpp.

#include <plugins.hpp>

Inheritance diagram for CLIVariablesPlugin:
[legend]
Collaboration diagram for CLIVariablesPlugin:
[legend]

Public Field Index:

StringVectorMA AlternativeArgs
 
StringVectorMA DefaultCategories
 
uint8_t QtyMandatoryHyphens = 0
 
uint8_t QtyOptionalHyphens = 2
 

Public Method Index:

ALIB_API CLIVariablesPlugin (MonoAllocator &ma, Priority pPriority=Priority::CLI)
 
virtual ~CLIVariablesPlugin () override
 Virtual Destructor.
 
virtual ALIB_API bool Get (const String &name, AString &target) override
 
virtual ALIB_API String Name () const override
 
- Public Method Index: inherited from ConfigurationPlugin
virtual ~ConfigurationPlugin ()
 Virtual Destructor.
 
virtual const StringEscaperGetEscaper () const
 
- Public Method Index: inherited from Plugin< Configuration, Priority >
PrioritiesType GetPriority () const
 

Additional Inherited Members

- Public Type Index: inherited from Plugin< Configuration, Priority >
using PluginType
 This exposes the template parameter TPlugin to the outer world.
 
using PrioritiesType
 This exposes the template parameter pTPlugin to the outer world.
 
- Protected Field Index: inherited from ConfigurationPlugin
StringEscaperStandard stringEscaper
 
- Protected Field Index: inherited from Plugin< Configuration, Priority >
PrioritiesType priority
 The priority of this plug-in.
 
- Protected Method Index: inherited from ConfigurationPlugin
 ConfigurationPlugin (Priority pPriority)
 
- Protected Method Index: inherited from Plugin< Configuration, Priority >
 Plugin (PrioritiesType pPriority)
 

Field Details:

◆ AlternativeArgs

StringVectorMA AlternativeArgs

If any value is added to this vector, its values are used as the source of command line arguments instead of using ALib namespace variables ARG_C and ARG_VN/ARG_VW.
This mechanic provides an alternative method to set the command line argument list.

Applications that have a dedicated (more sophisticated) CLI interface which performs more complex processing of CLI arguments, may collect any unrecognized CLI argument here to be duly recognized as a configuration variable instead

Definition at line 119 of file config/plugins.hpp.

◆ DefaultCategories

StringVectorMA DefaultCategories

An application can specify one or more "default categories" by adding a prefix of the variable path here. Variables of these "categories" are recognized by the plug-in also when given without this prefix.
Please note, that if ALib and ALox variables should be abbreviatable, for example that the locale can be given with –locale=de_DE.UTF-8 instead of –alib_locale=de_DE.UTF-8 this vector has to be populated during bootstrap phase PrepareConfig. See chapter 4.6 Customizing The Bootstrap Process for more information on how to customize ALib bootstrapping.

Definition at line 132 of file config/plugins.hpp.

◆ QtyMandatoryHyphens

uint8_t QtyMandatoryHyphens = 0

Determines whether zero, one or two introducing hyphen characters '-' are mandatory. An command line argument is ignored if the number of leading hyphens is smaller than the value set here.
Defaults to 0.

See also
Sibling option QtyOptionalHyphens.

Definition at line 139 of file config/plugins.hpp.

◆ QtyOptionalHyphens

uint8_t QtyOptionalHyphens = 2

Determines whether zero, one or two optional hyphen characters '-' might be given. An command line argument is ignored if the number of leading hyphens is greater than the value set here.
Defaults to 2.

See also
Sibling option QtyMandatoryHyphens.

Definition at line 146 of file config/plugins.hpp.

Constructor(s) / Destructor Details:

◆ CLIVariablesPlugin()

CLIVariablesPlugin ( MonoAllocator & ma,
Priority pPriority = Priority::CLI )

Constructor.

Parameters
maThe monotonic allocator to use. This usually is the one of the configuration instance.
pPriorityThe priority that this plug-in uses. Defaults to CLI.

Definition at line 24 of file plugins.cpp.

◆ ~CLIVariablesPlugin()

virtual ~CLIVariablesPlugin ( )
inlineoverridevirtual

Virtual Destructor.

Definition at line 157 of file config/plugins.hpp.

Method Details:

◆ Get()

bool Get ( const String & name,
AString & target )
overridevirtual

Searches the variable in the command line parameters.

Parameters
nameThe name of the variable to retrieve.
[out]targetA reference to the buffer to write the variable's exported value to.
Returns
true if variable was found, false if not.

Implements ConfigurationPlugin.

Definition at line 35 of file plugins.cpp.

Here is the call graph for this function:

◆ Name()

String Name ( ) const
overridevirtual
Returns
The plug-in name, in this case, we read resource variable "CfgPlgCLI".

Implements ConfigurationPlugin.

Definition at line 30 of file plugins.cpp.

Here is the call graph for this function:

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