C++ Utilities 5.24.7
Useful C++ classes and routines such as argument parser, IO and conversion utilities
Loading...
Searching...
No Matches
Public Member Functions | List of all members
CppUtilities::ConfigValueArgument Class Reference

The ConfigValueArgument class is an Argument where setCombinable() is true by default. More...

#include <argumentparser.h>

Inheritance diagram for CppUtilities::ConfigValueArgument:
[legend]
Collaboration diagram for CppUtilities::ConfigValueArgument:
[legend]

Public Member Functions

 ConfigValueArgument (const char *name, char abbreviation='\0', const char *description=nullptr, std::initializer_list< const char * > valueNames=std::initializer_list< const char * >())
 Constructs a new ConfigValueArgument with the specified parameter.
 
- Public Member Functions inherited from CppUtilities::Argument
 Argument (const char *name, char abbreviation='\0', const char *description=nullptr, const char *example=nullptr)
 Constructs an Argument with the given name, abbreviation and description.
 
 ~Argument ()
 Destroys the Argument.
 
const charname () const
 Returns the name of the argument.
 
void setName (const char *name)
 Sets the name of the argument.
 
char abbreviation () const
 Returns the abbreviation of the argument.
 
void setAbbreviation (char abbreviation)
 Sets the abbreviation of the argument.
 
const charenvironmentVariable () const
 Returns the environment variable queried when firstValue() is called.
 
void setEnvironmentVariable (const char *environmentVariable)
 Sets the environment variable queried when firstValue() is called.
 
const chardescription () const
 Returns the description of the argument.
 
void setDescription (const char *description)
 Sets the description of the argument.
 
const charexample () const
 Returns the usage example of the argument.
 
void setExample (const char *example)
 Sets the a usage example for the argument.
 
std::size_t requiredValueCount () const
 Returns the number of values which are required to be given for this argument.
 
void setRequiredValueCount (std::size_t requiredValueCount)
 Sets the number of values which are required to be given for this argument.
 
const std::vector< const char * > & valueNames () const
 Returns the names of the required values.
 
void setValueNames (std::initializer_list< const char * > valueNames)
 Sets the names of the required values.
 
void appendValueName (const char *valueName)
 Appends a value name.
 
void setConstraints (std::size_t minOccurrences, std::size_t maxOccurrences)
 Sets the allowed number of occurrences.
 
const std::vector< Argument * > & path (std::size_t occurrence=0) const
 Returns the path of the specified occurrence.
 
bool isRequired () const
 Returns an indication whether the argument is mandatory.
 
void setRequired (bool required)
 Sets whether this argument is mandatory or not.
 
Argument::Flags flags () const
 Returns Argument::Flags for the argument.
 
void setFlags (Argument::Flags flags)
 Replaces all Argument::Flags for the argument with the flags.
 
void setFlags (Argument::Flags flags, bool add)
 Adds or removes the specified flags.
 
bool isCombinable () const
 Returns an indication whether the argument is combinable.
 
void setCombinable (bool combinable)
 Sets whether this argument can be combined.
 
bool isImplicit () const
 Returns an indication whether the argument is an implicit argument.
 
void setImplicit (bool implicit)
 Sets whether the argument is an implicit argument.
 
bool denotesOperation () const
 Returns whether the argument denotes an operation.
 
void setDenotesOperation (bool denotesOperation)
 Sets whether the argument denotes the operation.
 
const CallbackFunctioncallback () const
 Returns the assigned callback function.
 
void setCallback (CallbackFunction callback)
 Sets a callback function which will be called by the parser if the argument could be found and no parsing errors occurred.
 
const ArgumentVectorsubArguments () const
 Returns the secondary arguments for this argument.
 
void setSubArguments (const ArgumentInitializerList &subArguments)
 Sets the secondary arguments for this argument.
 
void addSubArguments (const ArgumentInitializerList &subArguments)
 Sets the secondary arguments for this argument.
 
void addSubArgument (Argument *arg)
 Adds arg as a secondary argument for this argument.
 
bool hasSubArguments () const
 Returns an indication whether the argument has secondary arguments.
 
const ArgumentVectorparents () const
 Returns the parents of this argument.
 
void printInfo (std::ostream &os, unsigned char indentation=0) const
 Writes the name, the abbreviation and other information about the Argument to the give ostream.
 
ValueCompletionBehavior valueCompletionBehaviour () const
 Returns the items to be considered when generating completion for the values.
 
void setValueCompletionBehavior (ValueCompletionBehavior valueCompletionBehaviour)
 Sets the items to be considered when generating completion for the values.
 
const charpreDefinedCompletionValues () const
 Returns the assigned values used when generating completion for the values.
 
void setPreDefinedCompletionValues (const char *preDefinedCompletionValues)
 Assigns the values to be used when generating completion for the values.
 
const std::vector< const char * > & values (std::size_t occurrence=0) const
 Returns the parameter values for the specified occurrence of argument.
 
template<typename... TargetType>
std::tuple< TargetType... > valuesAs (std::size_t occurrence=0) const
 Converts the present values for the specified occurrence to the specified target types.
 
template<typename... TargetType>
std::vector< std::tuple< TargetType... > > allValuesAs () const
 Converts the present values for all occurrence to the specified target types.
 
const charfirstValue () const
 Returns the first parameter value of the first occurrence of the argument.
 
const charfirstValueOr (const char *fallback) const
 Returns the first value like Argument::firstValue() but returns fallback instead of nullptr if there's no value.
 
bool allRequiredValuesPresent (std::size_t occurrence=0) const
 Returns an indication whether all required values are present.
 
bool isPresent () const
 Returns an indication whether the argument could be detected when parsing.
 
std::size_t occurrences () const
 Returns how often the argument could be detected when parsing.
 
std::size_t index (std::size_t occurrence) const
 Returns the indices of the argument's occurrences which could be detected when parsing.
 
std::size_t minOccurrences () const
 Returns the minimum number of occurrences.
 
std::size_t maxOccurrences () const
 Returns the maximum number of occurrences.
 
bool isDeprecated () const
 
const ArgumentdeprecatedBy () const
 Returns the argument which obsoletes this argument.
 
void markAsDeprecated (const Argument *deprecatedBy=nullptr)
 Marks the argument as deprecated.
 
bool isMainArgument () const
 Returns an indication whether the argument is used as main argument.
 
bool isParentPresent () const
 Returns whether at least one parent argument is present.
 
ArgumentconflictsWithArgument () const
 Checks if this arguments conflicts with other arguments.
 
ArgumentwouldConflictWithArgument () const
 Checks if this argument would conflict with other arguments if it was present.
 
ArgumentspecifiedOperation () const
 Returns the first operation argument specified by the user or nullptr if no operation has been specified.
 
const std::vector< ArgumentOccurrence > & occurrenceInfo () const
 Returns information about all occurrences of the argument which have been detected when parsing.
 
std::vector< ArgumentOccurrence > & occurrenceInfo ()
 Returns information about all occurrences of the argument which have been detected when parsing.
 
void reset ()
 Resets occurrences (indices, values and paths).
 
void resetRecursively ()
 Resets this argument and all sub arguments recursively.
 

Additional Inherited Members

- Public Types inherited from CppUtilities::Argument
enum class  Flags : std::uint64_t {
  None = 0x0 , Combinable = 0x1 , Implicit = 0x2 , Operation = 0x4 ,
  Deprecated = 0x8 , Greedy = 0x10
}
 The Flags enum specifies options for treating the argument in a special way. More...
 
typedef std::function< void(const ArgumentOccurrence &) CallbackFunction)
 
- Static Public Attributes inherited from CppUtilities::Argument
static constexpr std::size_t varValueCount = std::numeric_limits<std::size_t>::max()
 Denotes a variable number of values.
 

Detailed Description

The ConfigValueArgument class is an Argument where setCombinable() is true by default.

See also
ConfigValueArgument::ConfigValueArgument()

Definition at line 441 of file argumentparser.h.

Constructor & Destructor Documentation

◆ ConfigValueArgument()

CppUtilities::ConfigValueArgument::ConfigValueArgument ( const char * name,
char abbreviation = '\0',
const char * description = nullptr,
std::initializer_list< const char * > valueNames = std::initializer_list<const char *>() )
inline

Constructs a new ConfigValueArgument with the specified parameter.

The initial value of requiredValueCount() is set to size of specified valueNames.

Definition at line 1062 of file argumentparser.h.


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