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