mirror of
https://github.com/KeqingMoe/argparse.git
synced 2025-07-04 07:04:39 +00:00
Move NArgsRange to private: because it is detail of implementation
This commit is contained in:
parent
25d24c731b
commit
ed84d90d89
@ -328,37 +328,6 @@ template <class T> struct parse_number<T, chars_format::fixed> {
|
||||
|
||||
} // 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<std::size_t>::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<std::size_t>::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())
|
||||
|
Loading…
Reference in New Issue
Block a user