Debian Codegraph @

application/argumentparser.h

raw symbols SCIP
1 #cxx . . $ `<file>/application/argumentparser.h`/ifndef APPLICATION_UTILITIES_ARGUMENTPARSER_H
2 #define APPLICATION_UTILITIES_ARGUMENTPARSER_Hcxx . . $ `application/argumentparser.h:2:9`!
3
4 #include "../conversion/stringconversion.h"cxx . . $ `<file>/conversion/stringconversion.h`/
5 #include "../misc/traits.h"cxx . . $ `<file>/misc/traits.h`/
6
7 #include <functional>
8 #include <initializer_list>
9 #include <limits>
10 #include <tuple>
11 #include <vector>
12 #ifdef CPP_UTILITIES_DEBUG_BUILD
13 #include <cassert>
14 #endif
15
16 class ArgumentParserTestscxx . . $ ArgumentParserTests#; // not a public class (only used for internal tests)
17
18 namespace CppUtilitiescxx . . $ CppUtilities/ {
19
20 /*!
21 * \brief Stores information about an application.
22 */
23 struct ApplicationInfocxx . . $ CppUtilities/ApplicationInfo# {
24 const char *namecxx . . $ CppUtilities/ApplicationInfo#name. = nullptr;
25 const char *authorcxx . . $ CppUtilities/ApplicationInfo#author. = nullptr;
26 const char *versioncxx . . $ CppUtilities/ApplicationInfo#version. = nullptr;
27 const char *urlcxx . . $ CppUtilities/ApplicationInfo#url. = nullptr;
28 const char *domaincxx . . $ CppUtilities/ApplicationInfo#domain. = nullptr;
29 const char *descriptioncxx . . $ CppUtilities/ApplicationInfo#description. = nullptr;
30 const char *licensecxx . . $ CppUtilities/ApplicationInfo#license. = nullptr;
31 const char *creditscxx . . $ CppUtilities/ApplicationInfo#credits. = nullptr;
32 stdcxx . . $ std/::vectorcxx . . $ std/vector#<const char *> dependencyVersionscxx . . $ CppUtilities/ApplicationInfo#dependencyVersions.;
33 };
34
35 /*!
36 * \brief Stores global application info used by ArgumentParser::printHelp() and AboutDialog.
37 */
38 CPP_UTILITIES_EXPORTcxx . . $ `global.h:11:9`! extern ApplicationInfocxx . . $ CppUtilities/ApplicationInfo# applicationInfocxx . . $ CppUtilities/applicationInfo.;
39
40 /*!
41 * \def SET_DEPENDENCY_INFO
42 * \brief Sets meta data about the dependencies the application was linked against which is
43 * used by ArgumentParser::printHelp().
44 * \remarks Reads those data from the config header so "config.h" must be included.
45 */
46 #define SET_DEPENDENCY_INFOcxx . . $ `application/argumentparser.h:46:9`! ::CppUtilities::applicationInfo.dependencyVersions = DEPENCENCY_VERSIONS
47
48 /*!
49 * \def SET_APPLICATION_INFO
50 * \brief Sets application meta data (including SET_DEPENDENCY_INFO) used by ArgumentParser::printHelp().
51 * \remarks Reads those data from the config header so "config.h" must be included.
52 */
53 #define SET_APPLICATION_INFOcxx . . $ `application/argumentparser.h:53:9`! \
54 ::CppUtilities::applicationInfo.name = APP_NAME; \
55 ::CppUtilities::applicationInfo.author = APP_AUTHOR; \
56 ::CppUtilities::applicationInfo.version = APP_VERSION; \
57 ::CppUtilities::applicationInfo.url = APP_URL; \
58 ::CppUtilities::applicationInfo.domain = APP_DOMAIN; \
59 ::CppUtilities::applicationInfo.description = APP_DESCRIPTION; \
60 ::CppUtilities::applicationInfo.license = PROJECT_LICENSE; \
61 ::CppUtilities::applicationInfo.credits = APP_CREDITS; \
62 SET_DEPENDENCY_INFO
63
64 class Argumentcxx . . $ CppUtilities/Argument#;
65 class ArgumentParsercxx . . $ CppUtilities/ArgumentParser#;
66 class ArgumentReadercxx . . $ CppUtilities/ArgumentReader#;
67
68 using ArgumentInitializerListcxx . . $ CppUtilities/ArgumentInitializerList# = stdcxx . . $ std/::initializer_listcxx . . $ std/initializer_list#<Argumentcxx . . $ CppUtilities/Argument# *>;
69 using ArgumentVectorcxx . . $ CppUtilities/ArgumentVector# = stdcxx . . $ std/::vectorcxx . . $ std/vector#<Argumentcxx . . $ CppUtilities/Argument# *>;
70 using ArgumentPredicatecxx . . $ CppUtilities/ArgumentPredicate# = stdcxx . . $ std/::functioncxx . . $ std/function#<bool(Argumentcxx . . $ CppUtilities/Argument# *)>;
71
72 /*!
73 * \brief The UnknownArgumentBehavior enum specifies the behavior of the argument parser when an unknown
74 * argument is detected.
75 */
76 enum class UnknownArgumentBehaviorcxx . . $ CppUtilities/UnknownArgumentBehavior# {
77 Ignorecxx . . $ CppUtilities/UnknownArgumentBehavior#Ignore., /**< Unknown arguments are ignored without warnings. */
78 Warncxx . . $ CppUtilities/UnknownArgumentBehavior#Warn., /**< A warning is printed to std::cerr if an unknown argument is detected. */
79 Failcxx . . $ CppUtilities/UnknownArgumentBehavior#Fail. /**< Further parsing is aborted and a Failure instance with an error message is thrown. */
80 };
81
82 /*!
83 * \brief The ParseArgumentBehavior enum specifies the behavior when parsing arguments.
84 *
85 * This concerns checking constraints, invoking callbacks and handling failures. The values are supposed to be combined
86 * using the |-operator. Note that ParseArgumentBehavior::ReadArguments is always implied.
87 */
88 enum class ParseArgumentBehaviorcxx . . $ CppUtilities/ParseArgumentBehavior# {
89 ReadArgumentscxx . . $ CppUtilities/ParseArgumentBehavior#ReadArguments. = 0x0, /**< reads the specified CLI arguments, equivalent to simply calling readArgs() */
90 CheckConstraintscxx . . $ CppUtilities/ParseArgumentBehavior#CheckConstraints. = 0x1, /**< whether the constraints should be checked after reading the arguments */
91 InvokeCallbackscxx . . $ CppUtilities/ParseArgumentBehavior#InvokeCallbacks. = 0x2, /**< whether the callbacks should be invoked after reading the arguments and (maybe) checking the constraints */
92 ExitOnFailurecxx . . $ CppUtilities/ParseArgumentBehavior#ExitOnFailure.
93 = 0x4, /**< whether the parser should print an error message and terminate the application on failure (rather than throwing an exception) */
94 };
95
96 /// \cond
97 constexpr ParseArgumentBehaviorcxx . . $ CppUtilities/ParseArgumentBehavior# operatorcxx . . $ CppUtilities/`operator|`(e25733aab63f2018).|(ParseArgumentBehaviorcxx . . $ CppUtilities/ParseArgumentBehavior# lhs, ParseArgumentBehaviorcxx . . $ CppUtilities/ParseArgumentBehavior# rhs)
98 {
99 return static_cast<ParseArgumentBehaviorcxx . . $ CppUtilities/ParseArgumentBehavior#>(static_cast<unsigned char>(lhs) | static_cast<unsigned char>(rhs));
100 }
101
102 constexpr bool operatorcxx . . $ CppUtilities/`operator&`(f2029251cce91bbf).&(ParseArgumentBehaviorcxx . . $ CppUtilities/ParseArgumentBehavior# lhs, ParseArgumentBehaviorcxx . . $ CppUtilities/ParseArgumentBehavior# rhs)
103 {
104 return static_cast<bool>(static_cast<unsigned char>(lhs) & static_cast<unsigned char>(rhs));
105 }
106 /// \endcond
107
108 /*!
109 * \brief The ValueCompletionBehavior enum specifies the items to be considered when generating completion for an argument value.
110 * \remarks
111 * - The enumeration items are meant to be combined using the |-operator.
112 * - ValueCompletionBehavior::InvokeCallback is meant to initialize pre-defined values only when required in the callback assigned
113 * via Argument::setCallback(). Hence it makes sense to combine it with ValueCompletionBehavior::PreDefinedValues.
114 * - When ValueCompletionBehavior::InvokeCallback is present, the callback assigned via Argument::setCallback() might be called
115 * even when not all constraints are fulfilled. So, for instance, there might not be all required values present.
116 */
117 enum class ValueCompletionBehaviorcxx . . $ CppUtilities/ValueCompletionBehavior# : unsigned char {
118 Nonecxx . . $ CppUtilities/ValueCompletionBehavior#None. = 0, /**< no auto-completion */
119 PreDefinedValuescxx . . $ CppUtilities/ValueCompletionBehavior#PreDefinedValues. = 2, /**< values assigned with Argument::setPreDefinedCompletionValues() */
120 Filescxx . . $ CppUtilities/ValueCompletionBehavior#Files. = 4, /**< files */
121 Directoriescxx . . $ CppUtilities/ValueCompletionBehavior#Directories. = 8, /**< directories */
122 FileSystemIfNoPreDefinedValuescxx . . $ CppUtilities/ValueCompletionBehavior#FileSystemIfNoPreDefinedValues. = 16, /**< files and directories but only if no values have been assigned (default behavior) */
123 AppendEquationSigncxx . . $ CppUtilities/ValueCompletionBehavior#AppendEquationSign. = 32, /**< an equation sign is appended to values which not contain an equation sign already */
124 InvokeCallbackcxx . . $ CppUtilities/ValueCompletionBehavior#InvokeCallback. = 64, /**< whether to invoke the callback before reading pre-defined values */
125 };
126
127 /// \cond
128 constexpr ValueCompletionBehaviorcxx . . $ CppUtilities/ValueCompletionBehavior# operatorcxx . . $ CppUtilities/`operator|`(c2b922020561bbb).|(ValueCompletionBehaviorcxx . . $ CppUtilities/ValueCompletionBehavior# lhs, ValueCompletionBehaviorcxx . . $ CppUtilities/ValueCompletionBehavior# rhs)
129 {
130 return static_cast<ValueCompletionBehaviorcxx . . $ CppUtilities/ValueCompletionBehavior#>(static_cast<unsigned char>(lhs) | static_cast<unsigned char>(rhs));
131 }
132
133 constexpr bool operatorcxx . . $ CppUtilities/`operator&`(83f89e59cac566d1).&(ValueCompletionBehaviorcxx . . $ CppUtilities/ValueCompletionBehavior# lhs, ValueCompletionBehaviorcxx . . $ CppUtilities/ValueCompletionBehavior# rhs)
134 {
135 return static_cast<bool>(static_cast<unsigned char>(lhs) & static_cast<unsigned char>(rhs));
136 }
137 /// \endcond
138
139 /*!
140 * \brief Contains functions to convert raw argument values to certain types.
141 *
142 * Extend this namespace by additional convert() functions to allow use of Argument::valuesAs() with your custom types.
143 *
144 * \remarks Still experimental. Might be removed/adjusted in next minor release.
145 */
146 namespace ValueConversioncxx . . $ CppUtilities/ValueConversion/ {
147 template <typename TargetType, Traitscxx . . $ CppUtilities/Traits/::EnableIfcxx . . $ CppUtilities/Traits/EnableIf#<stdcxx . . $ std/::is_same<TargetType, stdcxx . . $ std/::stringcxx . . $ std/string#>> * = nullptr> TargetType convertcxx . . $ CppUtilities/ValueConversion/convert(cb6fd9cdaeafa88d).(const char *value)
148 {
149 return stdcxx . . $ std/::stringcxx . . $ std/string#(value);
150 }
151
152 template <typename TargetType, Traitscxx . . $ CppUtilities/Traits/::EnableIfcxx . . $ CppUtilities/Traits/EnableIf#<stdcxx . . $ std/::is_arithmetic<TargetType>> * = nullptr> TargetType convertcxx . . $ CppUtilities/ValueConversion/convert(cb6fd9cdaeafa88d).(const char *value)
153 {
154 return stringToNumbercxx . . $ CppUtilities/stringToNumber(478c46a825b2cbff).<TargetType>(value);
155 }
156
157 /// \cond
158 namespace Helpercxx . . $ CppUtilities/ValueConversion/Helper/ {
159 struct CPP_UTILITIES_EXPORTcxx . . $ `global.h:11:9`! ArgumentValueConversionErrorcxx . . $ CppUtilities/ValueConversion/Helper/ArgumentValueConversionError# {
160 const stdcxx . . $ std/::stringcxx . . $ std/string# errorMessagecxx . . $ CppUtilities/ValueConversion/Helper/ArgumentValueConversionError#errorMessage.;
161 const char *const valueToConvertcxx . . $ CppUtilities/ValueConversion/Helper/ArgumentValueConversionError#valueToConvert.;
162 const char *const targetTypeNamecxx . . $ CppUtilities/ValueConversion/Helper/ArgumentValueConversionError#targetTypeName.;
163
164 [[noreturn]] void throwFailurecxx . . $ CppUtilities/ValueConversion/Helper/ArgumentValueConversionError#throwFailure(66bba89efa4d5a8c).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<Argumentcxx . . $ CppUtilities/Argument# *> &argumentPath) const;
165 };
166
167 template <stdcxx . . $ std/::size_tcxx . . $ std/size_t# N, typename FirstTargetType, typename... RemainingTargetTypes> struct ArgumentValueConvertercxx . . $ CppUtilities/ValueConversion/Helper/ArgumentValueConverter# {
168 static stdcxx . . $ std/::tuplecxx . . $ std/tuple#<FirstTargetType, RemainingTargetTypes...> convertValuescxx . . $ CppUtilities/ValueConversion/Helper/ArgumentValueConverter#convertValues(41399412408c143d).(stdcxx . . $ std/::vectorcxx . . $ std/vector#<const char *>::const_iteratorcxx . . $ std/vector#const_iterator# firstValue)
169 {
170 return stdcxx . . $ std/::tuple_catcxx . . $ std/tuple_cat(e4b7fdbc2fd7b4b4).(ArgumentValueConvertercxx . . $ CppUtilities/ValueConversion/Helper/ArgumentValueConverter#<1, FirstTargetType>::convertValues(firstValue),
171 ArgumentValueConvertercxx . . $ CppUtilities/ValueConversion/Helper/ArgumentValueConverter#<N - 1, RemainingTargetTypes...>::convertValues(firstValue +cxx . . $ __gnu_cxx/__normal_iterator#operator+(192bf940fa7bb3b2). 1));
172 }
173 };
174
175 template <typename FirstTargetType, typename... RemainingTargetTypes> struct ArgumentValueConvertercxx . . $ CppUtilities/ValueConversion/Helper/ArgumentValueConverter#<1, FirstTargetType, RemainingTargetTypes...> {
176 static stdcxx . . $ std/::tuplecxx . . $ std/tuple#<FirstTargetType> convertValuescxx . . $ CppUtilities/ValueConversion/Helper/ArgumentValueConverter#convertValues(a1ad9e7b44517c60).(stdcxx . . $ std/::vectorcxx . . $ std/vector#<const char *>::const_iteratorcxx . . $ std/vector#const_iterator# firstValue)
177 {
178 // FIXME: maybe use std::expected here when available
179 try {
180 return stdcxx . . $ std/::make_tuplecxx . . $ std/make_tuple(3964edbfd7e8599f).<FirstTargetType>(ValueConversioncxx . . $ CppUtilities/ValueConversion/::convertcxx . . $ CppUtilities/ValueConversion/convert(cb6fd9cdaeafa88d).<FirstTargetType>(*cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).firstValue));
181 } catch (const ConversionExceptioncxx . . $ CppUtilities/ConversionException# &exception) {
182 throw ArgumentValueConversionErrorcxx . . $ CppUtilities/ValueConversion/Helper/ArgumentValueConversionError#{ exception.whatcxx . . $ std/runtime_error#what(ba32b354807b2b81).(), *cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(f9c37c6e427d43d6).firstValue, typeid(FirstTargetType).namecxx . . $ std/type_info#name(ba32b354807b2b81).() };
183 }
184 }
185 };
186 } // namespace Helper
187 /// \endcond
188
189 } // namespace ValueConversion
190
191 /*!
192 * \brief The ArgumentOccurrence struct holds argument values for an occurrence of an argument.
193 */
194 struct CPP_UTILITIES_EXPORTcxx . . $ `global.h:11:9`! ArgumentOccurrencecxx . . $ CppUtilities/ArgumentOccurrence# {
195 ArgumentOccurrencecxx . . $ CppUtilities/ArgumentOccurrence#ArgumentOccurrence(2c44cd906ae4e829).(stdcxx . . $ std/::size_tcxx . . $ std/size_t# index);
196 ArgumentOccurrencecxx . . $ CppUtilities/ArgumentOccurrence#ArgumentOccurrence(8ecab4cab72dd7f3).(stdcxx . . $ std/::size_tcxx . . $ std/size_t# index, const stdcxx . . $ std/::vectorcxx . . $ std/vector#<Argumentcxx . . $ CppUtilities/Argument# *> parentPath, Argumentcxx . . $ CppUtilities/Argument# *parent);
197
198 /*!
199 * \brief The index of the occurrence. This is not necessarily the index in the argv array.
200 */
201 stdcxx . . $ std/::size_tcxx . . $ std/size_t# indexcxx . . $ CppUtilities/ArgumentOccurrence#index.;
202
203 /*!
204 * \brief The parameter values which have been specified after the occurrence of the argument.
205 */
206 stdcxx . . $ std/::vectorcxx . . $ std/vector#<const char *> valuescxx . . $ CppUtilities/ArgumentOccurrence#values.;
207
208 /*!
209 * \brief The "path" of the occurrence (the parent elements which have been specified before).
210 * \remarks Empty for top-level occurrences.
211 */
212 stdcxx . . $ std/::vectorcxx . . $ std/vector#<Argumentcxx . . $ CppUtilities/Argument# *> pathcxx . . $ CppUtilities/ArgumentOccurrence#path.;
213
214 template <typename... RemainingTargetTypes> stdcxx . . $ std/::tuplecxx . . $ std/tuple#<RemainingTargetTypes...> convertValuescxx . . $ CppUtilities/ArgumentOccurrence#convertValues(2e232625b190361b).() const;
215
216 private:
217 [[noreturn]] void throwNumberOfValuesNotSufficientcxx . . $ CppUtilities/ArgumentOccurrence#throwNumberOfValuesNotSufficient(cf8bf0a838713cc4).(unsigned long valuesToConvert) const;
218 };
219
220 /*!
221 * \brief Converts the present values to the specified target types. There must be as many values present as types are specified.
222 * \throws Throws ArgumentUtilities::Failure when the number of present values is not sufficient or a conversion error occurs.
223 * \remarks Still experimental. Might be removed/adjusted in next minor release.
224 */
225 template <typename... RemainingTargetTypes> stdcxx . . $ std/::tuplecxx . . $ std/tuple#<RemainingTargetTypes...> ArgumentOccurrencecxx . . $ CppUtilities/ArgumentOccurrence#::convertValuescxx . . $ CppUtilities/ArgumentOccurrence#convertValues(2e232625b190361b).() const
226 {
227 constexpr auto valuesToConvert = sizeof...(RemainingTargetTypes);
228 if (valuescxx . . $ CppUtilities/ArgumentOccurrence#values..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).() < valuesToConvert) {
229 throwNumberOfValuesNotSufficientcxx . . $ CppUtilities/ArgumentOccurrence#throwNumberOfValuesNotSufficient(cf8bf0a838713cc4).(valuesToConvert);
230 }
231 try {
232 return ValueConversioncxx . . $ CppUtilities/ValueConversion/::Helpercxx . . $ CppUtilities/ValueConversion/Helper/::ArgumentValueConvertercxx . . $ CppUtilities/ValueConversion/Helper/ArgumentValueConverter#<valuesToConvert, RemainingTargetTypes...>::convertValues(valuescxx . . $ CppUtilities/ArgumentOccurrence#values..cbegincxx . . $ std/vector#cbegin(d1e1699016b9d7e6).());
233 } catch (const ValueConversioncxx . . $ CppUtilities/ValueConversion/::Helpercxx . . $ CppUtilities/ValueConversion/Helper/::ArgumentValueConversionErrorcxx . . $ CppUtilities/ValueConversion/Helper/ArgumentValueConversionError# &error) {
234 error.throwFailurecxx . . $ CppUtilities/ValueConversion/Helper/ArgumentValueConversionError#throwFailure(66bba89efa4d5a8c).(pathcxx . . $ CppUtilities/ArgumentOccurrence#path.);
235 }
236 }
237
238 /*!
239 * \brief Constructs an argument occurrence for the specified \a index.
240 */
241 inline ArgumentOccurrencecxx . . $ CppUtilities/ArgumentOccurrence#::ArgumentOccurrencecxx . . $ CppUtilities/ArgumentOccurrence#ArgumentOccurrence(2c44cd906ae4e829).(stdcxx . . $ std/::size_tcxx . . $ std/size_t# index)
242 : indexcxx . . $ CppUtilities/ArgumentOccurrence#index.(index)
243 {
244 }
245
246 /*!
247 * \brief Constructs an argument occurrence.
248 * \param index Specifies the index.
249 * \param parentPath Specifies the path of \a parent.
250 * \param parent Specifies the parent which might be nullptr for top-level occurrences.
251 *
252 * The path of the new occurrence is built from the specified \a parentPath and \a parent.
253 */
254 inline ArgumentOccurrencecxx . . $ CppUtilities/ArgumentOccurrence#::ArgumentOccurrencecxx . . $ CppUtilities/ArgumentOccurrence#ArgumentOccurrence(8ecab4cab72dd7f3).(stdcxx . . $ std/::size_tcxx . . $ std/size_t# index, const stdcxx . . $ std/::vectorcxx . . $ std/vector#<Argumentcxx . . $ CppUtilities/Argument# *> parentPath, Argumentcxx . . $ CppUtilities/Argument# *parent)
255 : indexcxx . . $ CppUtilities/ArgumentOccurrence#index.(index)
256 , pathcxx . . $ CppUtilities/ArgumentOccurrence#path.(parentPath)
257 {
258 if (parent) {
259 pathcxx . . $ CppUtilities/ArgumentOccurrence#path..push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(parent);
260 }
261 }
262
263 class CPP_UTILITIES_EXPORTcxx . . $ `global.h:11:9`! Argumentcxx . . $ CppUtilities/Argument# {
264 friend ArgumentParsercxx . . $ CppUtilities/ArgumentParser#;
265 friend ArgumentReadercxx . . $ CppUtilities/ArgumentReader#;
266 friend ArgumentParserTestscxx . . $ ArgumentParserTests#;
267
268 public:
269 typedef stdcxx . . $ std/::functioncxx . . $ std/function#<void(const ArgumentOccurrencecxx . . $ CppUtilities/ArgumentOccurrence# &)> CallbackFunctioncxx . . $ CppUtilities/Argument#CallbackFunction#;
270
271 /// \brief The Flags enum specifies options for treating the argument in a special way.
272 enum class Flagscxx . . $ CppUtilities/Argument#Flags# : stdcxx . . $ std/::uint64_tcxx . . $ std/uint64_t# {
273 Nonecxx . . $ CppUtilities/Argument#Flags#None. = 0x0, /**< No flags are present. The default for Argument(). */
274 Combinablecxx . . $ CppUtilities/Argument#Flags#Combinable.
275 = 0x1, /**< It is no error if this argument occurs besides other arguments on the same level. The default for ConfigValueArgument. */
276 Implicitcxx . . $ CppUtilities/Argument#Flags#Implicit. = 0x2, /**< The argument is assumed to be present if its values are present. Only one argument can be implicit at the same level. */
277 Operationcxx . . $ CppUtilities/Argument#Flags#Operation. = 0x4, /**< The argument is an operation, so no `--` prefix is required when specifying it. The default for OperationArgument(). */
278 Deprecatedcxx . . $ CppUtilities/Argument#Flags#Deprecated. = 0x8, /**< The argument is considered deprecated and therefore excluded from the help. */
279 Greedycxx . . $ CppUtilities/Argument#Flags#Greedy.
280 = 0x10, /**< The argument is "greedy" so when Argument::varValueCount is used all subsequent arguments will be considered values of that argument. This is useful to pass remaining arguments down to another argument parser as-is. */
281 };
282
283 Argumentcxx . . $ CppUtilities/Argument#Argument(af3d03003c91f516).(const char *name, char abbreviation = '\0', const char *description = nullptr, const char *example = nullptr);
284 ~cxx . . $ CppUtilities/Argument#`~Argument`(ced63f7c635d850d).Argumentcxx . . $ CppUtilities/Argument#();
285
286 // declare getter/setter/properties/operations for argument definition:
287 // - those properties must be set *before* parsing
288 // - they control the behaviour of the parser, eg.
289 // - the name/abbreviation to look for
290 // - constraints to be checked
291 // - callbacks to be invoked
292 // TODO v5: It would make sense to move these to a separate class (eg. ArgumentDefinition) to prevent this one from
293 // becoming to big.
294 const char *namecxx . . $ CppUtilities/Argument#name(a9f41ea0e82d88cf).() const;
295 void setNamecxx . . $ CppUtilities/Argument#setName(85c52e162fed56f9).(const char *name);
296 char abbreviationcxx . . $ CppUtilities/Argument#abbreviation(1b8b762cbef9c2c9).() const;
297 void setAbbreviationcxx . . $ CppUtilities/Argument#setAbbreviation(44b6ea1973a07080).(char abbreviation);
298 const char *environmentVariablecxx . . $ CppUtilities/Argument#environmentVariable(a9f41ea0e82d88cf).() const;
299 void setEnvironmentVariablecxx . . $ CppUtilities/Argument#setEnvironmentVariable(85c52e162fed56f9).(const char *environmentVariable);
300 const char *descriptioncxx . . $ CppUtilities/Argument#description(a9f41ea0e82d88cf).() const;
301 void setDescriptioncxx . . $ CppUtilities/Argument#setDescription(85c52e162fed56f9).(const char *description);
302 const char *examplecxx . . $ CppUtilities/Argument#example(a9f41ea0e82d88cf).() const;
303 void setExamplecxx . . $ CppUtilities/Argument#setExample(85c52e162fed56f9).(const char *example);
304 stdcxx . . $ std/::size_tcxx . . $ std/size_t# requiredValueCountcxx . . $ CppUtilities/Argument#requiredValueCount(fe4d2d262d4164a8).() const;
305 void setRequiredValueCountcxx . . $ CppUtilities/Argument#setRequiredValueCount(2c44cd906ae4e829).(stdcxx . . $ std/::size_tcxx . . $ std/size_t# requiredValueCount);
306 const stdcxx . . $ std/::vectorcxx . . $ std/vector#<const char *> &valueNamescxx . . $ CppUtilities/Argument#valueNames(6073f6567d110ada).() const;
307 void setValueNamescxx . . $ CppUtilities/Argument#setValueNames(d357f9644586045e).(stdcxx . . $ std/::initializer_listcxx . . $ std/initializer_list#<const char *> valueNames);
308 void appendValueNamecxx . . $ CppUtilities/Argument#appendValueName(85c52e162fed56f9).(const char *valueName);
309 void setConstraintscxx . . $ CppUtilities/Argument#setConstraints(6714b5f2551eea49).(stdcxx . . $ std/::size_tcxx . . $ std/size_t# minOccurrences, stdcxx . . $ std/::size_tcxx . . $ std/size_t# maxOccurrences);
310 const stdcxx . . $ std/::vectorcxx . . $ std/vector#<Argumentcxx . . $ CppUtilities/Argument# *> &pathcxx . . $ CppUtilities/Argument#path(b87142e1c5eb1796).(stdcxx . . $ std/::size_tcxx . . $ std/size_t# occurrence = 0) const;
311 bool isRequiredcxx . . $ CppUtilities/Argument#isRequired(50ce9a9e25b4a850).() const;
312 void setRequiredcxx . . $ CppUtilities/Argument#setRequired(b45ddcbc8423892c).(bool required);
313 Argumentcxx . . $ CppUtilities/Argument#::Flagscxx . . $ CppUtilities/Argument#Flags# flagscxx . . $ CppUtilities/Argument#flags(17c623cd32e8f2b8).() const;
314 void setFlagscxx . . $ CppUtilities/Argument#setFlags(45a26be16130673e).(Argumentcxx . . $ CppUtilities/Argument#::Flagscxx . . $ CppUtilities/Argument#Flags# flags);
315 void setFlagscxx . . $ CppUtilities/Argument#setFlags(28d96d49eed1205c).(Argumentcxx . . $ CppUtilities/Argument#::Flagscxx . . $ CppUtilities/Argument#Flags# flags, bool add);
316 bool isCombinablecxx . . $ CppUtilities/Argument#isCombinable(50ce9a9e25b4a850).() const;
317 void setCombinablecxx . . $ CppUtilities/Argument#setCombinable(b45ddcbc8423892c).(bool combinable);
318 bool isImplicitcxx . . $ CppUtilities/Argument#isImplicit(50ce9a9e25b4a850).() const;
319 void setImplicitcxx . . $ CppUtilities/Argument#setImplicit(b45ddcbc8423892c).(bool implicit);
320 bool denotesOperationcxx . . $ CppUtilities/Argument#denotesOperation(50ce9a9e25b4a850).() const;
321 void setDenotesOperationcxx . . $ CppUtilities/Argument#setDenotesOperation(b45ddcbc8423892c).(bool denotesOperation);
322 const CallbackFunctioncxx . . $ CppUtilities/Argument#CallbackFunction# &callbackcxx . . $ CppUtilities/Argument#callback(be5f22ef79a956ac).() const;
323 void setCallbackcxx . . $ CppUtilities/Argument#setCallback(e4ee40b4f868025b).(CallbackFunctioncxx . . $ CppUtilities/Argument#CallbackFunction# callback);
324 const ArgumentVectorcxx . . $ CppUtilities/ArgumentVector# &subArgumentscxx . . $ CppUtilities/Argument#subArguments(1ef3bc1254d64c10).() const;
325 void setSubArgumentscxx . . $ CppUtilities/Argument#setSubArguments(fd9df7cc6299ed0c).(const ArgumentInitializerListcxx . . $ CppUtilities/ArgumentInitializerList# &subArguments);
326 void addSubArgumentscxx . . $ CppUtilities/Argument#addSubArguments(fd9df7cc6299ed0c).(const ArgumentInitializerListcxx . . $ CppUtilities/ArgumentInitializerList# &subArguments);
327 void addSubArgumentcxx . . $ CppUtilities/Argument#addSubArgument(c2eefe819a479349).(Argumentcxx . . $ CppUtilities/Argument# *arg);
328 bool hasSubArgumentscxx . . $ CppUtilities/Argument#hasSubArguments(50ce9a9e25b4a850).() const;
329 const ArgumentVectorcxx . . $ CppUtilities/ArgumentVector# &parentscxx . . $ CppUtilities/Argument#parents(1ef3bc1254d64c10).() const;
330 void printInfocxx . . $ CppUtilities/Argument#printInfo(26c0a26698046a31).(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &os, unsigned char indentation = 0) const;
331
332 // declare getter/setter/properties for bash completion: those properties must be set *before parsing
333 ValueCompletionBehaviorcxx . . $ CppUtilities/ValueCompletionBehavior# valueCompletionBehaviourcxx . . $ CppUtilities/Argument#valueCompletionBehaviour(e66dc16b08d52b98).() const;
334 void setValueCompletionBehaviorcxx . . $ CppUtilities/Argument#setValueCompletionBehavior(f9523c9a7dbf97a5).(ValueCompletionBehaviorcxx . . $ CppUtilities/ValueCompletionBehavior# valueCompletionBehaviour);
335 const char *preDefinedCompletionValuescxx . . $ CppUtilities/Argument#preDefinedCompletionValues(a9f41ea0e82d88cf).() const;
336 void setPreDefinedCompletionValuescxx . . $ CppUtilities/Argument#setPreDefinedCompletionValues(85c52e162fed56f9).(const char *preDefinedCompletionValues);
337
338 // declare getter/read-only properties for parsing results: those properties will be populated when parsing
339 const stdcxx . . $ std/::vectorcxx . . $ std/vector#<const char *> &valuescxx . . $ CppUtilities/Argument#values(f310c0743d72f851).(stdcxx . . $ std/::size_tcxx . . $ std/size_t# occurrence = 0) const;
340 template <typename... TargetType> stdcxx . . $ std/::tuplecxx . . $ std/tuple#<TargetType...> valuesAscxx . . $ CppUtilities/Argument#valuesAs(98dbb89e0a08a083).(stdcxx . . $ std/::size_tcxx . . $ std/size_t# occurrence = 0) const;
341 template <typename... TargetType> stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<TargetType...>> allValuesAscxx . . $ CppUtilities/Argument#allValuesAs(50761507cbaed734).() const;
342
343 const char *firstValuecxx . . $ CppUtilities/Argument#firstValue(a9f41ea0e82d88cf).() const;
344 const char *firstValueOrcxx . . $ CppUtilities/Argument#firstValueOr(865ea18671f48fc1).(const char *fallback) const;
345 bool allRequiredValuesPresentcxx . . $ CppUtilities/Argument#allRequiredValuesPresent(2ff7c7de1baa6d0a).(stdcxx . . $ std/::size_tcxx . . $ std/size_t# occurrence = 0) const;
346 bool isPresentcxx . . $ CppUtilities/Argument#isPresent(50ce9a9e25b4a850).() const;
347 stdcxx . . $ std/::size_tcxx . . $ std/size_t# occurrencescxx . . $ CppUtilities/Argument#occurrences(fe4d2d262d4164a8).() const;
348 stdcxx . . $ std/::size_tcxx . . $ std/size_t# indexcxx . . $ CppUtilities/Argument#index(611be0c07d97f8b8).(stdcxx . . $ std/::size_tcxx . . $ std/size_t# occurrence) const;
349 stdcxx . . $ std/::size_tcxx . . $ std/size_t# minOccurrencescxx . . $ CppUtilities/Argument#minOccurrences(fe4d2d262d4164a8).() const;
350 stdcxx . . $ std/::size_tcxx . . $ std/size_t# maxOccurrencescxx . . $ CppUtilities/Argument#maxOccurrences(fe4d2d262d4164a8).() const;
351 bool isDeprecatedcxx . . $ CppUtilities/Argument#isDeprecated(50ce9a9e25b4a850).() const;
352 const Argumentcxx . . $ CppUtilities/Argument# *deprecatedBycxx . . $ CppUtilities/Argument#deprecatedBy(1d185535a93e5288).() const;
353 void markAsDeprecatedcxx . . $ CppUtilities/Argument#markAsDeprecated(e71b349e7ebca7e6).(const Argumentcxx . . $ CppUtilities/Argument# *deprecatedBy = nullptr);
354 bool isMainArgumentcxx . . $ CppUtilities/Argument#isMainArgument(50ce9a9e25b4a850).() const;
355 bool isParentPresentcxx . . $ CppUtilities/Argument#isParentPresent(50ce9a9e25b4a850).() const;
356 Argumentcxx . . $ CppUtilities/Argument# *conflictsWithArgumentcxx . . $ CppUtilities/Argument#conflictsWithArgument(cb6a3fc127670316).() const;
357 Argumentcxx . . $ CppUtilities/Argument# *wouldConflictWithArgumentcxx . . $ CppUtilities/Argument#wouldConflictWithArgument(cb6a3fc127670316).() const;
358 Argumentcxx . . $ CppUtilities/Argument# *specifiedOperationcxx . . $ CppUtilities/Argument#specifiedOperation(cb6a3fc127670316).() const;
359 const stdcxx . . $ std/::vectorcxx . . $ std/vector#<ArgumentOccurrencecxx . . $ CppUtilities/ArgumentOccurrence#> &occurrenceInfocxx . . $ CppUtilities/Argument#occurrenceInfo(e4ad38e4a0a57b47).() const;
360 stdcxx . . $ std/::vectorcxx . . $ std/vector#<ArgumentOccurrencecxx . . $ CppUtilities/ArgumentOccurrence#> &occurrenceInfocxx . . $ CppUtilities/Argument#occurrenceInfo(3aed361425eaf2a8).();
361 void resetcxx . . $ CppUtilities/Argument#reset(49f6e7a06ebc5aa8).();
362 void resetRecursivelycxx . . $ CppUtilities/Argument#resetRecursively(49f6e7a06ebc5aa8).();
363
364 /*!
365 * \brief Denotes a variable number of values.
366 * \sa setRequiredValueCount()
367 */
368 static constexpr stdcxx . . $ std/::size_tcxx . . $ std/size_t# varValueCountcxx . . $ CppUtilities/Argument#varValueCount. = stdcxx . . $ std/::numeric_limitscxx . . $ std/numeric_limits#<std::size_t>::maxcxx . . $ std/numeric_limits#max(cee159cc271e827).();
369
370 private:
371 // declare internal getter/setter/properties/operations for argument definition
372 bool matchesDenotationcxx . . $ CppUtilities/Argument#matchesDenotation(7d22623725d5361b).(const char *denotation, stdcxx . . $ std/::size_tcxx . . $ std/size_t# denotationLength) const;
373
374 const char *m_namecxx . . $ CppUtilities/Argument#m_name.;
375 char m_abbreviationcxx . . $ CppUtilities/Argument#m_abbreviation.;
376 const char *m_environmentVarcxx . . $ CppUtilities/Argument#m_environmentVar.;
377 const char *m_descriptioncxx . . $ CppUtilities/Argument#m_description.;
378 const char *m_examplecxx . . $ CppUtilities/Argument#m_example.;
379 stdcxx . . $ std/::size_tcxx . . $ std/size_t# m_minOccurrencescxx . . $ CppUtilities/Argument#m_minOccurrences.;
380 stdcxx . . $ std/::size_tcxx . . $ std/size_t# m_maxOccurrencescxx . . $ CppUtilities/Argument#m_maxOccurrences.;
381 stdcxx . . $ std/::size_tcxx . . $ std/size_t# m_requiredValueCountcxx . . $ CppUtilities/Argument#m_requiredValueCount.;
382 stdcxx . . $ std/::vectorcxx . . $ std/vector#<const char *> m_valueNamescxx . . $ CppUtilities/Argument#m_valueNames.;
383 Flagscxx . . $ CppUtilities/Argument#Flags# m_flagscxx . . $ CppUtilities/Argument#m_flags.;
384 stdcxx . . $ std/::vectorcxx . . $ std/vector#<ArgumentOccurrencecxx . . $ CppUtilities/ArgumentOccurrence#> m_occurrencescxx . . $ CppUtilities/Argument#m_occurrences.;
385 ArgumentVectorcxx . . $ CppUtilities/ArgumentVector# m_subArgscxx . . $ CppUtilities/Argument#m_subArgs.;
386 CallbackFunctioncxx . . $ CppUtilities/Argument#CallbackFunction# m_callbackFunctioncxx . . $ CppUtilities/Argument#m_callbackFunction.;
387 ArgumentVectorcxx . . $ CppUtilities/ArgumentVector# m_parentscxx . . $ CppUtilities/Argument#m_parents.;
388 const Argumentcxx . . $ CppUtilities/Argument# *m_deprecatedBycxx . . $ CppUtilities/Argument#m_deprecatedBy.;
389 bool m_isMainArgcxx . . $ CppUtilities/Argument#m_isMainArg.;
390 ValueCompletionBehaviorcxx . . $ CppUtilities/ValueCompletionBehavior# m_valueCompletionBehaviorcxx . . $ CppUtilities/Argument#m_valueCompletionBehavior.;
391 const char *m_preDefinedCompletionValuescxx . . $ CppUtilities/Argument#m_preDefinedCompletionValues.;
392 };
393
394 /// \cond
395 constexpr Argumentcxx . . $ CppUtilities/Argument#::Flagscxx . . $ CppUtilities/Argument#Flags# operatorcxx . . $ CppUtilities/`operator|`(895db631fc1941b5).|(Argumentcxx . . $ CppUtilities/Argument#::Flagscxx . . $ CppUtilities/Argument#Flags# lhs, Argumentcxx . . $ CppUtilities/Argument#::Flagscxx . . $ CppUtilities/Argument#Flags# rhs)
396 {
397 return static_cast<Argumentcxx . . $ CppUtilities/Argument#::Flagscxx . . $ CppUtilities/Argument#Flags#>(static_cast<unsigned char>(lhs) | static_cast<unsigned char>(rhs));
398 }
399
400 constexpr bool operatorcxx . . $ CppUtilities/`operator&`(564b1b0111016947).&(Argumentcxx . . $ CppUtilities/Argument#::Flagscxx . . $ CppUtilities/Argument#Flags# lhs, Argumentcxx . . $ CppUtilities/Argument#::Flagscxx . . $ CppUtilities/Argument#Flags# rhs)
401 {
402 return static_cast<bool>(static_cast<unsigned char>(lhs) & static_cast<unsigned char>(rhs));
403 }
404 /// \endcond
405
406 /*!
407 * \brief Converts the present values for the specified \a occurrence to the specified target types. There must be as many values present as types are specified.
408 * \throws Throws ArgumentUtilities::Failure when the number of present values is not sufficient or a conversion error occurs.
409 * \remarks Still experimental. Might be removed/adjusted in next minor release.
410 */
411 template <typename... TargetType> stdcxx . . $ std/::tuplecxx . . $ std/tuple#<TargetType...> Argumentcxx . . $ CppUtilities/Argument#::valuesAscxx . . $ CppUtilities/Argument#valuesAs(98dbb89e0a08a083).(stdcxx . . $ std/::size_tcxx . . $ std/size_t# occurrence) const
412 {
413 return m_occurrencescxx . . $ CppUtilities/Argument#m_occurrences.[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).occurrence].convertValuescxx . . $ CppUtilities/ArgumentOccurrence#convertValues(2e232625b190361b).<TargetType...>();
414 }
415
416 /*!
417 * \brief Converts the present values for all occurrences to the specified target types. For each occurrence, there must be as many values present as types are specified.
418 * \throws Throws ArgumentUtilities::Failure when the number of present values is not sufficient or a conversion error occurs.
419 * \remarks Still experimental. Might be removed/adjusted in next minor release.
420 */
421 template <typename... TargetType> stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<TargetType...>> Argumentcxx . . $ CppUtilities/Argument#::allValuesAscxx . . $ CppUtilities/Argument#allValuesAs(50761507cbaed734).() const
422 {
423 stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<TargetType...>> res;
424 res.reservecxx . . $ std/vector#reserve(2c44cd906ae4e829).(m_occurrencescxx . . $ CppUtilities/Argument#m_occurrences..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).());
425 for (const auto &occurrence : m_occurrencescxx . . $ CppUtilities/Argument#m_occurrences.) {
426 res.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).(occurrence.convertValuescxx . . $ CppUtilities/ArgumentOccurrence#convertValues(2e232625b190361b).<TargetType...>());
427 }
428 return res;
429 }
430
431 class CPP_UTILITIES_EXPORTcxx . . $ `global.h:11:9`! HelpArgumentcxx . . $ CppUtilities/HelpArgument# : public Argumentcxx . . $ CppUtilities/Argument# {
432 public:
433 HelpArgumentcxx . . $ CppUtilities/HelpArgument#HelpArgument(d2dcd5df46dc3eee).(ArgumentParsercxx . . $ CppUtilities/ArgumentParser# &parser);
434 };
435
436 class CPP_UTILITIES_EXPORTcxx . . $ `global.h:11:9`! OperationArgumentcxx . . $ CppUtilities/OperationArgument# : public Argumentcxx . . $ CppUtilities/Argument# {
437 public:
438 OperationArgumentcxx . . $ CppUtilities/OperationArgument#OperationArgument(af3d03003c91f516).(const char *name, char abbreviation = '\0', const char *description = nullptr, const char *example = nullptr);
439 };
440
441 class CPP_UTILITIES_EXPORTcxx . . $ `global.h:11:9`! ConfigValueArgumentcxx . . $ CppUtilities/ConfigValueArgument# : public Argumentcxx . . $ CppUtilities/Argument# {
442 public:
443 ConfigValueArgumentcxx . . $ CppUtilities/ConfigValueArgument#ConfigValueArgument(8938ad5557ae1687).(const char *name, char abbreviation = '\0', const char *description = nullptr,
444 stdcxx . . $ std/::initializer_listcxx . . $ std/initializer_list#<const char *> valueNames = stdcxx . . $ std/initializer_list#initializer_list(ced63f7c635d850d).::initializer_listcxx . . $ std/initializer_list#<const char *>());
445 };
446
447 class CPP_UTILITIES_EXPORTcxx . . $ `global.h:11:9`! NoColorArgumentcxx . . $ CppUtilities/NoColorArgument# : public Argumentcxx . . $ CppUtilities/Argument# {
448 friend ArgumentParserTestscxx . . $ ArgumentParserTests#;
449
450 public:
451 NoColorArgumentcxx . . $ CppUtilities/NoColorArgument#NoColorArgument(49f6e7a06ebc5aa8).();
452 void applycxx . . $ CppUtilities/NoColorArgument#apply(83f5f38750778ac8).() const;
453 };
454
455 struct ArgumentCompletionInfocxx . . $ CppUtilities/ArgumentCompletionInfo#;
456
457 class CPP_UTILITIES_EXPORTcxx . . $ `global.h:11:9`! ArgumentParsercxx . . $ CppUtilities/ArgumentParser# {
458 friend ArgumentParserTestscxx . . $ ArgumentParserTests#;
459 friend ArgumentReadercxx . . $ CppUtilities/ArgumentReader#;
460
461 public:
462 ArgumentParsercxx . . $ CppUtilities/ArgumentParser#ArgumentParser(49f6e7a06ebc5aa8).();
463
464 // declare getter/setter for argument definitions
465 const ArgumentVectorcxx . . $ CppUtilities/ArgumentVector# &mainArgumentscxx . . $ CppUtilities/ArgumentParser#mainArguments(1ef3bc1254d64c10).() const;
466 void setMainArgumentscxx . . $ CppUtilities/ArgumentParser#setMainArguments(fd9df7cc6299ed0c).(const ArgumentInitializerListcxx . . $ CppUtilities/ArgumentInitializerList# &mainArguments);
467 void addMainArgumentcxx . . $ CppUtilities/ArgumentParser#addMainArgument(c2eefe819a479349).(Argumentcxx . . $ CppUtilities/Argument# *argument);
468
469 // declare operations which will consider previously assigned argument definitions and maybe modify parsing results
470 void printHelpcxx . . $ CppUtilities/ArgumentParser#printHelp(490063bd7e6d8d5d).(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &os) const;
471 void parseArgscxx . . $ CppUtilities/ArgumentParser#parseArgs(539add8bb24c60d4).(int argc, const char *const *argv,
472 ParseArgumentBehaviorcxx . . $ CppUtilities/ParseArgumentBehavior# behavior
473 = ParseArgumentBehaviorcxx . . $ CppUtilities/ParseArgumentBehavior#::CheckConstraintscxx . . $ CppUtilities/ParseArgumentBehavior#CheckConstraints. |cxx . . $ CppUtilities/`operator|`(e25733aab63f2018). ParseArgumentBehaviorcxx . . $ CppUtilities/ParseArgumentBehavior#::InvokeCallbackscxx . . $ CppUtilities/ParseArgumentBehavior#InvokeCallbacks. |cxx . . $ CppUtilities/`operator|`(e25733aab63f2018). ParseArgumentBehaviorcxx . . $ CppUtilities/ParseArgumentBehavior#::ExitOnFailurecxx . . $ CppUtilities/ParseArgumentBehavior#ExitOnFailure.);
474 void readArgscxx . . $ CppUtilities/ArgumentParser#readArgs(5151383285df94d8).(int argc, const char *const *argv);
475 void resetArgscxx . . $ CppUtilities/ArgumentParser#resetArgs(49f6e7a06ebc5aa8).();
476 void assumeDefaultArgumentcxx . . $ CppUtilities/ArgumentParser#assumeDefaultArgument(49f6e7a06ebc5aa8).();
477 void ensureDefaultOperationcxx . . $ CppUtilities/ArgumentParser#ensureDefaultOperation(49f6e7a06ebc5aa8).();
478 void checkConstraintscxx . . $ CppUtilities/ArgumentParser#checkConstraints(49f6e7a06ebc5aa8).();
479 void invokeCallbackscxx . . $ CppUtilities/ArgumentParser#invokeCallbacks(49f6e7a06ebc5aa8).();
480
481 // declare getter for parsing results
482 unsigned int actualArgumentCountcxx . . $ CppUtilities/ArgumentParser#actualArgumentCount(ddd8539a2fcdd4ce).() const;
483 const char *executablecxx . . $ CppUtilities/ArgumentParser#executable(a9f41ea0e82d88cf).() const;
484 UnknownArgumentBehaviorcxx . . $ CppUtilities/UnknownArgumentBehavior# unknownArgumentBehaviorcxx . . $ CppUtilities/ArgumentParser#unknownArgumentBehavior(cf4cd57dc503ea70).() const;
485 void setUnknownArgumentBehaviorcxx . . $ CppUtilities/ArgumentParser#setUnknownArgumentBehavior(b1521e9ef4d9e3dc).(UnknownArgumentBehaviorcxx . . $ CppUtilities/UnknownArgumentBehavior# behavior);
486 Argumentcxx . . $ CppUtilities/Argument# *defaultArgumentcxx . . $ CppUtilities/ArgumentParser#defaultArgument(cb6a3fc127670316).() const;
487 void setDefaultArgumentcxx . . $ CppUtilities/ArgumentParser#setDefaultArgument(c2eefe819a479349).(Argumentcxx . . $ CppUtilities/Argument# *argument);
488 Argumentcxx . . $ CppUtilities/Argument# *specifiedOperationcxx . . $ CppUtilities/ArgumentParser#specifiedOperation(cb6a3fc127670316).() const;
489 bool isUncombinableMainArgPresentcxx . . $ CppUtilities/ArgumentParser#isUncombinableMainArgPresent(50ce9a9e25b4a850).() const;
490 void setExitFunctioncxx . . $ CppUtilities/ArgumentParser#setExitFunction(c984aeb66bdba57e).(stdcxx . . $ std/::functioncxx . . $ std/function#<void(int)> exitFunction);
491 const HelpArgumentcxx . . $ CppUtilities/HelpArgument# &helpArgcxx . . $ CppUtilities/ArgumentParser#helpArg(558d3090d72dbcec).() const;
492 HelpArgumentcxx . . $ CppUtilities/HelpArgument# &helpArgcxx . . $ CppUtilities/ArgumentParser#helpArg(f85ec61c65e3ee59).();
493 const NoColorArgumentcxx . . $ CppUtilities/NoColorArgument# &noColorArgcxx . . $ CppUtilities/ArgumentParser#noColorArg(7764408f961aadbc).() const;
494 NoColorArgumentcxx . . $ CppUtilities/NoColorArgument# &noColorArgcxx . . $ CppUtilities/ArgumentParser#noColorArg(a5cff874ad1ea402).();
495
496 private:
497 // declare internal operations
498 CPP_UTILITIES_IF_DEBUG_BUILDcxx . . $ `application/global.h:118:9`!(void verifyArgs(const ArgumentVector &args);)
499 ArgumentCompletionInfocxx . . $ CppUtilities/ArgumentCompletionInfo# determineCompletionInfocxx . . $ CppUtilities/ArgumentParser#determineCompletionInfo(a82f731a26a5c72e).(
500 int argc, const char *const *argv, unsigned int currentWordIndex, const ArgumentReadercxx . . $ CppUtilities/ArgumentReader# &reader) const;
501 stdcxx . . $ std/::stringcxx . . $ std/string# findSuggestionscxx . . $ CppUtilities/ArgumentParser#findSuggestions(6a143a656ff85f6c).(int argc, const char *const *argv, unsigned int cursorPos, const ArgumentReadercxx . . $ CppUtilities/ArgumentReader# &reader) const;
502 void printBashCompletioncxx . . $ CppUtilities/ArgumentParser#printBashCompletion(34b204d995c4289d).(int argc, const char *const *argv, unsigned int cursorPos, const ArgumentReadercxx . . $ CppUtilities/ArgumentReader# &reader) const;
503 void checkConstraintscxx . . $ CppUtilities/ArgumentParser#checkConstraints(116237cab03ffd67).(const ArgumentVectorcxx . . $ CppUtilities/ArgumentVector# &args);
504 static void invokeCallbackscxx . . $ CppUtilities/ArgumentParser#invokeCallbacks(116237cab03ffd67).(const ArgumentVectorcxx . . $ CppUtilities/ArgumentVector# &args);
505 void invokeExitcxx . . $ CppUtilities/ArgumentParser#invokeExit(d4f767463ce0a6b3).(int code);
506
507 ArgumentVectorcxx . . $ CppUtilities/ArgumentVector# m_mainArgscxx . . $ CppUtilities/ArgumentParser#m_mainArgs.;
508 unsigned int m_actualArgccxx . . $ CppUtilities/ArgumentParser#m_actualArgc.;
509 const char *m_executablecxx . . $ CppUtilities/ArgumentParser#m_executable.;
510 UnknownArgumentBehaviorcxx . . $ CppUtilities/UnknownArgumentBehavior# m_unknownArgBehaviorcxx . . $ CppUtilities/ArgumentParser#m_unknownArgBehavior.;
511 Argumentcxx . . $ CppUtilities/Argument# *m_defaultArgcxx . . $ CppUtilities/ArgumentParser#m_defaultArg.;
512 HelpArgumentcxx . . $ CppUtilities/HelpArgument# m_helpArgcxx . . $ CppUtilities/ArgumentParser#m_helpArg.;
513 NoColorArgumentcxx . . $ CppUtilities/NoColorArgument# m_noColorArgcxx . . $ CppUtilities/ArgumentParser#m_noColorArg.;
514 stdcxx . . $ std/::functioncxx . . $ std/function#<void(int)> m_exitFunctioncxx . . $ CppUtilities/ArgumentParser#m_exitFunction.;
515 };
516
517 /*!
518 * \brief Returns the name of the argument.
519 *
520 * The parser compares the name with the characters following a "--" prefix to identify arguments.
521 */
522 inline const char *Argumentcxx . . $ CppUtilities/Argument#::namecxx . . $ CppUtilities/Argument#name(a9f41ea0e82d88cf).() const
523 {
524 return m_namecxx . . $ CppUtilities/Argument#m_name.;
525 }
526
527 /*!
528 * \brief Sets the name of the argument.
529 *
530 * The name mustn't be empty, start with a minus or contain white spaces, equation chars, quotes and newlines.
531 *
532 * The parser compares the name with the characters following a "--" prefix to identify arguments.
533 */
534 inline void Argumentcxx . . $ CppUtilities/Argument#::setNamecxx . . $ CppUtilities/Argument#setName(85c52e162fed56f9).(const char *name)
535 {
536 #if defined(CPP_UTILITIES_DEBUG_BUILD) && !defined(_MSC_VER)
537 if (name && *name) {
538 assert(*name != '-');
539 for (const char *c = name; *c; ++c) {
540 assert(*c != ' ' && *c != '=' && *c != '\'' && *c != '\"' && *c != '\n' && *c != '\r');
541 }
542 }
543 #endif
544 m_namecxx . . $ CppUtilities/Argument#m_name. = name;
545 }
546
547 /*!
548 * \brief Returns the abbreviation of the argument.
549 *
550 * The parser compares the abbreviation with the characters following a "-" prefix to identify arguments.
551 */
552 inline char Argumentcxx . . $ CppUtilities/Argument#::abbreviationcxx . . $ CppUtilities/Argument#abbreviation(1b8b762cbef9c2c9).() const
553 {
554 return m_abbreviationcxx . . $ CppUtilities/Argument#m_abbreviation.;
555 }
556
557 /*!
558 * \brief Sets the abbreviation of the argument.
559 *
560 * The abbreviation might be empty but mustn't be white spaces, equation char, single quote, double quote or newline.
561 *
562 * The parser compares the abbreviation with the characters following a "-" prefix to identify arguments.
563 */
564 inline void Argumentcxx . . $ CppUtilities/Argument#::setAbbreviationcxx . . $ CppUtilities/Argument#setAbbreviation(44b6ea1973a07080).(char abbreviation)
565 {
566 CPP_UTILITIES_IF_DEBUG_BUILDcxx . . $ `application/global.h:118:9`!(assert(abbreviation != ' ' && abbreviation != '=' && abbreviation != '-' && abbreviation != '\''
567 && abbreviation != '"' && abbreviation != '\n' && abbreviation != '\r'));
568 m_abbreviationcxx . . $ CppUtilities/Argument#m_abbreviation. = abbreviation;
569 }
570
571 /*!
572 * \brief Returns the environment variable queried when firstValue() is called.
573 * \sa firstValue(), setEnvironmentVariable()
574 */
575 inline const char *Argumentcxx . . $ CppUtilities/Argument#::environmentVariablecxx . . $ CppUtilities/Argument#environmentVariable(a9f41ea0e82d88cf).() const
576 {
577 return m_environmentVarcxx . . $ CppUtilities/Argument#m_environmentVar.;
578 }
579
580 /*!
581 * \brief Sets the environment variable queried when firstValue() is called.
582 * \sa firstValue(), environmentVariable()
583 */
584 inline void Argumentcxx . . $ CppUtilities/Argument#::setEnvironmentVariablecxx . . $ CppUtilities/Argument#setEnvironmentVariable(85c52e162fed56f9).(const char *environmentVariable)
585 {
586 m_environmentVarcxx . . $ CppUtilities/Argument#m_environmentVar. = environmentVariable;
587 }
588
589 /*!
590 * \brief Returns the description of the argument.
591 *
592 * The parser uses the description when printing help information.
593 */
594 inline const char *Argumentcxx . . $ CppUtilities/Argument#::descriptioncxx . . $ CppUtilities/Argument#description(a9f41ea0e82d88cf).() const
595 {
596 return m_descriptioncxx . . $ CppUtilities/Argument#m_description.;
597 }
598
599 /*!
600 * \brief Sets the description of the argument.
601 *
602 * The parser uses the description when printing help information.
603 */
604 inline void Argumentcxx . . $ CppUtilities/Argument#::setDescriptioncxx . . $ CppUtilities/Argument#setDescription(85c52e162fed56f9).(const char *description)
605 {
606 m_descriptioncxx . . $ CppUtilities/Argument#m_description. = description;
607 }
608
609 /*!
610 * \brief Returns the usage example of the argument.
611 *
612 * The parser uses the description when printing help information.
613 */
614 inline const char *Argumentcxx . . $ CppUtilities/Argument#::examplecxx . . $ CppUtilities/Argument#example(a9f41ea0e82d88cf).() const
615 {
616 return m_examplecxx . . $ CppUtilities/Argument#m_example.;
617 }
618
619 /*!
620 * \brief Sets the a usage example for the argument.
621 *
622 * The parser uses the description when printing help information.
623 */
624 inline void Argumentcxx . . $ CppUtilities/Argument#::setExamplecxx . . $ CppUtilities/Argument#setExample(85c52e162fed56f9).(const char *example)
625 {
626 m_examplecxx . . $ CppUtilities/Argument#m_example. = example;
627 }
628
629 /*!
630 * \brief Returns the parameter values for the specified \a occurrence of argument.
631 * \remarks
632 * - The values are set by the parser when parsing the command line arguments.
633 * - The specified \a occurrence must be less than occurrences().
634 */
635 inline const stdcxx . . $ std/::vectorcxx . . $ std/vector#<const char *> &Argumentcxx . . $ CppUtilities/Argument#::valuescxx . . $ CppUtilities/Argument#values(f310c0743d72f851).(stdcxx . . $ std/::size_tcxx . . $ std/size_t# occurrence) const
636 {
637 return m_occurrencescxx . . $ CppUtilities/Argument#m_occurrences.[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).occurrence].valuescxx . . $ CppUtilities/ArgumentOccurrence#values.;
638 }
639
640 /*!
641 * \brief Returns the number of values which are required to be given
642 * for this argument.
643 *
644 * The parser will expect that many values when parsing command line arguments.
645 * A negative value indicates a variable number of arguments to be expected.
646 *
647 * The default value is 0, except for ConfigValueArgument instances.
648 *
649 * \sa setRequiredValueCount()
650 * \sa valueNames()
651 * \sa setValueNames()
652 */
653 inline stdcxx . . $ std/::size_tcxx . . $ std/size_t# Argumentcxx . . $ CppUtilities/Argument#::requiredValueCountcxx . . $ CppUtilities/Argument#requiredValueCount(fe4d2d262d4164a8).() const
654 {
655 return m_requiredValueCountcxx . . $ CppUtilities/Argument#m_requiredValueCount.;
656 }
657
658 /*!
659 * \brief Sets the number of values which are required to be given
660 * for this argument.
661 *
662 * The parser will expect that many values when parsing command line arguments.
663 * Pass Argument::varValueCount for a variable number of arguments
664 * to be expected.
665 *
666 * \sa requiredValueCount()
667 * \sa valueNames()
668 * \sa setValueNames()
669 */
670 inline void Argumentcxx . . $ CppUtilities/Argument#::setRequiredValueCountcxx . . $ CppUtilities/Argument#setRequiredValueCount(2c44cd906ae4e829).(stdcxx . . $ std/::size_tcxx . . $ std/size_t# requiredValueCount)
671 {
672 m_requiredValueCountcxx . . $ CppUtilities/Argument#m_requiredValueCount. = requiredValueCount;
673 }
674
675 /*!
676 * \brief Returns the names of the required values.
677 *
678 * These names will be shown when printing information about the argument.
679 *
680 * \sa setValueNames()
681 * \sa appendValueName()
682 */
683 inline const stdcxx . . $ std/::vectorcxx . . $ std/vector#<const char *> &Argumentcxx . . $ CppUtilities/Argument#::valueNamescxx . . $ CppUtilities/Argument#valueNames(6073f6567d110ada).() const
684 {
685 return m_valueNamescxx . . $ CppUtilities/Argument#m_valueNames.;
686 }
687
688 /*!
689 * \brief Sets the names of the required values. These names will be used
690 * when printing information about the argument.
691 *
692 * If the number of value names is higher than the number of required values
693 * the additional value names will be ignored.
694 * If the number of value names is lesser than the number of required values
695 * generic values will be used for the missing names.
696 *
697 * \sa appendValueName()
698 * \sa valueNames()
699 * \sa requiredValueCount()
700 */
701 inline void Argumentcxx . . $ CppUtilities/Argument#::setValueNamescxx . . $ CppUtilities/Argument#setValueNames(d357f9644586045e).(stdcxx . . $ std/::initializer_listcxx . . $ std/initializer_list#<const char *> valueNames)
702 {
703 m_valueNamescxx . . $ CppUtilities/Argument#m_valueNames..assigncxx . . $ std/vector#assign(b6da5b9a9f304025).(valueNames);
704 }
705
706 /*!
707 * \brief Appends a value name. The value names names will be shown
708 * when printing information about the argument.
709 * \sa setValueNames()
710 * \sa valueNames()
711 */
712 inline void Argumentcxx . . $ CppUtilities/Argument#::appendValueNamecxx . . $ CppUtilities/Argument#appendValueName(85c52e162fed56f9).(const char *valueName)
713 {
714 m_valueNamescxx . . $ CppUtilities/Argument#m_valueNames..emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).(valueName);
715 }
716
717 /*!
718 * \brief Returns an indication whether all required values are present.
719 */
720 inline bool Argumentcxx . . $ CppUtilities/Argument#::allRequiredValuesPresentcxx . . $ CppUtilities/Argument#allRequiredValuesPresent(2ff7c7de1baa6d0a).(stdcxx . . $ std/::size_tcxx . . $ std/size_t# occurrence) const
721 {
722 return m_requiredValueCountcxx . . $ CppUtilities/Argument#m_requiredValueCount. == Argumentcxx . . $ CppUtilities/Argument#::varValueCountcxx . . $ CppUtilities/Argument#varValueCount.
723 || (m_occurrencescxx . . $ CppUtilities/Argument#m_occurrences.[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).occurrence].valuescxx . . $ CppUtilities/ArgumentOccurrence#values..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).() >= static_cast<stdcxx . . $ std/::size_tcxx . . $ std/size_t#>(m_requiredValueCountcxx . . $ CppUtilities/Argument#m_requiredValueCount.));
724 }
725
726 /*!
727 * \brief Returns an indication whether the argument is an implicit argument.
728 * \sa setImplicit()
729 */
730 inline bool Argumentcxx . . $ CppUtilities/Argument#::isImplicitcxx . . $ CppUtilities/Argument#isImplicit(50ce9a9e25b4a850).() const
731 {
732 return m_flagscxx . . $ CppUtilities/Argument#m_flags. &cxx . . $ CppUtilities/`operator&`(564b1b0111016947). Flagscxx . . $ CppUtilities/Argument#Flags#::Implicitcxx . . $ CppUtilities/Argument#Flags#Implicit.;
733 }
734
735 /*!
736 * \brief Sets whether the argument is an implicit argument.
737 * \sa isImplicit()
738 */
739 inline void Argumentcxx . . $ CppUtilities/Argument#::setImplicitcxx . . $ CppUtilities/Argument#setImplicit(b45ddcbc8423892c).(bool implicit)
740 {
741 setFlagscxx . . $ CppUtilities/Argument#setFlags(28d96d49eed1205c).(Flagscxx . . $ CppUtilities/Argument#Flags#::Implicitcxx . . $ CppUtilities/Argument#Flags#Implicit., implicit);
742 }
743
744 /*!
745 * \brief Returns an indication whether the argument could be detected when parsing.
746 */
747 inline bool Argumentcxx . . $ CppUtilities/Argument#::isPresentcxx . . $ CppUtilities/Argument#isPresent(50ce9a9e25b4a850).() const
748 {
749 return !m_occurrencescxx . . $ CppUtilities/Argument#m_occurrences..emptycxx . . $ std/vector#empty(3482b152b9333168).();
750 }
751
752 /*!
753 * \brief Returns how often the argument could be detected when parsing.
754 */
755 inline stdcxx . . $ std/::size_tcxx . . $ std/size_t# Argumentcxx . . $ CppUtilities/Argument#::occurrencescxx . . $ CppUtilities/Argument#occurrences(fe4d2d262d4164a8).() const
756 {
757 return m_occurrencescxx . . $ CppUtilities/Argument#m_occurrences..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).();
758 }
759
760 /*!
761 * \brief Returns the indices of the argument's occurrences which could be detected when parsing.
762 */
763 inline stdcxx . . $ std/::size_tcxx . . $ std/size_t# Argumentcxx . . $ CppUtilities/Argument#::indexcxx . . $ CppUtilities/Argument#index(611be0c07d97f8b8).(stdcxx . . $ std/::size_tcxx . . $ std/size_t# occurrence) const
764 {
765 return m_occurrencescxx . . $ CppUtilities/Argument#m_occurrences.[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).occurrence].indexcxx . . $ CppUtilities/ArgumentOccurrence#index.;
766 }
767
768 /*!
769 * \brief Returns the minimum number of occurrences.
770 *
771 * If the argument occurs not that many times, the parser will complain.
772 */
773 inline stdcxx . . $ std/::size_tcxx . . $ std/size_t# Argumentcxx . . $ CppUtilities/Argument#::minOccurrencescxx . . $ CppUtilities/Argument#minOccurrences(fe4d2d262d4164a8).() const
774 {
775 return m_minOccurrencescxx . . $ CppUtilities/Argument#m_minOccurrences.;
776 }
777
778 /*!
779 * \brief Returns the maximum number of occurrences.
780 *
781 * If the argument occurs more often, the parser will complain.
782 */
783 inline stdcxx . . $ std/::size_tcxx . . $ std/size_t# Argumentcxx . . $ CppUtilities/Argument#::maxOccurrencescxx . . $ CppUtilities/Argument#maxOccurrences(fe4d2d262d4164a8).() const
784 {
785 return m_maxOccurrencescxx . . $ CppUtilities/Argument#m_maxOccurrences.;
786 }
787
788 inline bool Argumentcxx . . $ CppUtilities/Argument#::isDeprecatedcxx . . $ CppUtilities/Argument#isDeprecated(50ce9a9e25b4a850).() const
789 {
790 return m_flagscxx . . $ CppUtilities/Argument#m_flags. &cxx . . $ CppUtilities/`operator&`(564b1b0111016947). Flagscxx . . $ CppUtilities/Argument#Flags#::Deprecatedcxx . . $ CppUtilities/Argument#Flags#Deprecated.;
791 }
792
793 /*!
794 * \brief Returns the argument which obsoletes this argument.
795 */
796 inline const Argumentcxx . . $ CppUtilities/Argument# *Argumentcxx . . $ CppUtilities/Argument#::deprecatedBycxx . . $ CppUtilities/Argument#deprecatedBy(1d185535a93e5288).() const
797 {
798 return m_deprecatedBycxx . . $ CppUtilities/Argument#m_deprecatedBy.;
799 }
800
801 /*!
802 * \brief Marks the argument as deprecated.
803 *
804 * If another argument should be used instead, specify it via \a deprecatedBy.
805 */
806 inline void Argumentcxx . . $ CppUtilities/Argument#::markAsDeprecatedcxx . . $ CppUtilities/Argument#markAsDeprecated(e71b349e7ebca7e6).(const Argumentcxx . . $ CppUtilities/Argument# *deprecatedBy)
807 {
808 setFlagscxx . . $ CppUtilities/Argument#setFlags(28d96d49eed1205c).(Flagscxx . . $ CppUtilities/Argument#Flags#::Deprecatedcxx . . $ CppUtilities/Argument#Flags#Deprecated., true);
809 m_deprecatedBycxx . . $ CppUtilities/Argument#m_deprecatedBy. = deprecatedBy;
810 }
811
812 /*!
813 * \brief Sets the allowed number of occurrences.
814 * \sa minOccurrences()
815 * \sa maxOccurrences()
816 */
817 inline void Argumentcxx . . $ CppUtilities/Argument#::setConstraintscxx . . $ CppUtilities/Argument#setConstraints(6714b5f2551eea49).(stdcxx . . $ std/::size_tcxx . . $ std/size_t# minOccurrences, stdcxx . . $ std/::size_tcxx . . $ std/size_t# maxOccurrences)
818 {
819 m_minOccurrencescxx . . $ CppUtilities/Argument#m_minOccurrences. = minOccurrences;
820 m_maxOccurrencescxx . . $ CppUtilities/Argument#m_maxOccurrences. = maxOccurrences;
821 }
822
823 /*!
824 * \brief Returns the path of the specified \a occurrence.
825 */
826 inline const stdcxx . . $ std/::vectorcxx . . $ std/vector#<Argumentcxx . . $ CppUtilities/Argument# *> &Argumentcxx . . $ CppUtilities/Argument#::pathcxx . . $ CppUtilities/Argument#path(b87142e1c5eb1796).(stdcxx . . $ std/::size_tcxx . . $ std/size_t# occurrence) const
827 {
828 return m_occurrencescxx . . $ CppUtilities/Argument#m_occurrences.[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).occurrence].pathcxx . . $ CppUtilities/ArgumentOccurrence#path.;
829 }
830
831 /*!
832 * \brief Returns an indication whether the argument is mandatory.
833 *
834 * The parser will complain if a mandatory argument is not present.
835 *
836 * The default value is false.
837 *
838 * \sa setRequired()
839 */
840 inline bool Argumentcxx . . $ CppUtilities/Argument#::isRequiredcxx . . $ CppUtilities/Argument#isRequired(50ce9a9e25b4a850).() const
841 {
842 return m_minOccurrencescxx . . $ CppUtilities/Argument#m_minOccurrences.;
843 }
844
845 /*!
846 * \brief Sets whether this argument is mandatory or not.
847 *
848 * The parser will complain if a mandatory argument is not present.
849 *
850 * * \sa isRequired()
851 */
852 inline void Argumentcxx . . $ CppUtilities/Argument#::setRequiredcxx . . $ CppUtilities/Argument#setRequired(b45ddcbc8423892c).(bool required)
853 {
854 if (required) {
855 if (!m_minOccurrencescxx . . $ CppUtilities/Argument#m_minOccurrences.) {
856 m_minOccurrencescxx . . $ CppUtilities/Argument#m_minOccurrences. = 1;
857 }
858 } else {
859 m_minOccurrencescxx . . $ CppUtilities/Argument#m_minOccurrences. = 0;
860 }
861 }
862
863 /*!
864 * \brief Returns Argument::Flags for the argument.
865 */
866 inline Argumentcxx . . $ CppUtilities/Argument#::Flagscxx . . $ CppUtilities/Argument#Flags# Argumentcxx . . $ CppUtilities/Argument#::flagscxx . . $ CppUtilities/Argument#flags(17c623cd32e8f2b8).() const
867 {
868 return m_flagscxx . . $ CppUtilities/Argument#m_flags.;
869 }
870
871 /*!
872 * \brief Replaces all Argument::Flags for the argument with the \a flags.
873 */
874 inline void Argumentcxx . . $ CppUtilities/Argument#::setFlagscxx . . $ CppUtilities/Argument#setFlags(45a26be16130673e).(Argumentcxx . . $ CppUtilities/Argument#::Flagscxx . . $ CppUtilities/Argument#Flags# flags)
875 {
876 m_flagscxx . . $ CppUtilities/Argument#m_flags. = flags;
877 }
878
879 /*!
880 * \brief Adds or removes the specified \a flags.
881 */
882 inline void Argumentcxx . . $ CppUtilities/Argument#::setFlagscxx . . $ CppUtilities/Argument#setFlags(28d96d49eed1205c).(Argumentcxx . . $ CppUtilities/Argument#::Flagscxx . . $ CppUtilities/Argument#Flags# flags, bool add)
883 {
884 m_flagscxx . . $ CppUtilities/Argument#m_flags. = add ? (m_flagscxx . . $ CppUtilities/Argument#m_flags. |cxx . . $ CppUtilities/`operator|`(895db631fc1941b5). flags)
885 : static_cast<Argumentcxx . . $ CppUtilities/Argument#::Flagscxx . . $ CppUtilities/Argument#Flags#>(static_cast<stdcxx . . $ std/::underlying_type<Argument::Flags>::type>(m_flagscxx . . $ CppUtilities/Argument#m_flags.)
886 & ~static_cast<stdcxx . . $ std/::underlying_type<Argument::Flags>::type>(flags));
887 }
888
889 /*!
890 * \brief Returns an indication whether the argument is combinable.
891 *
892 * The parser will complain if two arguments labeled as uncombinable are
893 * present at the same time.
894 *
895 * \sa setCombinable()
896 */
897 inline bool Argumentcxx . . $ CppUtilities/Argument#::isCombinablecxx . . $ CppUtilities/Argument#isCombinable(50ce9a9e25b4a850).() const
898 {
899 return m_flagscxx . . $ CppUtilities/Argument#m_flags. &cxx . . $ CppUtilities/`operator&`(564b1b0111016947). Flagscxx . . $ CppUtilities/Argument#Flags#::Combinablecxx . . $ CppUtilities/Argument#Flags#Combinable.;
900 }
901
902 /*!
903 * \brief Sets whether this argument can be combined.
904 *
905 * The parser will complain if two arguments labeled as uncombinable are
906 * present at the same time.
907 *
908 * \sa isCombinable()
909 */
910 inline void Argumentcxx . . $ CppUtilities/Argument#::setCombinablecxx . . $ CppUtilities/Argument#setCombinable(b45ddcbc8423892c).(bool combinable)
911 {
912 setFlagscxx . . $ CppUtilities/Argument#setFlags(28d96d49eed1205c).(Flagscxx . . $ CppUtilities/Argument#Flags#::Combinablecxx . . $ CppUtilities/Argument#Flags#Combinable., combinable);
913 }
914
915 /*!
916 * \brief Returns whether the argument denotes an operation.
917 *
918 * An argument which denotes an operation might be specified
919 * without "--" or "-" prefix.
920 *
921 * The default value is false, except for OperationArgument instances.
922 *
923 * \sa setDenotesOperation()
924 */
925 inline bool Argumentcxx . . $ CppUtilities/Argument#::denotesOperationcxx . . $ CppUtilities/Argument#denotesOperation(50ce9a9e25b4a850).() const
926 {
927 return m_flagscxx . . $ CppUtilities/Argument#m_flags. &cxx . . $ CppUtilities/`operator&`(564b1b0111016947). Flagscxx . . $ CppUtilities/Argument#Flags#::Operationcxx . . $ CppUtilities/Argument#Flags#Operation.;
928 }
929
930 /*!
931 * \brief Sets whether the argument denotes the operation.
932 * \sa denotesOperation()
933 */
934 inline void Argumentcxx . . $ CppUtilities/Argument#::setDenotesOperationcxx . . $ CppUtilities/Argument#setDenotesOperation(b45ddcbc8423892c).(bool denotesOperation)
935 {
936 setFlagscxx . . $ CppUtilities/Argument#setFlags(28d96d49eed1205c).(Flagscxx . . $ CppUtilities/Argument#Flags#::Operationcxx . . $ CppUtilities/Argument#Flags#Operation., denotesOperation);
937 }
938
939 /*!
940 * \brief Returns the assigned callback function.
941 * \sa setCallback()
942 */
943 inline const Argumentcxx . . $ CppUtilities/Argument#::CallbackFunctioncxx . . $ CppUtilities/Argument#CallbackFunction# &Argumentcxx . . $ CppUtilities/Argument#::callbackcxx . . $ CppUtilities/Argument#callback(be5f22ef79a956ac).() const
944 {
945 return m_callbackFunctioncxx . . $ CppUtilities/Argument#m_callbackFunction.;
946 }
947
948 /*!
949 * \brief Sets a \a callback function which will be called by the parser if
950 * the argument could be found and no parsing errors occurred.
951 * \remarks The \a callback will be called for each occurrence of the argument.
952 * \sa callback()
953 */
954 inline void Argumentcxx . . $ CppUtilities/Argument#::setCallbackcxx . . $ CppUtilities/Argument#setCallback(e4ee40b4f868025b).(Argumentcxx . . $ CppUtilities/Argument#::CallbackFunctioncxx . . $ CppUtilities/Argument#CallbackFunction# callback)
955 {
956 m_callbackFunctioncxx . . $ CppUtilities/Argument#m_callbackFunction. =cxx . . $ std/function#`operator=`(cd4c190db6d6518f). callback;
957 }
958
959 /*!
960 * \brief Returns the secondary arguments for this argument.
961 *
962 * \sa setSubArguments()
963 * \sa hasSubArguments()
964 */
965 inline const ArgumentVectorcxx . . $ CppUtilities/ArgumentVector# &Argumentcxx . . $ CppUtilities/Argument#::subArgumentscxx . . $ CppUtilities/Argument#subArguments(1ef3bc1254d64c10).() const
966 {
967 return m_subArgscxx . . $ CppUtilities/Argument#m_subArgs.;
968 }
969
970 /*!
971 * \brief Returns an indication whether the argument has secondary arguments.
972 *
973 * \sa secondaryArguments()
974 * \sa setSubArguments()
975 */
976 inline bool Argumentcxx . . $ CppUtilities/Argument#::hasSubArgumentscxx . . $ CppUtilities/Argument#hasSubArguments(50ce9a9e25b4a850).() const
977 {
978 return !m_subArgscxx . . $ CppUtilities/Argument#m_subArgs..emptycxx . . $ std/vector#empty(3482b152b9333168).();
979 }
980
981 /*!
982 * \brief Returns the parents of this argument.
983 *
984 * If this argument is used as secondary argument, the arguments which
985 * contain this argument as secondary arguments are returned
986 * as "parents" of this argument.
987 *
988 * If this argument is used as a main argument shouldn't be used as
989 * secondary argument at the same time and thus have no parents.
990 */
991 inline const ArgumentVectorcxx . . $ CppUtilities/ArgumentVector# &Argumentcxx . . $ CppUtilities/Argument#::parentscxx . . $ CppUtilities/Argument#parents(1ef3bc1254d64c10).() const
992 {
993 return m_parentscxx . . $ CppUtilities/Argument#m_parents.;
994 }
995
996 /*!
997 * \brief Returns an indication whether the argument is used as main argument.
998 *
999 * An argument used as main argument shouldn't be used as secondary
1000 * arguments at the same time.
1001 */
1002 inline bool Argumentcxx . . $ CppUtilities/Argument#::isMainArgumentcxx . . $ CppUtilities/Argument#isMainArgument(50ce9a9e25b4a850).() const
1003 {
1004 return m_isMainArgcxx . . $ CppUtilities/Argument#m_isMainArg.;
1005 }
1006
1007 /*!
1008 * \brief Returns the items to be considered when generating completion for the values.
1009 *
1010 * By default, files and directories are considered, unless pre-defined values have been
1011 * specified using setPreDefinedCompletionValues().
1012 */
1013 inline ValueCompletionBehaviorcxx . . $ CppUtilities/ValueCompletionBehavior# Argumentcxx . . $ CppUtilities/Argument#::valueCompletionBehaviourcxx . . $ CppUtilities/Argument#valueCompletionBehaviour(e66dc16b08d52b98).() const
1014 {
1015 return m_valueCompletionBehaviorcxx . . $ CppUtilities/Argument#m_valueCompletionBehavior.;
1016 }
1017
1018 /*!
1019 * \brief Sets the items to be considered when generating completion for the values.
1020 *
1021 * By default, files and directories are considered, unless pre-defined values have been
1022 * specified using setPreDefinedCompletionValues().
1023 */
1024 inline void Argumentcxx . . $ CppUtilities/Argument#::setValueCompletionBehaviorcxx . . $ CppUtilities/Argument#setValueCompletionBehavior(f9523c9a7dbf97a5).(ValueCompletionBehaviorcxx . . $ CppUtilities/ValueCompletionBehavior# completionValues)
1025 {
1026 m_valueCompletionBehaviorcxx . . $ CppUtilities/Argument#m_valueCompletionBehavior. = completionValues;
1027 }
1028
1029 /*!
1030 * \brief Returns the assigned values used when generating completion for the values.
1031 */
1032 inline const char *Argumentcxx . . $ CppUtilities/Argument#::preDefinedCompletionValuescxx . . $ CppUtilities/Argument#preDefinedCompletionValues(a9f41ea0e82d88cf).() const
1033 {
1034 return m_preDefinedCompletionValuescxx . . $ CppUtilities/Argument#m_preDefinedCompletionValues.;
1035 }
1036
1037 /*!
1038 * \brief Assigns the values to be used when generating completion for the values.
1039 */
1040 inline void Argumentcxx . . $ CppUtilities/Argument#::setPreDefinedCompletionValuescxx . . $ CppUtilities/Argument#setPreDefinedCompletionValues(85c52e162fed56f9).(const char *preDefinedCompletionValues)
1041 {
1042 m_preDefinedCompletionValuescxx . . $ CppUtilities/Argument#m_preDefinedCompletionValues. = preDefinedCompletionValues;
1043 }
1044
1045 /*!
1046 * \brief Resets occurrences (indices, values and paths).
1047 *
1048 * So parsing results are wiped while the argument definition is preserved.
1049 */
1050 inline void Argumentcxx . . $ CppUtilities/Argument#::resetcxx . . $ CppUtilities/Argument#reset(49f6e7a06ebc5aa8).()
1051 {
1052 m_occurrencescxx . . $ CppUtilities/Argument#m_occurrences..clearcxx . . $ std/vector#clear(ced63f7c635d850d).();
1053 }
1054
1055 inline OperationArgumentcxx . . $ CppUtilities/OperationArgument#::OperationArgumentcxx . . $ CppUtilities/OperationArgument#OperationArgument(af3d03003c91f516).(const char *name, char abbreviation, const char *description, const char *example)
1056 : Argumentcxx . . $ CppUtilities/Argument#Argument(af3d03003c91f516).(name, abbreviation, description, example)
1057 {
1058 setDenotesOperationcxx . . $ CppUtilities/Argument#setDenotesOperation(b45ddcbc8423892c).(true);
1059 }
1060
1061 /*!
1062 * \brief Constructs a new ConfigValueArgument with the specified parameter. The initial value of requiredValueCount() is set to size of specified \a valueNames.
1063 */
1064 inline ConfigValueArgumentcxx . . $ CppUtilities/ConfigValueArgument#::ConfigValueArgumentcxx . . $ CppUtilities/ConfigValueArgument#ConfigValueArgument(8938ad5557ae1687).(
1065 const char *name, char abbreviation, const char *description, stdcxx . . $ std/::initializer_listcxx . . $ std/initializer_list#<const char *> valueNames)
1066 : Argumentcxx . . $ CppUtilities/Argument#Argument(af3d03003c91f516).(name, abbreviation, description)
1067 {
1068 setCombinablecxx . . $ CppUtilities/Argument#setCombinable(b45ddcbc8423892c).(true);
1069 setRequiredValueCountcxx . . $ CppUtilities/Argument#setRequiredValueCount(2c44cd906ae4e829).(valueNames.sizecxx . . $ std/initializer_list#size(c9b1e749b64d5edc).());
1070 setValueNamescxx . . $ CppUtilities/Argument#setValueNames(d357f9644586045e).(valueNames);
1071 }
1072
1073 /*!
1074 * \brief Returns information about all occurrences of the argument which have been detected when parsing.
1075 * \remarks The convenience methods isPresent(), values() and path() provide direct access to these information for a particular occurrence.
1076 */
1077 inline const stdcxx . . $ std/::vectorcxx . . $ std/vector#<ArgumentOccurrencecxx . . $ CppUtilities/ArgumentOccurrence#> &Argumentcxx . . $ CppUtilities/Argument#::occurrenceInfocxx . . $ CppUtilities/Argument#occurrenceInfo(e4ad38e4a0a57b47).() const
1078 {
1079 return m_occurrencescxx . . $ CppUtilities/Argument#m_occurrences.;
1080 }
1081
1082 /*!
1083 * \brief Returns information about all occurrences of the argument which have been detected when parsing.
1084 * \remarks
1085 * This information is meant to be set by the ArgumentParser. Modifying it directly is likely not a good idea. This method has been
1086 * added primarily for testing purposes. In this case it might make sense to skip the actual parsing and just provide some dummy values.
1087 */
1088 inline stdcxx . . $ std/::vectorcxx . . $ std/vector#<ArgumentOccurrencecxx . . $ CppUtilities/ArgumentOccurrence#> &Argumentcxx . . $ CppUtilities/Argument#::occurrenceInfocxx . . $ CppUtilities/Argument#occurrenceInfo(3aed361425eaf2a8).()
1089 {
1090 return m_occurrencescxx . . $ CppUtilities/Argument#m_occurrences.;
1091 }
1092
1093 /*!
1094 * \brief Returns the main arguments.
1095 * \sa setMainArguments()
1096 */
1097 inline const ArgumentVectorcxx . . $ CppUtilities/ArgumentVector# &ArgumentParsercxx . . $ CppUtilities/ArgumentParser#::mainArgumentscxx . . $ CppUtilities/ArgumentParser#mainArguments(1ef3bc1254d64c10).() const
1098 {
1099 return m_mainArgscxx . . $ CppUtilities/ArgumentParser#m_mainArgs.;
1100 }
1101
1102 /*!
1103 * \brief Returns the actual number of arguments that could be found when parsing.
1104 */
1105 inline unsigned int ArgumentParsercxx . . $ CppUtilities/ArgumentParser#::actualArgumentCountcxx . . $ CppUtilities/ArgumentParser#actualArgumentCount(ddd8539a2fcdd4ce).() const
1106 {
1107 return m_actualArgccxx . . $ CppUtilities/ArgumentParser#m_actualArgc.;
1108 }
1109
1110 /*!
1111 * \brief Returns the name of the current executable.
1112 */
1113 inline const char *ArgumentParsercxx . . $ CppUtilities/ArgumentParser#::executablecxx . . $ CppUtilities/ArgumentParser#executable(a9f41ea0e82d88cf).() const
1114 {
1115 return m_executablecxx . . $ CppUtilities/ArgumentParser#m_executable.;
1116 }
1117
1118 /*!
1119 * \brief Returns how unknown arguments are treated.
1120 *
1121 * The default value is UnknownArgumentBehavior::Fail.
1122 */
1123 inline UnknownArgumentBehaviorcxx . . $ CppUtilities/UnknownArgumentBehavior# ArgumentParsercxx . . $ CppUtilities/ArgumentParser#::unknownArgumentBehaviorcxx . . $ CppUtilities/ArgumentParser#unknownArgumentBehavior(cf4cd57dc503ea70).() const
1124 {
1125 return m_unknownArgBehaviorcxx . . $ CppUtilities/ArgumentParser#m_unknownArgBehavior.;
1126 }
1127
1128 /*!
1129 * \brief Sets how unknown arguments are treated.
1130 *
1131 * The default value is UnknownArgumentBehavior::Fail.
1132 */
1133 inline void ArgumentParsercxx . . $ CppUtilities/ArgumentParser#::setUnknownArgumentBehaviorcxx . . $ CppUtilities/ArgumentParser#setUnknownArgumentBehavior(b1521e9ef4d9e3dc).(UnknownArgumentBehaviorcxx . . $ CppUtilities/UnknownArgumentBehavior# behavior)
1134 {
1135 m_unknownArgBehaviorcxx . . $ CppUtilities/ArgumentParser#m_unknownArgBehavior. = behavior;
1136 }
1137
1138 /*!
1139 * \brief Returns the default argument.
1140 * \remarks The default argument is assumed to be present if no other arguments have been specified.
1141 */
1142 inline Argumentcxx . . $ CppUtilities/Argument# *ArgumentParsercxx . . $ CppUtilities/ArgumentParser#::defaultArgumentcxx . . $ CppUtilities/ArgumentParser#defaultArgument(cb6a3fc127670316).() const
1143 {
1144 return m_defaultArgcxx . . $ CppUtilities/ArgumentParser#m_defaultArg.;
1145 }
1146
1147 /*!
1148 * \brief Sets the default argument.
1149 * \remarks The default argument is assumed to be present if no other arguments have been specified.
1150 */
1151 inline void ArgumentParsercxx . . $ CppUtilities/ArgumentParser#::setDefaultArgumentcxx . . $ CppUtilities/ArgumentParser#setDefaultArgument(c2eefe819a479349).(Argumentcxx . . $ CppUtilities/Argument# *argument)
1152 {
1153 m_defaultArgcxx . . $ CppUtilities/ArgumentParser#m_defaultArg. = argument;
1154 }
1155
1156 /*!
1157 * \brief Checks whether constraints are violated.
1158 * \remarks Automatically called by parseArgs().
1159 * \throws Throws Failure if constraints are violated.
1160 */
1161 inline void ArgumentParsercxx . . $ CppUtilities/ArgumentParser#::checkConstraintscxx . . $ CppUtilities/ArgumentParser#checkConstraints(49f6e7a06ebc5aa8).()
1162 {
1163 checkConstraintscxx . . $ CppUtilities/ArgumentParser#checkConstraints(116237cab03ffd67).(m_mainArgscxx . . $ CppUtilities/ArgumentParser#m_mainArgs.);
1164 }
1165
1166 /*!
1167 * \brief Invokes all assigned callbacks.
1168 * \remarks Automatically called by parseArgs().
1169 */
1170 inline void ArgumentParsercxx . . $ CppUtilities/ArgumentParser#::invokeCallbackscxx . . $ CppUtilities/ArgumentParser#invokeCallbacks(49f6e7a06ebc5aa8).()
1171 {
1172 invokeCallbackscxx . . $ CppUtilities/ArgumentParser#invokeCallbacks(116237cab03ffd67).(m_mainArgscxx . . $ CppUtilities/ArgumentParser#m_mainArgs.);
1173 }
1174
1175 /*!
1176 * \brief Specifies a function quit the application.
1177 * \remarks Currently only used after printing Bash completion. Default is std::exit().
1178 */
1179 inline void ArgumentParsercxx . . $ CppUtilities/ArgumentParser#::setExitFunctioncxx . . $ CppUtilities/ArgumentParser#setExitFunction(c984aeb66bdba57e).(stdcxx . . $ std/::functioncxx . . $ std/function#<void(int)> exitFunction)
1180 {
1181 m_exitFunctioncxx . . $ CppUtilities/ArgumentParser#m_exitFunction. =cxx . . $ std/function#`operator=`(cd4c190db6d6518f). exitFunction;
1182 }
1183
1184 /*!
1185 * \brief Returns the `--help` argument.
1186 */
1187 inline const HelpArgumentcxx . . $ CppUtilities/HelpArgument# &ArgumentParsercxx . . $ CppUtilities/ArgumentParser#::helpArgcxx . . $ CppUtilities/ArgumentParser#helpArg(558d3090d72dbcec).() const
1188 {
1189 return m_helpArgcxx . . $ CppUtilities/ArgumentParser#m_helpArg.;
1190 }
1191
1192 /*!
1193 * \brief Returns the `--help` argument.
1194 */
1195 inline HelpArgumentcxx . . $ CppUtilities/HelpArgument# &ArgumentParsercxx . . $ CppUtilities/ArgumentParser#::helpArgcxx . . $ CppUtilities/ArgumentParser#helpArg(f85ec61c65e3ee59).()
1196 {
1197 return m_helpArgcxx . . $ CppUtilities/ArgumentParser#m_helpArg.;
1198 }
1199
1200 /*!
1201 * \brief Returns the `--no-color` argument.
1202 */
1203 inline const NoColorArgumentcxx . . $ CppUtilities/NoColorArgument# &ArgumentParsercxx . . $ CppUtilities/ArgumentParser#::noColorArgcxx . . $ CppUtilities/ArgumentParser#noColorArg(7764408f961aadbc).() const
1204 {
1205 return m_noColorArgcxx . . $ CppUtilities/ArgumentParser#m_noColorArg.;
1206 }
1207
1208 /*!
1209 * \brief Returns the `--no-color` argument.
1210 */
1211 inline NoColorArgumentcxx . . $ CppUtilities/NoColorArgument# &ArgumentParsercxx . . $ CppUtilities/ArgumentParser#::noColorArgcxx . . $ CppUtilities/ArgumentParser#noColorArg(a5cff874ad1ea402).()
1212 {
1213 return m_noColorArgcxx . . $ CppUtilities/ArgumentParser#m_noColorArg.;
1214 }
1215
1216 } // namespace CppUtilities
1217
1218 #endif // APPLICATION_UTILITIES_ARGUMENTPARSER_H