Home
Base module

OptionParser

Command-line option parser.

OptionParser

#include <icy/application.h>
struct OptionParser

Defined in src/base/include/icy/application.h:103

Command-line option parser.

List of all members

NameKindOwner
exepathvariableDeclared here
argsvariableDeclared here
OptionParserfunctionDeclared here
hasfunctionDeclared here
getfunctionDeclared here
getfunctionDeclared here

Public Attributes

ReturnNameDescription
std::stringexepath
OptionMapargs

exepath

std::string exepath

Defined in src/base/include/icy/application.h:105


args

OptionMap args

Defined in src/base/include/icy/application.h:106

Public Methods

ReturnNameDescription
OptionParserParses command-line arguments from argc/argv.
boolhas inlineReturns true if the given option key was present on the command line.
std::stringget inlineReturns the string value associated with the given option key. Returns an empty string if the key was not found.
NumericTypeget inlineReturns the value associated with the given option key, converted to a numeric type.

OptionParser

OptionParser(int argc, char * argv, const char * delim)

Defined in src/base/include/icy/application.h:112

Parses command-line arguments from argc/argv.

Parameters

  • argc Argument count from main().

  • argv Argument vector from main().

  • delim Prefix string that identifies an option key (e.g. "--").


has

inline

inline bool has(const char * key)

Defined in src/base/include/icy/application.h:117

Returns true if the given option key was present on the command line.

Parameters

  • key Option key to look up (without delimiter prefix).

Returns

True if the key exists in the parsed argument map.


get

inline

inline std::string get(const char * key)

Defined in src/base/include/icy/application.h:123

Returns the string value associated with the given option key. Returns an empty string if the key was not found.

Parameters

  • key Option key to look up.

Returns

Value string, or empty string if not present.


get

inline

template<typename NumericType> inline NumericType get(const char * key)

Defined in src/base/include/icy/application.h:136

Returns the value associated with the given option key, converted to a numeric type.

Parameters

  • NumericType Integral or floating-point type to convert the value to.

Parameters

  • key Option key to look up.

Returns

Converted numeric value.