CPP-AP 2.2.6
Command-line argument parser for C++20
Loading...
Searching...
No Matches
predefined_actions.hpp File Reference
#include "ap/exceptions.hpp"
#include "detail/utility.hpp"
#include <filesystem>
#include <ostream>

Go to the source code of this file.

Functions

std::ostream & ap::operator<< (std::ostream &os, const argument_parser &) noexcept
 
ap::action_type::on_flag::type ap::action::print_config (const argument_parser &parser, const std::optional< int > exit_code=std::nullopt, std::ostream &os=std::cout) noexcept
 Returns an on-flag action which prints the argument parser's configuration.
 
detail::callable_type< ap::action_type::observe, std::string > ap::action::check_file_exists () noexcept
 Returns an observe action which checks whether lower_bound file with the given name exists.
 
template<ap::detail::c_arithmetic T>
detail::callable_type< ap::action_type::observe, T > ap::action::gt (const T lower_bound) noexcept
 Returns an observe action which checks if a parsed value is greater than the given bound.
 
template<ap::detail::c_arithmetic T>
detail::callable_type< ap::action_type::observe, T > ap::action::geq (const T lower_bound) noexcept
 Returns an observe action which checks if a parsed value is greater than or equal to the given bound.
 
template<ap::detail::c_arithmetic T>
detail::callable_type< ap::action_type::observe, T > ap::action::lt (const T upper_bound) noexcept
 Returns an observe action which checks if a parsed value is less than the given bound.
 
template<ap::detail::c_arithmetic T>
detail::callable_type< ap::action_type::observe, T > ap::action::leq (const T upper_bound) noexcept
 Returns an observe action which checks if a parsed value is less than or equal to the given bound.
 
template<ap::detail::c_arithmetic T, bool LeftInclusive = true, bool RightInclusive = true>
detail::callable_type< ap::action_type::observe, T > ap::action::within (const T lower_bound, const T upper_bound) noexcept
 Returns an observe action which checks if a parsed value falls within the specified interval.
 

Function Documentation

◆ check_file_exists()

detail::callable_type< ap::action_type::observe, std::string > ap::action::check_file_exists ( )
inlinenoexcept

Returns an observe action which checks whether lower_bound file with the given name exists.

Definition at line 41 of file predefined_actions.hpp.

◆ geq()

detail::callable_type< ap::action_type::observe, T > ap::action::geq ( const T  lower_bound)
noexcept

Returns an observe action which checks if a parsed value is greater than or equal to the given bound.

Template Parameters
TThe arithmetic value type.
Parameters
lower_boundThe inclusive lower bound to validate against.

Definition at line 73 of file predefined_actions.hpp.

◆ gt()

detail::callable_type< ap::action_type::observe, T > ap::action::gt ( const T  lower_bound)
noexcept

Returns an observe action which checks if a parsed value is greater than the given bound.

Template Parameters
TThe arithmetic value type.
Parameters
lower_boundThe exclusive lower bound to validate against.

Definition at line 58 of file predefined_actions.hpp.

◆ leq()

detail::callable_type< ap::action_type::observe, T > ap::action::leq ( const T  upper_bound)
noexcept

Returns an observe action which checks if a parsed value is less than or equal to the given bound.

Template Parameters
TThe arithmetic value type.
Parameters
lower_boundThe inclusive upper bound to validate against.

Definition at line 103 of file predefined_actions.hpp.

◆ lt()

detail::callable_type< ap::action_type::observe, T > ap::action::lt ( const T  upper_bound)
noexcept

Returns an observe action which checks if a parsed value is less than the given bound.

Template Parameters
TThe arithmetic value type.
Parameters
lower_boundThe exclusive upper bound to validate against.

Definition at line 88 of file predefined_actions.hpp.

◆ operator<<()

std::ostream & ap::operator<< ( std::ostream &  os,
const argument_parser  
)
noexcept

An os << parser operation is equivalent to a parser.print_config(_verbose, os) call, where _verbose is the inner verbosity mode, which can be set with the verbose function.

Parameters
osOutput stream.
parserThe argument parser to print.
Returns
The modified output stream.

Definition at line 468 of file argument_parser.hpp.

◆ print_config()

ap::action_type::on_flag::type ap::action::print_config ( const argument_parser parser,
const std::optional< int >  exit_code = std::nullopt,
std::ostream &  os = std::cout 
)
inlinenoexcept

Returns an on-flag action which prints the argument parser's configuration.

Parameters
parserThe argument parser the configuration of which will be printed.
exit_codeThe exit code with which std::exit will be called (if not std::nullopt).
osThe output stream to which the configuration will be printed.

Definition at line 28 of file predefined_actions.hpp.

◆ within()

template<ap::detail::c_arithmetic T, bool LeftInclusive = true, bool RightInclusive = true>
detail::callable_type< ap::action_type::observe, T > ap::action::within ( const T  lower_bound,
const T  upper_bound 
)
noexcept

Returns an observe action which checks if a parsed value falls within the specified interval.

The interval is defined by the given lower and upper bounds, with inclusivity controlled by the template parameters.

Template Parameters
TThe arithmetic value type.
LeftInclusiveWhether the lower bound is inclusive ([) or exclusive (() - default: true.
RightInclusiveWhether the upper bound is inclusive (]) or exclusive ()) - default: true.
Parameters
lower_boundThe lower bound of the interval.
upper_boundThe upper bound of the interval.

Definition at line 124 of file predefined_actions.hpp.