# HG changeset patch # User John Schneiderman # Date 1402759578 0 # Node ID d051e4094072d949c068d67f6db8791c443a4983 # Parent 7ef0a8f6b3767b00352c2bb231964cc5f98d1fb5 Added ability to expand the types of arguments supplied. ti: - diff -r 7ef0a8f6b376 -r d051e4094072 doc/ChangeLog --- a/doc/ChangeLog Sat Jun 14 15:10:10 2014 +0000 +++ b/doc/ChangeLog Sat Jun 14 15:26:18 2014 +0000 @@ -26,6 +26,7 @@ - Prevented the addition of more options once they are set. - Support for arguments with multiple values: e.g. -i 2 3 5 - Support for non-const argument linst in main. + - Added ability to use user-defined types of argument options. 2011-05-27 John Schneiderman 1.2.1 - Fixed issue with unit test failing because tabs were converted to spaces. - Fixed warnings when using QCoreApplication prior to creation. diff -r 7ef0a8f6b376 -r d051e4094072 src/qargs.cpp --- a/src/qargs.cpp Sat Jun 14 15:10:10 2014 +0000 +++ b/src/qargs.cpp Sat Jun 14 15:26:18 2014 +0000 @@ -373,7 +373,8 @@ return value; } -qreal QArgs::value(const QChar& shortName, qreal defaultValue) const +template<> +QTARGS_SHARED_EXPORT qreal QArgs::value(const QChar& shortName, qreal defaultValue) const { qreal value(defaultValue); int shortIndex(shortNameIndex(shortName)); @@ -399,7 +400,8 @@ return value; } -qint8 QArgs::value(const QChar& shortName, qint8 defaultValue) const +template<> +QTARGS_SHARED_EXPORT qint8 QArgs::value(const QChar& shortName, qint8 defaultValue) const { qint8 value(defaultValue); int shortIndex(shortNameIndex(shortName)); @@ -425,7 +427,8 @@ return value; } -qint16 QArgs::value(const QChar& shortName, qint16 defaultValue) const +template<> +QTARGS_SHARED_EXPORT qint16 QArgs::value(const QChar& shortName, qint16 defaultValue) const { qint16 value(defaultValue); int shortIndex(shortNameIndex(shortName)); @@ -451,7 +454,8 @@ return value; } -qint32 QArgs::value(const QChar& shortName, qint32 defaultValue) const +template<> +QTARGS_SHARED_EXPORT qint32 QArgs::value(const QChar& shortName, qint32 defaultValue) const { qint32 value(defaultValue); int shortIndex(shortNameIndex(shortName)); @@ -477,7 +481,8 @@ return value; } -qint64 QArgs::value(const QChar& shortName, qint64 defaultValue) const +template<> +QTARGS_SHARED_EXPORT qint64 QArgs::value(const QChar& shortName, qint64 defaultValue) const { qint64 value(defaultValue); int shortIndex(shortNameIndex(shortName)); @@ -503,7 +508,8 @@ return value; } -quint8 QArgs::value(const QChar& shortName, quint8 defaultValue) const +template<> +QTARGS_SHARED_EXPORT quint8 QArgs::value(const QChar& shortName, quint8 defaultValue) const { quint8 value(defaultValue); int shortIndex(shortNameIndex(shortName)); @@ -529,7 +535,8 @@ return value; } -quint16 QArgs::value(const QChar& shortName, quint16 defaultValue) const +template<> +QTARGS_SHARED_EXPORT quint16 QArgs::value(const QChar& shortName, quint16 defaultValue) const { quint16 value(defaultValue); int shortIndex(shortNameIndex(shortName)); @@ -555,7 +562,8 @@ return value; } -quint32 QArgs::value(const QChar& shortName, quint32 defaultValue) const +template<> +QTARGS_SHARED_EXPORT quint32 QArgs::value(const QChar& shortName, quint32 defaultValue) const { quint32 value(defaultValue); int shortIndex(shortNameIndex(shortName)); @@ -581,7 +589,8 @@ return value; } -quint64 QArgs::value(const QChar& shortName, quint64 defaultValue) const +template<> +QTARGS_SHARED_EXPORT quint64 QArgs::value(const QChar& shortName, quint64 defaultValue) const { quint64 value(defaultValue); int shortIndex(shortNameIndex(shortName)); diff -r 7ef0a8f6b376 -r d051e4094072 src/qargs.h --- a/src/qargs.h Sat Jun 14 15:10:10 2014 +0000 +++ b/src/qargs.h Sat Jun 14 15:26:18 2014 +0000 @@ -452,8 +452,8 @@ bool value(const QChar& shortName, bool defaultValue, BooleanSupport types = TRUE_OR_FALSE) const; /** - * @brief Option Double Precision Value - * @details Provides access to the value from a short or long named argument + * @brief Argument Option Value + * @details Provides access to a value from a short or long named argument * supplied by the user from the command-line. Once the value for the * option is determined the signal for the argument value is fired. In * addition, all argument values provided by the user are verified for both @@ -467,143 +467,8 @@ * name or long name option and is a valid single or double precision * number, else the default value is provided. */ - qreal value(const QChar& shortName, qreal defaultValue) const; - /** - * @brief Option Signed 8-bit Value - * @details Provides access to the value from a short or long named argument - * supplied by the user from the command-line. Once the value for the - * option is determined the signal for the argument value is fired. In - * addition, all argument values provided by the user are verified for both - * being valid and required. - * - * @param[in] shortName The short-name of the argument option. - * @param[in] defaultValue The value to use when an argument is not - * supplied by the user from the command-line. - * - * @return Any value supplied from the command-line which matches the short - * name or long name option and is a valid signed 8-bit integer number, - * else the default value is provided. - */ - qint8 value(const QChar& shortName, qint8 defaultValue) const; - /** - * @brief Option Signed 16-bit Value - * @details Provides access to the value from a short or long named argument - * supplied by the user from the command-line. Once the value for the - * option is determined the signal for the argument value is fired. In - * addition, all argument values provided by the user are verified for both - * being valid and required. - * - * @param[in] shortName The short-name of the argument option. - * @param[in] defaultValue The value to use when an argument is not - * supplied by the user from the command-line. - * - * @return Any value supplied from the command-line which matches the short - * name or long name option and is a valid signed 16-bit integer number, - * else the default value is provided. - */ - qint16 value(const QChar& shortName, qint16 defaultValue) const; - /** - * @brief Option Signed 32-bit Value - * @details Provides access to the value from a short or long named argument - * supplied by the user from the command-line. Once the value for the - * option is determined the signal for the argument value is fired. In - * addition, all argument values provided by the user are verified for both - * being valid and required. - * - * @param[in] shortName The short-name of the argument option. - * @param[in] defaultValue The value to use when an argument is not - * supplied by the user from the command-line. - * - * @return Any value supplied from the command-line which matches the short - * name or long name option and is a valid signed 32-bit integer number, - * else the default value is provided. - */ - qint32 value(const QChar& shortName, qint32 defaultValue) const; - /** - * @brief Option Signed 64-bit Value - * @details Provides access to the value from a short or long named argument - * supplied by the user from the command-line. Once the value for the - * option is determined the signal for the argument value is fired. In - * addition, all argument values provided by the user are verified for both - * being valid and required. - * - * @param[in] shortName The short-name of the argument option. - * @param[in] defaultValue The value to use when an argument is not - * supplied by the user from the command-line. - * - * @return Any value supplied from the command-line which matches the short - * name or long name option and is a valid signed 64-bit integer number, - * else the default value is provided. - */ - qint64 value(const QChar& shortName, qint64 defaultValue) const; - /** - * @brief Option Unsigned 8-bit Value - * @details Provides access to the value from a short or long named argument - * supplied by the user from the command-line. Once the value for the - * option is determined the signal for the argument value is fired. In - * addition, all argument values provided by the user are verified for both - * being valid and required. - * - * @param[in] shortName The short-name of the argument option. - * @param[in] defaultValue The value to use when an argument is not - * supplied by the user from the command-line. - * - * @return Any value supplied from the command-line which matches the short - * name or long name option and is a valid unsigned 8-bit integer number, - * else the default value is provided. - */ - quint8 value(const QChar& shortName, quint8 defaultValue) const; - /** - * @brief Option Unsigned 16-bit Value - * @details Provides access to the value from a short or long named argument - * supplied by the user from the command-line. Once the value for the - * option is determined the signal for the argument value is fired. In - * addition, all argument values provided by the user are verified for both - * being valid and required. - * - * @param[in] shortName The short-name of the argument option. - * @param[in] defaultValue The value to use when an argument is not - * supplied by the user from the command-line. - * - * @return Any value supplied from the command-line which matches the short - * name or long name option and is a valid unsigned 16-bit integer number, - * else the default value is provided. - */ - quint16 value(const QChar& shortName, quint16 defaultValue) const; - /** - * @brief Option Unsigned 32-bit Value - * @details Provides access to the value from a short or long named argument - * supplied by the user from the command-line. Once the value for the - * option is determined the signal for the argument value is fired. In - * addition, all argument values provided by the user are verified for both - * being valid and required. - * - * @param[in] shortName The short-name of the argument option. - * @param[in] defaultValue The value to use when an argument is not - * supplied by the user from the command-line. - * - * @return Any value supplied from the command-line which matches the short - * name or long name option and is a valid unsigned 32-bit integer number, - * else the default value is provided. - */ - quint32 value(const QChar& shortName, quint32 defaultValue) const; - /** - * @brief Option Unsigned 64-bit Value - * @details Provides access to the value from a short or long named argument - * supplied by the user from the command-line. Once the value for the - * option is determined the signal for the argument value is fired. In - * addition, all argument values provided by the user are verified for both - * being valid and required. - * - * @param[in] shortName The short-name of the argument option. - * @param[in] defaultValue The value to use when an argument is not - * supplied by the user from the command-line. - * - * @return Any value supplied from the command-line which matches the short - * name or long name option and is a valid unsigned 64-bit integer number, - * else the default value is provided. - */ - quint64 value(const QChar& shortName, quint64 defaultValue) const; + template + Expected value(const QChar& shortName, Expected defaultValue) const; /** * @brief Argument Option Character Value * @details Provides access to the value from a short or long named argument