From ed84d90d897ab4b91fa43f2e23d6a5b67e8bf241 Mon Sep 17 00:00:00 2001 From: Yoshihiro Hokazono Date: Wed, 22 Jun 2022 09:30:36 +0900 Subject: [PATCH] Move NArgsRange to private: because it is detail of implementation --- include/argparse/argparse.hpp | 67 ++++++++++++++++------------------- 1 file changed, 31 insertions(+), 36 deletions(-) diff --git a/include/argparse/argparse.hpp b/include/argparse/argparse.hpp index b65b540..c9a256e 100644 --- a/include/argparse/argparse.hpp +++ b/include/argparse/argparse.hpp @@ -328,37 +328,6 @@ template struct parse_number { } // namespace details -class NArgsRange { - std::size_t m_min; - std::size_t m_max; - -public: - NArgsRange(std::size_t minimum, std::size_t maximum) : m_min(minimum), m_max(maximum) { - if (minimum > maximum) - throw std::logic_error("Range of number of arguments is invalid"); - } - - bool contains(std::size_t value) const { - return value >= m_min && value <= m_max; - } - - bool is_exact() const { - return m_min == m_max; - } - - bool is_right_bounded() const { - return m_max < std::numeric_limits::max(); - } - - std::size_t get_min() const { - return m_min; - } - - std::size_t get_max() const { - return m_max; - } -}; - enum class nargs_pattern { optional, any, @@ -500,11 +469,6 @@ public: return *this; } - Argument &nargs(NArgsRange num_args_range) { - m_num_args_range = num_args_range; - return *this; - } - Argument &nargs(nargs_pattern pattern) { switch (pattern) { case nargs_pattern::optional: @@ -650,6 +614,37 @@ public: private: + class NArgsRange { + std::size_t m_min; + std::size_t m_max; + + public: + NArgsRange(std::size_t minimum, std::size_t maximum) : m_min(minimum), m_max(maximum) { + if (minimum > maximum) + throw std::logic_error("Range of number of arguments is invalid"); + } + + bool contains(std::size_t value) const { + return value >= m_min && value <= m_max; + } + + bool is_exact() const { + return m_min == m_max; + } + + bool is_right_bounded() const { + return m_max < std::numeric_limits::max(); + } + + std::size_t get_min() const { + return m_min; + } + + std::size_t get_max() const { + return m_max; + } + }; + void throw_nargs_range_validation_error() const { std::stringstream stream; if (!m_used_name.empty())