CPP-AP 2.2.6
Command-line argument parser for C++20
Loading...
Searching...
No Matches
ap::nargs::range Class Reference

Argument's number of values managing class. More...

#include <range.hpp>

Public Types

using count_type = std::size_t
 

Public Member Functions

 range ()
 Default constructor: creates range [1, 1].
 
 range (const count_type n)
 Exact count constructor: creates range [n, n].
 
 range (const count_type lower_bound, const count_type upper_bound)
 Concrete range constructor: creates range [lower_bound, upper_bound].
 
 range (const range &)=default
 
 range (range &&)=default
 
rangeoperator= (const range &)=default
 
rangeoperator= (range &&)=default
 
bool is_bound () const noexcept
 Returns true if at least one bound (lower, upper) is set. Otherwise returns false
 
std::weak_ordering ordering (const range::count_type n) const noexcept
 Determines the ordering of the count against a range instance.
 

Friends

std::ostream & operator<< (std::ostream &os, const range &r) noexcept
 
range at_least (const count_type) noexcept
 range class builder function. Creates a range [n, inf].
 
range more_than (const count_type) noexcept
 range class builder function. Creates a range [n + 1, inf].
 
range less_than (const count_type) noexcept
 range class builder function. Creates a range [0, n - 1].
 
range up_to (const count_type) noexcept
 range class builder function. Creates a range [0, n].
 
range any () noexcept
 range class builder function. Creates a range [0, inf].
 

Detailed Description

Argument's number of values managing class.

Definition at line 18 of file range.hpp.

Member Typedef Documentation

◆ count_type

using ap::nargs::range::count_type = std::size_t

Definition at line 20 of file range.hpp.

Constructor & Destructor Documentation

◆ range() [1/3]

ap::nargs::range::range ( )
inline

Default constructor: creates range [1, 1].

Definition at line 23 of file range.hpp.

◆ range() [2/3]

ap::nargs::range::range ( const count_type  n)
inlineexplicit

Exact count constructor: creates range [n, n].

Parameters
nExpected value count.

Definition at line 29 of file range.hpp.

◆ range() [3/3]

ap::nargs::range::range ( const count_type  lower_bound,
const count_type  upper_bound 
)
inline

Concrete range constructor: creates range [lower_bound, upper_bound].

Parameters
lower_boundThe lower bound.
upper_boundThe upper bound.

Definition at line 36 of file range.hpp.

Member Function Documentation

◆ is_bound()

bool ap::nargs::range::is_bound ( ) const
inlinenoexcept

Returns true if at least one bound (lower, upper) is set. Otherwise returns false

Definition at line 48 of file range.hpp.

◆ ordering()

std::weak_ordering ap::nargs::range::ordering ( const range::count_type  n) const
inlinenoexcept

Determines the ordering of the count against a range instance.

For a [lower, upper] range and the count n the returned value is:

  • less if n < lower,
  • equivalent if n >= lower and n <= upper,
  • greater if n > upper. If either lower or upper limits are not set (std::nullopt), then the corresponding conditions are dropped.
Parameters
nThe value count to order.
Returns
Ordering relationship between the count and the range.

Definition at line 65 of file range.hpp.

Friends And Related Symbol Documentation

◆ any

range any ( )
friend

range class builder function. Creates a range [0, inf].

Returns
Built range class instance.

Definition at line 170 of file range.hpp.

◆ at_least

range at_least ( const count_type  n)
friend

range class builder function. Creates a range [n, inf].

Parameters
nThe lower bound.
Returns
Built range class instance.

Definition at line 135 of file range.hpp.

◆ less_than

range less_than ( const count_type  n)
friend

range class builder function. Creates a range [0, n - 1].

Parameters
nThe upper bound
Returns
Built range class instance.

Definition at line 153 of file range.hpp.

◆ more_than

range more_than ( const count_type  n)
friend

range class builder function. Creates a range [n + 1, inf].

Parameters
nThe lower bound.
Returns
Built range class instance.

Definition at line 144 of file range.hpp.

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const range r 
)
friend

Definition at line 89 of file range.hpp.

◆ up_to

range up_to ( const count_type  n)
friend

range class builder function. Creates a range [0, n].

Parameters
nThe upper bound
Returns
Built range class instance.

Definition at line 162 of file range.hpp.


The documentation for this class was generated from the following file: