ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
plugins.mpp
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header-file is part of the \aliblong.
4/// With supporting legacy or module builds, .mpp-files are either recognized by the build-system
5/// as C++20 Module interface files, or are included by the
6/// \ref alib_manual_modules_impludes "import/include headers".
7///
8/// \emoji :copyright: 2013-2025 A-Worx GmbH, Germany.
9/// Published under \ref mainpage_license "Boost Software License".
10//==================================================================================================
11#if !defined(ALIB_C20_MODULES) || ((ALIB_C20_MODULES != 0) && (ALIB_C20_MODULES != 1))
12# error "Symbol ALIB_C20_MODULES has to be given to the compiler as either 0 or 1"
13#endif
14#if ALIB_C20_MODULES
15 module;
16#endif
17// ====================================== Global Fragment ======================================
20
21#include "ALib.Strings.Vector.H"
22#if ALIB_DEBUG_BOXING
23# include <vector>
24#endif
25// =========================================== Module ==========================================
26#if ALIB_C20_MODULES
27 /// This is a C++ Module of the \aliblong. Due to the dual-compile option - as either
28 /// C++20 Modules or legacy C++ inclusion, the C++20 Module names are not of further interest
29 /// or use.<br>
30 /// In general, the names equal the names of the header files listed in the chapter
31 /// \ref alib_manual_modules_impludes of the \alib User Manual.
32 /// This chapter, among others, provides further explanations.
33 export module ALib.Variables.Plugins;
34 import ALib.Variables;
35 import ALib.Monomem;
36 import ALib.Strings;
37#else
38#include "ALib.Variables.H"
39#include "ALib.Monomem.H"
40#include "ALib.Strings.H"
41#endif
42
43// ========================================== Exports ==========================================
45
46//==================================================================================================
47/// Specialization of abstract interface class #ConfigurationPlugin, which reads command line
48/// parameters from namespace globals #alib::ARG_C and #alib::ARG_VN / \alib{ARG_VW} on request.
49/// Its priority value usually is \alib{variables;Priority;Priority::CLI}, which is higher
50/// than all other default plug-ins provided.
51///
52/// To recognize variables, the separation character <c>'/'</c> of the configuration tree is
53/// converted to underscore character <c>'_'</c>. For example, the \alib locale variable with path
54/// ALIB/LOCALE
55/// is recognized as
56/// ALIB_LOCALE
57///
58/// Variable names are insensitive in respect to character case.
59///
60/// Command line variables may be passed with either one hyphen ('-') or two ('--').
61/// Both are accepted.
62///
63/// An application can specify one or more "default categories" by adding their string names to
64/// public field #DefaultCategories. Variables of these categories are recognized by the plug-in
65/// also when given without the name prefix of category name and underscore \c '_'.
66//==================================================================================================
68{
69 public:
70 /// If any value is added to this vector, its values are used as the source of command line
71 /// arguments instead of using \alib namespace variables \alib{ARG_C} and
72 /// \alib{ARG_VN}/\alib{ARG_VW}.<br>
73 /// This mechanic provides an alternative method to set the command line argument list.
74 ///
75 /// Applications that have a dedicated (more sophisticated) CLI interface which performs
76 /// more complex processing of CLI arguments, may collect any unrecognized
77 /// CLI argument here to be duly recognized as a configuration variable instead
79
80 /// An application can specify one or more "default categories" by adding a prefix of the
81 /// variable path here. Variables of these "categories" are recognized by the plug-in also
82 /// when given without this prefix.<br>
83 /// Please note, that if \alib and \alox variables should be abbreviatable, for example that
84 /// the locale can be given with
85 /// --locale=de_DE.UTF-8
86 /// instead of
87 /// --alib_locale=de_DE.UTF-8
88 /// this vector has to be populated during bootstrap phase \alib{BootstrapPhases;PrepareConfig}.
89 /// See chapter \ref alib_mod_bs_customize for more information on how to
90 /// customize \alib bootstrapping.
92
93 /// Determines whether zero, one or two introducing hyphen characters <c>'-'</c> are mandatory.
94 /// An command line argument is ignored if the number of leading hyphens is smaller than
95 /// the value set here.<br>
96 /// Defaults to \c 0.
97 /// @see Sibling option #QtyOptionalHyphens.
99
100 /// Determines whether zero, one or two optional hyphen characters <c>'-'</c> might be given.
101 /// An command line argument is ignored if the number of leading hyphens is greater than
102 /// the value set here.<br>
103 /// Defaults to \c 2.
104 /// @see Sibling option #QtyMandatoryHyphens.
106
107 /// Constructor.
108 /// @param ma The monotonic allocator to use. This usually is the one of the
109 /// configuration instance.
110 /// @param pPriority The priority that this plug-in uses. Defaults to
111 /// \alib{variables;Priority;CLI}.
113 CLIVariablesPlugin( MonoAllocator& ma, Priority pPriority= Priority::CLI );
114
115 /// Virtual Destructor.
116 virtual ~CLIVariablesPlugin() override {}
117
118 /// @return The plug-in name, in this case, we read resource variable "CFGPlgCLI".
119 ALIB_DLL virtual String Name() const override;
120
121 /// Searches the variable in the command line parameters.
122 /// @param name The name of the variable to retrieve.
123 /// @param[out] target A reference to the buffer to write the variable's exported value to.
124 /// @return \c true if variable was found, \c false if not.
125 ALIB_DLL virtual bool Get( const String& name, AString& target ) override;
126};
127
128//==================================================================================================
129/// Specialization of abstract interface class #ConfigurationPlugin, retrieves configuration
130/// data from the system environment.
131///
132/// The priority value of this plug-in usually is \alib{variables;Priority;Priority::Environment},
133/// which is higher than \alib{variables;Priority;Standard} but lower than \alib{variables;Priority;CLI}.
134///
135/// To recognize variables, the separation character <c>'/'</c> of the configuration tree is
136/// converted to underscore character <c>'_'</c>. For example, the \alib locale variable with path
137/// ALIB/LOCALE
138/// is recognized as
139/// ALIB_LOCALE
140///
141/// Category and Variable names are insensitive in respect to character case.
142//==================================================================================================
144{
145 public:
146 /// An application can specify one or more "default categories" by adding a prefix of the
147 /// variable path here. Variables of these "categories" are recognized by the plug-in also
148 /// when given without this prefix.<br>
149 /// Please note, that if \alib and \alox variables should be abbreviatable, for example that
150 /// the locale can be given with
151 /// --locale=de_DE.UTF-8
152 /// instead of
153 /// --alib_locale=de_DE.UTF-8
154 /// this vector has to be populated during bootstrap phase \alib{BootstrapPhases;PrepareConfig}.
155 /// See chapter \ref alib_mod_bs_customize for more information on how to
156 /// customize \alib bootstrapping.
158
159 /// Constructor.
160 /// @param ma The monotonic allocator to use. This usually is the one of the
161 /// configuration instance.
162 /// @param pPriority The priority that this plug-in uses. Defaults to
163 /// \alib{variables;Priority;Environment}.
165 Priority pPriority = Priority::Environment );
166
167 /// Virtual Destructor.
168 virtual ~EnvironmentVariablesPlugin() override {}
169
170 /// @return The name of the plug-in, in this case, the value of resource variable "CFGPlgEnv".
171 ALIB_DLL virtual String Name() const override;
172
173 /// Searches the variable in the environment.
174 /// @param name The name of the variable to retrieve.
175 /// @param[out] target A reference to the buffer to write the variable's exported value to.
176 /// @return \c true if variable was found, \c false if not.
177 ALIB_DLL virtual bool Get( const String& name, AString& target ) override;
178};
179
180} // namespace [alib::variables]
181
182
183
184
ALIB_DLL CLIVariablesPlugin(MonoAllocator &ma, Priority pPriority=Priority::CLI)
Definition plugins.cpp:41
virtual ~CLIVariablesPlugin() override
Virtual Destructor.
Definition plugins.mpp:116
virtual ALIB_DLL String Name() const override
Definition plugins.cpp:47
virtual ALIB_DLL bool Get(const String &name, AString &target) override
Definition plugins.cpp:56
ALIB_DLL EnvironmentVariablesPlugin(MonoAllocator &ma, Priority pPriority=Priority::Environment)
Definition plugins.cpp:153
virtual ALIB_DLL bool Get(const String &name, AString &target) override
Definition plugins.cpp:168
virtual ~EnvironmentVariablesPlugin() override
Virtual Destructor.
Definition plugins.mpp:168
virtual ALIB_DLL String Name() const override
Definition plugins.cpp:159
#define ALIB_DLL
Definition alib.inl:496
#define ALIB_EXPORT
Definition alib.inl:488
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace alib.
strings::util::TStringVector< character, MonoAllocator > StringVectorMA
Type alias in namespace alib.
monomem::TMonoAllocator< lang::HeapAllocator > MonoAllocator
strings::TString< character > String
Type alias in namespace alib.
Definition string.inl:2381