C++ Utilities
4.17.0
Useful C++ classes and routines such as argument parser, IO and conversion utilities
|
The NoColorArgument class allows to specify whether use of escape codes or similar technique to provide formatted output on the terminal should be enabled/disabled. More...
#include <argumentparser.h>
Public Member Functions | |
NoColorArgument () | |
Constructs a new NoColorArgument argument. More... | |
~NoColorArgument () | |
Destroys the object. More... | |
![]() | |
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. More... | |
~Argument () | |
Destroys the Argument. More... | |
const char * | name () const |
Returns the name of the argument. More... | |
void | setName (const char *name) |
Sets the name of the argument. More... | |
char | abbreviation () const |
Returns the abbreviation of the argument. More... | |
void | setAbbreviation (char abbreviation) |
Sets the abbreviation of the argument. More... | |
const char * | environmentVariable () const |
Returns the environment variable queried when firstValue() is called. More... | |
void | setEnvironmentVariable (const char *environmentVariable) |
Sets the environment variable queried when firstValue() is called. More... | |
const char * | description () const |
Returns the description of the argument. More... | |
void | setDescription (const char *description) |
Sets the description of the argument. More... | |
const char * | example () const |
Returns the usage example of the argument. More... | |
void | setExample (const char *example) |
Sets the a usage example for the argument. More... | |
std::size_t | requiredValueCount () const |
Returns the number of values which are required to be given for this argument. More... | |
void | setRequiredValueCount (std::size_t requiredValueCount) |
Sets the number of values which are required to be given for this argument. More... | |
const std::vector< const char * > & | valueNames () const |
Returns the names of the requried values. More... | |
void | setValueNames (std::initializer_list< const char * > valueNames) |
Sets the names of the requried values. More... | |
void | appendValueName (const char *valueName) |
Appends a value name. More... | |
void | setConstraints (std::size_t minOccurrences, std::size_t maxOccurrences) |
Sets the allowed number of occurrences. More... | |
const std::vector< Argument * > & | path (std::size_t occurrence=0) const |
Returns the path of the specified occurrence. More... | |
bool | isRequired () const |
Returns an indication whether the argument is mandatory. More... | |
void | setRequired (bool required) |
Sets whether this argument is mandatory or not. More... | |
bool | isCombinable () const |
Returns an indication whether the argument is combinable. More... | |
void | setCombinable (bool value) |
Sets whether this argument can be combined. More... | |
bool | isImplicit () const |
Returns an indication whether the argument is an implicit argument. More... | |
void | setImplicit (bool value) |
Sets whether the argument is an implicit argument. More... | |
bool | denotesOperation () const |
Returns whether the argument denotes an operation. More... | |
void | setDenotesOperation (bool denotesOperation) |
Sets whether the argument denotes the operation. More... | |
const CallbackFunction & | callback () const |
Returns the assigned callback function. More... | |
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 occured. More... | |
const ArgumentVector & | subArguments () const |
Returns the secondary arguments for this argument. More... | |
void | setSubArguments (const ArgumentInitializerList &subArguments) |
Sets the secondary arguments for this arguments. More... | |
void | addSubArgument (Argument *arg) |
Adds arg as a secondary argument for this argument. More... | |
bool | hasSubArguments () const |
Returns an indication whether the argument has secondary arguments. More... | |
const ArgumentVector | parents () const |
Returns the parents of this argument. More... | |
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. More... | |
ValueCompletionBehavior | valueCompletionBehaviour () const |
Returns the items to be considered when generating completion for the values. More... | |
void | setValueCompletionBehavior (ValueCompletionBehavior valueCompletionBehaviour) |
Sets the items to be considered when generating completion for the values. More... | |
const char * | preDefinedCompletionValues () const |
Returns the assigned values used when generating completion for the values. More... | |
void | setPreDefinedCompletionValues (const char *preDefinedCompletionValues) |
Assignes the values to be used when generating completion for the values. More... | |
const std::vector< const char * > & | values (std::size_t occurrence=0) const |
Returns the parameter values for the specified occurrence of argument. More... | |
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. More... | |
template<typename... TargetType> | |
std::vector< std::tuple< TargetType... > > | allValuesAs () const |
Converts the present values for all occurrence to the specified target types. More... | |
const char * | firstValue () const |
Returns the first parameter value of the first occurrence of the argument. More... | |
bool | allRequiredValuesPresent (std::size_t occurrence=0) const |
Returns an indication whether all required values are present. More... | |
bool | isPresent () const |
Returns an indication whether the argument could be detected when parsing. More... | |
std::size_t | occurrences () const |
Returns how often the argument could be detected when parsing. More... | |
std::size_t | index (std::size_t occurrence) const |
Returns the indices of the argument's occurences which could be detected when parsing. More... | |
std::size_t | minOccurrences () const |
Returns the minimum number of occurrences. More... | |
std::size_t | maxOccurrences () const |
Returns the maximum number of occurrences. More... | |
bool | isMainArgument () const |
Returns an indication whether the argument is used as main argument. More... | |
bool | isParentPresent () const |
Returns whether at least one parent argument is present. More... | |
Argument * | conflictsWithArgument () const |
Checks if this arguments conflicts with other arguments. More... | |
Argument * | wouldConflictWithArgument () const |
Checks if this argument would conflict with other arguments if it was present. More... | |
Argument * | specifiedOperation () const |
Returns the first operation argument specified by the user or nullptr if no operation has been specified. More... | |
const std::vector< ArgumentOccurrence > & | occurrenceInfo () const |
Returns information about all occurrences of the argument which have been detected when parsing. More... | |
std::vector< ArgumentOccurrence > & | occurrenceInfo () |
Returns information about all occurrences of the argument which have been detected when parsing. More... | |
void | reset () |
Resets occurrences (indices, values and paths). More... | |
void | resetRecursively () |
Resets this argument and all sub arguments recursively. More... | |
Static Public Member Functions | |
static void | apply () |
Sets EscapeCodes::enabled according to the presense of the first instantiation of NoColorArgument. More... | |
Additional Inherited Members | |
![]() | |
typedef std::function< void(const ArgumentOccurrence &)> | CallbackFunction |
![]() | |
static constexpr std::size_t | varValueCount = std::numeric_limits<std::size_t>::max() |
Denotes a variable number of values. More... | |
The NoColorArgument class allows to specify whether use of escape codes or similar technique to provide formatted output on the terminal should be enabled/disabled.
This argument will either prevent or explicitely allow the use of escape codes or similar technique to provide formatted output on the terminal. More explicitly, the argument will always allow to negate the default value of EscapeCodes::enabled which can be configured at build time by setting the CMake variable ENABLE_ESCAPE_CODES_BY_DEFAULT.
Definition at line 1071 of file argumentparser.h.
ApplicationUtilities::NoColorArgument::NoColorArgument | ( | ) |
Constructs a new NoColorArgument argument.
Definition at line 1667 of file argumentparser.cpp.
ApplicationUtilities::NoColorArgument::~NoColorArgument | ( | ) |
Destroys the object.
Definition at line 1707 of file argumentparser.cpp.
|
static |
Sets EscapeCodes::enabled according to the presense of the first instantiation of NoColorArgument.
Definition at line 1717 of file argumentparser.cpp.