From f9e4c74aff06a028663808de11ea2bc3bb6303ce Mon Sep 17 00:00:00 2001 From: Martchus Date: Mon, 6 Nov 2017 19:50:46 +0100 Subject: [PATCH] argument parser: Expose occurrence info directly Primarily for testing porposes, see documentation. --- CMakeLists.txt | 2 +- application/argumentparser.h | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e97db1f..4ba766d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -128,7 +128,7 @@ set(META_APP_AUTHOR "Martchus") set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}") set(META_APP_DESCRIPTION "Useful C++ classes and routines such as argument parser, IO and conversion utilities") set(META_VERSION_MAJOR 4) -set(META_VERSION_MINOR 11) +set(META_VERSION_MINOR 12) set(META_VERSION_PATCH 0) # find required 3rd party libraries diff --git a/application/argumentparser.h b/application/argumentparser.h index 4ae8073..a1bf9e0 100644 --- a/application/argumentparser.h +++ b/application/argumentparser.h @@ -210,6 +210,8 @@ public: Argument *specifiedOperation() const; void reset(); void resetRecursively(); + const std::vector &occurrenceInfo() const; + std::vector &occurrenceInfo(); /*! * \brief Denotes a variable number of values. @@ -758,6 +760,26 @@ inline void Argument::reset() m_occurrences.clear(); } +/*! + * \brief Returns information about all occurrences of the argument which have been detected when parsing. + * \remarks The convenience methods isPresent(), values() and path() provide direct access to these information for a particular occurrence. + */ +inline const std::vector &Argument::occurrenceInfo() const +{ + return m_occurrences; +} + +/*! + * \brief Returns information about all occurrences of the argument which have been detected when parsing. + * \remarks + * This information is meant to be set by the ArgumentParser. Modifying it directly is likely not a good idea. This method has been + * added primarily for testing purposes. In this case it might make sense to skip the actual parsing and just provide some dummy values. + */ +inline std::vector &Argument::occurrenceInfo() +{ + return m_occurrences; +} + /*! * \brief Returns the main arguments. * \sa setMainArguments()