argument parser: Expose occurrence info directly

Primarily for testing porposes, see documentation.
This commit is contained in:
Martchus 2017-11-06 19:50:46 +01:00
parent cc09fdc35f
commit f9e4c74aff
2 changed files with 23 additions and 1 deletions

View File

@ -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

View File

@ -210,6 +210,8 @@ public:
Argument *specifiedOperation() const;
void reset();
void resetRecursively();
const std::vector<ArgumentOccurrence> &occurrenceInfo() const;
std::vector<ArgumentOccurrence> &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<ArgumentOccurrence> &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<ArgumentOccurrence> &Argument::occurrenceInfo()
{
return m_occurrences;
}
/*!
* \brief Returns the main arguments.
* \sa setMainArguments()