C++ Utilities  4.17.0
Useful C++ classes and routines such as argument parser, IO and conversion utilities
Classes | Namespaces | Macros | Typedefs | Enumerations | Functions | Variables
argumentparser.h File Reference
#include "../conversion/stringconversion.h"
#include "../global.h"
#include "../misc/traits.h"
#include <functional>
#include <initializer_list>
#include <limits>
#include <vector>
Include dependency graph for argumentparser.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ApplicationUtilities::ArgumentOccurrence
 The ArgumentOccurrence struct holds argument values for an occurrence of an argument. More...
 
class  ApplicationUtilities::Argument
 The Argument class is a wrapper for command line argument information. More...
 
class  ApplicationUtilities::ArgumentParser
 The ArgumentParser class provides a means for handling command line arguments. More...
 
class  ApplicationUtilities::HelpArgument
 The HelpArgument class prints help information for an argument parser when present (–help, -h). More...
 
class  ApplicationUtilities::OperationArgument
 The OperationArgument class is an Argument where denotesOperation() is true by default. More...
 
class  ApplicationUtilities::ConfigValueArgument
 The ConfigValueArgument class is an Argument where setCombinable() is true by default. More...
 
class  ApplicationUtilities::NoColorArgument
 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...
 

Namespaces

 ApplicationUtilities
 Contains currently only ArgumentParser and related classes.
 
 ApplicationUtilities::ValueConversion
 Contains functions to convert raw argument values to certain types.
 

Macros

#define SET_DEPENDENCY_INFO   ::ApplicationUtilities::dependencyVersions2 = DEPENCENCY_VERSIONS
 Sets meta data about the dependencies the application was linked against which is used by ArgumentParser::printHelp(). More...
 
#define SET_APPLICATION_INFO
 Sets application meta data (including SET_DEPENDENCY_INFO) used by ArgumentParser::printHelp(). More...
 

Typedefs

using ApplicationUtilities::ArgumentInitializerList = std::initializer_list< Argument * >
 
using ApplicationUtilities::ArgumentVector = std::vector< Argument * >
 
using ApplicationUtilities::ArgumentPredicate = std::function< bool(Argument *)>
 

Enumerations

enum  ApplicationUtilities::UnknownArgumentBehavior { ApplicationUtilities::UnknownArgumentBehavior::Ignore, ApplicationUtilities::UnknownArgumentBehavior::Warn, ApplicationUtilities::UnknownArgumentBehavior::Fail }
 The UnknownArgumentBehavior enum specifies the behavior of the argument parser when an unknown argument is detected. More...
 
enum  ApplicationUtilities::ParseArgumentBehavior { ApplicationUtilities::ParseArgumentBehavior::ReadArguments = 0x0, ApplicationUtilities::ParseArgumentBehavior::CheckConstraints = 0x1, ApplicationUtilities::ParseArgumentBehavior::InvokeCallbacks = 0x2, ApplicationUtilities::ParseArgumentBehavior::ExitOnFailure = 0x4 }
 The ParseArgumentBehavior enum specifies the behavior when parsing arguments. More...
 
enum  ApplicationUtilities::ValueCompletionBehavior : unsigned char {
  ApplicationUtilities::ValueCompletionBehavior::None = 0, ApplicationUtilities::ValueCompletionBehavior::PreDefinedValues = 2, ApplicationUtilities::ValueCompletionBehavior::Files = 4, ApplicationUtilities::ValueCompletionBehavior::Directories = 8,
  ApplicationUtilities::ValueCompletionBehavior::FileSystemIfNoPreDefinedValues = 16, ApplicationUtilities::ValueCompletionBehavior::AppendEquationSign = 32, ApplicationUtilities::ValueCompletionBehavior::InvokeCallback = 64
}
 The ValueCompletionBehavior enum specifies the items to be considered when generating completion for an argument value. More...
 

Functions

Argument CPP_UTILITIES_EXPORTApplicationUtilities::firstPresentUncombinableArg (const ArgumentVector &args, const Argument *except)
 This function return the first present and uncombinable argument of the given list of arguments. More...
 
template<typename TargetType , Traits::EnableIf< std::is_same< TargetType, std::string >> * = nullptr>
TargetType ApplicationUtilities::ValueConversion::convert (const char *value)
 

Variables

CPP_UTILITIES_EXPORT const char * ApplicationUtilities::applicationName = nullptr
 Specifies the name of the application (used by ArgumentParser::printHelp()). More...
 
CPP_UTILITIES_EXPORT const char * ApplicationUtilities::applicationAuthor = nullptr
 Specifies the author of the application (used by ArgumentParser::printHelp()). More...
 
CPP_UTILITIES_EXPORT const char * ApplicationUtilities::applicationVersion = nullptr
 Specifies the version of the application (used by ArgumentParser::printHelp()). More...
 
CPP_UTILITIES_EXPORT const char * ApplicationUtilities::applicationUrl = nullptr
 Specifies the URL to the application website (used by ArgumentParser::printHelp()). More...
 
CPP_UTILITIES_EXPORT std::initializer_list< const char * > ApplicationUtilities::dependencyVersions
 Specifies the dependency versions the application was linked against (used by ArgumentParser::printHelp()). More...
 
CPP_UTILITIES_EXPORT std::vector< const char * > ApplicationUtilities::dependencyVersions2
 Specifies the dependency versions the application was linked against (used by ArgumentParser::printHelp()). More...
 
CPP_UTILITIES_EXPORT void(* ApplicationUtilities::exitFunction )(int) = &exit
 Specifies a function quit the application. More...
 

Macro Definition Documentation

◆ SET_APPLICATION_INFO

#define SET_APPLICATION_INFO
Value:
SET_DEPENDENCY_INFO
CPP_UTILITIES_EXPORT const char * applicationUrl
Specifies the URL to the application website (used by ArgumentParser::printHelp()).
CPP_UTILITIES_EXPORT const char * applicationVersion
Specifies the version of the application (used by ArgumentParser::printHelp()).
CPP_UTILITIES_EXPORT const char * applicationName
Specifies the name of the application (used by ArgumentParser::printHelp()).
CPP_UTILITIES_EXPORT const char * applicationAuthor
Specifies the author of the application (used by ArgumentParser::printHelp()).

Sets application meta data (including SET_DEPENDENCY_INFO) used by ArgumentParser::printHelp().

Remarks
Reads those data from the config header so "config.h" must be included.

Definition at line 44 of file argumentparser.h.

◆ SET_DEPENDENCY_INFO

#define SET_DEPENDENCY_INFO   ::ApplicationUtilities::dependencyVersions2 = DEPENCENCY_VERSIONS

Sets meta data about the dependencies the application was linked against which is used by ArgumentParser::printHelp().

Remarks
Reads those data from the config header so "config.h" must be included.

Definition at line 34 of file argumentparser.h.