argument parser: Expose occurrence info directly

Primarily for testing porposes, see documentation.
experiment/srcref_basic_cfg
Martchus 5 years ago
parent cc09fdc35f
commit f9e4c74aff
  1. 2
      CMakeLists.txt
  2. 22
      application/argumentparser.h

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

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

Loading…
Cancel
Save