C++ Utilities
4.11.0
Common C++ classes and routines used by my applications such as argument parser, IO and conversion utilities
|
Contains currently only ArgumentParser and related classes. More...
Classes | |
class | Argument |
The Argument class is a wrapper for command line argument information. More... | |
struct | ArgumentOccurrence |
The ArgumentOccurrence struct holds argument values for an occurrence of an argument. More... | |
class | ArgumentParser |
The ArgumentParser class provides a means for handling command line arguments. More... | |
class | ArgumentReader |
The ArgumentReader class internally encapsulates the process of reading command line arguments. More... | |
class | ConfigValueArgument |
The ConfigValueArgument class is an Argument where setCombinable() is true by default. More... | |
class | Failure |
The Failure class is thrown by an ArgumentParser when a parsing error occurs. More... | |
class | FakeQtConfigArguments |
The FakeQtConfigArguments class provides arguments for the Qt GUI used when the application hasn't been built with Qt GUI support. More... | |
class | HelpArgument |
The HelpArgument class prints help information for an argument parser when present (–help, -h). More... | |
class | Indentation |
The Indentation class allows printing indentation conveniently, eg. More... | |
class | 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... | |
class | OperationArgument |
The OperationArgument class is an Argument where denotesOperation() is true by default. More... | |
struct | TerminalSize |
The TerminalSize struct describes a terminal size. More... | |
class | Wrapper |
The Wrapper class is internally used print text which might needs to be wrapped preserving the indentation. More... | |
Typedefs | |
typedef std::initializer_list< Argument * > | ArgumentInitializerList |
typedef std::vector< Argument * > | ArgumentVector |
typedef std::function< bool(Argument *)> | ArgumentPredicate |
Enumerations | |
enum | UnknownArgumentBehavior { UnknownArgumentBehavior::Ignore, UnknownArgumentBehavior::Warn, UnknownArgumentBehavior::Fail } |
The UnknownArgumentBehavior enum specifies the behavior of the argument parser when an unknown argument is detected. More... | |
enum | ValueCompletionBehavior : unsigned char { ValueCompletionBehavior::None = 0, ValueCompletionBehavior::PreDefinedValues = 2, ValueCompletionBehavior::Files = 4, ValueCompletionBehavior::Directories = 8, ValueCompletionBehavior::FileSystemIfNoPreDefinedValues = 16, ValueCompletionBehavior::AppendEquationSign = 32, ValueCompletionBehavior::InvokeCallback = 64 } |
The ValueCompletionBehavior enum specifies the items to be considered when generating completion for an argument value. More... | |
enum | Response { Response::None, Response::Yes, Response::No } |
The Response enum is used to specify the default response for the confirmPrompt() method. More... | |
enum | ArgumentDenotationType : unsigned char { Value = 0, Abbreviation = 1, FullName = 2 } |
The ArgumentDenotationType enum specifies the type of a given argument denotation. More... | |
Functions | |
Argument CPP_UTILITIES_EXPORT * | firstPresentUncombinableArg (const ArgumentVector &args, const Argument *except) |
This function return the first present and uncombinable argument of the given list of arguments. More... | |
std::ostream & | operator<< (std::ostream &os, const Wrapper &wrapper) |
bool CPP_UTILITIES_EXPORT | confirmPrompt (const char *message, Response defaultResponse) |
Prompts for confirmation displaying the specified message. More... | |
TerminalSize CPP_UTILITIES_EXPORT | determineTerminalSize () |
Returns the current size of the terminal. More... | |
CPP_UTILITIES_EXPORT std::ostream & | operator<< (std::ostream &out, Indentation indentation) |
CPP_UTILITIES_EXPORT std::ostream & | operator<< (std::ostream &o, const Failure &failure) |
Prints an error message "Unable to parse arguments: ..." for the specified failure. More... | |
bool | compareArgs (const Argument *arg1, const Argument *arg2) |
Returns whether arg1 should be listed before arg2 when printing completion. More... | |
void | insertSiblings (const ArgumentVector &siblings, list< const Argument *> &target) |
Inserts the specified siblings in the target list. More... | |
Variables | |
CPP_UTILITIES_EXPORT const char * | applicationName = nullptr |
Specifies the name of the application (used by ArgumentParser::printHelp()). More... | |
CPP_UTILITIES_EXPORT const char * | applicationAuthor = nullptr |
Specifies the author of the application (used by ArgumentParser::printHelp()). More... | |
CPP_UTILITIES_EXPORT const char * | applicationVersion = nullptr |
Specifies the version of the application (used by ArgumentParser::printHelp()). More... | |
CPP_UTILITIES_EXPORT const char * | applicationUrl = nullptr |
Specifies the URL to the application website (used by ArgumentParser::printHelp()). More... | |
CPP_UTILITIES_EXPORT std::initializer_list< const char * > | dependencyVersions |
Specifies the dependency versions the application was linked against (used by ArgumentParser::printHelp()). More... | |
CPP_UTILITIES_EXPORT void(* | exitFunction )(int) = &exit |
Specifies a function quit the application. More... | |
Contains currently only ArgumentParser and related classes.
typedef std::initializer_list<Argument *> ApplicationUtilities::ArgumentInitializerList |
Definition at line 52 of file argumentparser.h.
typedef std::function<bool(Argument *)> ApplicationUtilities::ArgumentPredicate |
Definition at line 56 of file argumentparser.h.
typedef std::vector<Argument *> ApplicationUtilities::ArgumentVector |
Definition at line 55 of file argumentparser.h.
enum ApplicationUtilities::ArgumentDenotationType : unsigned char |
The ArgumentDenotationType enum specifies the type of a given argument denotation.
Enumerator | |
---|---|
Value | parameter value |
Abbreviation | argument abbreviation |
FullName | full argument name |
Definition at line 33 of file argumentparser.cpp.
|
strong |
The Response enum is used to specify the default response for the confirmPrompt() method.
Enumerator | |
---|---|
None | |
Yes | |
No |
Definition at line 18 of file commandlineutils.h.
|
strong |
The UnknownArgumentBehavior enum specifies the behavior of the argument parser when an unknown argument is detected.
Enumerator | |
---|---|
Ignore | Unknown arguments are ignored without warnings. |
Warn | A warning is printed to std::cerr if an unknown argument is detected. |
Fail | Further parsing is aborted and an ApplicationUtilities::Failure instance with an error message is thrown. |
Definition at line 62 of file argumentparser.h.
|
strong |
The ValueCompletionBehavior enum specifies the items to be considered when generating completion for an argument value.
Enumerator | |
---|---|
None | no auto-completion |
PreDefinedValues | values assigned with Argument::setPreDefinedCompletionValues() |
Files | files |
Directories | directories |
FileSystemIfNoPreDefinedValues | files and directories but only if no values have been assigned (default behavior) |
AppendEquationSign | an equation sign is appended to values which not contain an equation sign already |
InvokeCallback | whether to invoke the callback before reading pre-defined values |
Definition at line 77 of file argumentparser.h.
Returns whether arg1 should be listed before arg2 when printing completion.
Arguments are sorted by name (ascending order). However, all arguments denoting an operation are listed before all other arguments.
Definition at line 904 of file argumentparser.cpp.
bool ApplicationUtilities::confirmPrompt | ( | const char * | message, |
Response | defaultResponse = Response::None |
||
) |
Prompts for confirmation displaying the specified message.
Definition at line 21 of file commandlineutils.cpp.
TerminalSize ApplicationUtilities::determineTerminalSize | ( | ) |
Returns the current size of the terminal.
Definition at line 46 of file commandlineutils.cpp.
Argument * ApplicationUtilities::firstPresentUncombinableArg | ( | const ArgumentVector & | args, |
const Argument * | except | ||
) |
This function return the first present and uncombinable argument of the given list of arguments.
The Argument except will be ignored.
Definition at line 462 of file argumentparser.cpp.
void ApplicationUtilities::insertSiblings | ( | const ArgumentVector & | siblings, |
list< const Argument *> & | target | ||
) |
Inserts the specified siblings in the target list.
Definition at line 919 of file argumentparser.cpp.
std::ostream & ApplicationUtilities::operator<< | ( | std::ostream & | o, |
const Failure & | failure | ||
) |
Prints an error message "Unable to parse arguments: ..." for the specified failure.
Definition at line 52 of file failure.cpp.
ostream & ApplicationUtilities::operator<< | ( | std::ostream & | os, |
const Wrapper & | wrapper | ||
) |
Definition at line 281 of file argumentparser.cpp.
|
inline |
Definition at line 83 of file commandlineutils.h.
const char * ApplicationUtilities::applicationAuthor = nullptr |
Specifies the author of the application (used by ArgumentParser::printHelp()).
Definition at line 313 of file argumentparser.cpp.
const char * ApplicationUtilities::applicationName = nullptr |
Specifies the name of the application (used by ArgumentParser::printHelp()).
Definition at line 311 of file argumentparser.cpp.
const char * ApplicationUtilities::applicationUrl = nullptr |
Specifies the URL to the application website (used by ArgumentParser::printHelp()).
Definition at line 317 of file argumentparser.cpp.
const char * ApplicationUtilities::applicationVersion = nullptr |
Specifies the version of the application (used by ArgumentParser::printHelp()).
Definition at line 315 of file argumentparser.cpp.
std::initializer_list< const char * > ApplicationUtilities::dependencyVersions |
Specifies the dependency versions the application was linked against (used by ArgumentParser::printHelp()).
Definition at line 319 of file argumentparser.cpp.
void(* ApplicationUtilities::exitFunction)(int) = &exit |
Specifies a function quit the application.
Definition at line 325 of file argumentparser.cpp.