Go to the documentation of this file. 1 #ifndef EAGINE_PROGRAM_ARGS_HPP
9 #define EAGINE_PROGRAM_ARGS_HPP
26 #include <type_traits>
60 _description = help_str;
97 , _value{std::move(initial)} {}
100 auto ref() noexcept -> T& {
107 return _is_valid(_value);
110 auto log_invalid_value(std::ostream& log)
const ->
auto& {
111 log <<
"Invalid value of parameter " <<
long_tag() <<
": ";
112 _log_invalid(_value, log);
119 log_invalid_value(log) << std::endl;
127 return _get_value(_value);
132 operator const T&()
const noexcept {
139 template <
typename X>
140 static auto _is_valid(
const X&) noexcept ->
bool {
144 template <
typename X,
typename P,
typename L>
145 static auto _is_valid(
const valid_if<X, P, L>& vi) noexcept ->
bool {
146 return vi.is_valid();
149 template <
typename X>
150 static void _log_invalid(
const X&,
const std::ostream&) noexcept {}
152 template <
typename X,
typename P,
typename L>
154 _log_invalid(
const valid_if<X, P, L>& vi, std::ostream& log) noexcept {
158 template <
typename X>
159 static auto _get_value(X& val) noexcept -> X& {
163 template <
typename X>
164 static auto _get_value(
const X& val) noexcept ->
const X& {
168 template <
typename X,
typename P,
typename L>
169 static auto _get_value(valid_if<X, P, L>& vi) -> X& {
173 template <
typename X,
typename P,
typename L>
174 static auto _get_value(
const valid_if<X, P, L>& vi) ->
const X& {
193 void increment() noexcept {
201 auto log_invalid_value(std::ostream& log)
const noexcept -> std::ostream& {
205 auto validate(std::ostream&)
const noexcept ->
bool {
217 using program_option = program_parameter<void>;
222 template <
typename T>
240 auto ref() noexcept -> auto& {
241 return _aliased.ref();
245 auto value() const noexcept -> auto& {
246 return _aliased.value();
251 operator const T&()
const noexcept {
252 return static_cast<const T&
>(_aliased);
259 class program_arg_iterator;
270 program_arg(
int argi,
int argc,
const char** argv) noexcept
280 return (0 < _argi) && (_argi < _argc) && (_argv !=
nullptr) &&
281 (_argv[_argi] !=
nullptr);
286 operator bool() const noexcept {
302 return _argi == _argc - 1;
320 return get().to_string();
343 return are_equal(
get(), tag);
348 return are_equal(
get(), short_tag) || are_equal(
get(), long_tag);
364 return {_argi + 1, _argc, _argv};
370 return {_argi - 1, _argc, _argv};
375 template <
typename T,
identifier_t V>
380 if(_do_parse(temp, sel, parse_log)) {
381 dest = std::move(temp);
390 template <
typename T>
391 auto parse(T& dest, std::ostream& parse_log)
const {
397 template <
typename T,
identifier_t V>
399 return next().parse(dest, sel, parse_log);
404 template <
typename T>
409 auto missing_handler(std::ostream& errorlog) {
411 errorlog <<
"Missing value after '" << arg_tag <<
"'." << std::endl;
415 auto invalid_handler(std::ostream& errorlog) {
419 errorlog <<
"Invalid value '" << arg_val <<
"' after '" << arg_tag
420 <<
"'. " << log_str << std::endl;
424 template <
typename T,
typename MissingFunc,
typename Inval
idFunc>
425 auto do_consume_next(
427 MissingFunc handle_missing,
428 InvalidFunc handle_invalid) ->
bool {
430 std::stringstream parse_log;
439 handle_missing(
get());
446 template <
typename T>
448 auto if_missing = missing_handler(errorlog);
449 auto if_invalid = invalid_handler(errorlog);
450 return do_consume_next(dest, if_missing, if_invalid);
453 template <
typename T,
typename MissingFunc,
typename Inval
idFunc>
456 MissingFunc handle_missing,
457 InvalidFunc handle_invalid) ->
bool {
459 return do_consume_next(param.ref(), handle_missing, handle_invalid);
464 template <
typename MissingFunc,
typename Inval
idFunc>
466 program_parameter<void>& param,
468 const InvalidFunc&) {
478 template <
typename T>
481 auto if_missing{missing_handler(errorlog)};
482 auto if_invalid{invalid_handler(errorlog)};
483 return do_parse_param(param, if_missing, if_invalid);
486 template <
typename T,
typename MissingFunc,
typename Inval
idFunc>
487 auto do_consume_next(
489 span<const T> choices,
490 MissingFunc handle_missing,
491 InvalidFunc handle_invalid) {
493 if(do_consume_next(temp, handle_missing, handle_invalid)) {
500 template <
typename T,
typename P,
typename L,
class MissingFunc,
class Inval
idFunc>
501 auto do_consume_next(
502 valid_if<T, P, L>& dest,
503 span<const T> choices,
504 MissingFunc handle_missing,
505 InvalidFunc handle_invalid) {
507 if(do_consume_next(temp, choices, handle_missing, handle_invalid)) {
508 if(dest.is_valid(temp)) {
509 dest = std::move(temp);
516 template <
typename T,
typename C>
517 auto consume_next(T& dest, span<const C> choices, std::ostream& errorlog)
519 auto if_missing{missing_handler(errorlog)};
520 auto if_invalid{invalid_handler(errorlog)};
521 return do_consume_next(dest, choices, if_missing, if_invalid);
524 template <
typename T,
typename C,
class MissingFunc,
class Inval
idFunc>
526 program_parameter<T>& param,
527 span<const C> choices,
528 MissingFunc handle_missing,
529 InvalidFunc handle_invalid) {
531 return do_consume_next(
532 param.ref(), choices, handle_missing, handle_invalid);
537 template <
typename T,
typename C>
539 program_parameter<T>& param,
540 span<const C> choices,
541 std::ostream& errorlog) ->
bool {
542 auto if_missing{missing_handler(errorlog)};
543 auto if_invalid{invalid_handler(errorlog)};
544 return do_parse_param(param, choices, if_missing, if_invalid);
547 template <
typename T,
typename MissingFunc,
typename Inval
idFunc>
548 auto do_consume_next(
550 span<const string_view> symbols,
551 span<const T> translations,
552 MissingFunc handle_missing,
553 InvalidFunc handle_invalid) {
554 EAGINE_ASSERT(symbols.size() <= translations.size());
557 if(do_consume_next(parsed, symbols, handle_missing, handle_invalid)) {
559 if(are_equal(parsed, symbols[i])) {
560 dest = translations[i];
568 template <
typename T,
typename P,
typename L,
class MissingFunc,
class Inval
idFunc>
569 auto do_consume_next(
570 valid_if<T, P, L>& dest,
571 span<const string_view> symbols,
572 span<const T> translations,
573 MissingFunc handle_missing,
574 InvalidFunc handle_invalid) {
577 temp, symbols, translations, handle_missing, handle_invalid)) {
578 if(dest.is_valid(temp)) {
579 dest = std::move(temp);
588 template <
typename T,
typename R>
591 span<const string_view> symbols,
592 span<const R> translations,
593 std::ostream& errorlog) ->
bool {
594 auto if_missing{missing_handler(errorlog)};
595 auto if_invalid{invalid_handler(errorlog)};
596 return do_consume_next(
597 dest, symbols, translations, if_missing, if_invalid);
600 template <
typename T,
typename R,
class MissingFunc,
class Inval
idFunc>
603 span<const string_view> symbols,
604 span<const R> translations,
605 MissingFunc handle_missing,
606 InvalidFunc handle_invalid) {
608 return do_consume_next(
618 template <
typename T,
typename R>
620 program_parameter<T>& param,
621 span<const string_view> symbols,
622 span<const R> translations,
623 std::ostream& errorlog) ->
bool {
624 auto if_missing{missing_handler(errorlog)};
625 auto if_invalid{invalid_handler(errorlog)};
626 return do_parse_param(
627 param, symbols, translations, if_missing, if_invalid);
630 template <
typename T,
typename R,
class MissingFunc,
class Inval
idFunc>
632 program_parameter_alias<T>& param,
633 span<const string_view> symbols,
634 span<const R> translations,
635 MissingFunc handle_missing,
636 InvalidFunc handle_invalid) {
638 return do_consume_next(
648 template <
typename T,
typename R>
650 program_parameter_alias<T>& param,
651 span<const string_view> symbols,
652 span<const R> translations,
653 std::ostream& errorlog) ->
bool {
654 auto if_missing{missing_handler(errorlog)};
655 auto if_invalid{invalid_handler(errorlog)};
656 return do_parse_param(
657 param, symbols, translations, if_missing, if_invalid);
662 return are_equal(
get(), v);
667 return are_equal(
get(), v);
673 const char** _argv{
nullptr};
675 friend class program_arg_iterator;
676 friend class program_args;
678 template <
typename T,
identifier_t V>
679 auto _do_parse(T& dest, selector<V> sel,
const std::ostream&)
const noexcept
681 if(
auto opt_val{from_string<T>(
get(), sel)}) {
682 dest = std::move(
extract(opt_val));
688 template <
identifier_t V>
689 auto _do_parse(
string_view& dest, selector<V>,
const std::ostream&)
690 const noexcept ->
bool {
695 template <
identifier_t V>
696 auto _do_parse(std::string& dest, selector<V>,
const std::ostream&)
const
702 template <
typename T,
typename P,
typename L,
identifier_t V>
704 valid_if<T, P, L>& dest,
706 std::ostream& parse_log)
const ->
bool {
708 if(
parse(value, sel, parse_log)) {
709 if(dest.is_valid(value)) {
710 dest = std::move(value);
713 dest.log_invalid(parse_log, value);
716 parse_log <<
"'" <<
get() <<
"' "
717 <<
"is not a valid `" << type_name<T>() <<
"` value";
722 template <
typename T,
typename A,
identifier_t V>
724 std::vector<T, A>& dest,
726 std::ostream& parse_log)
const ->
bool {
728 if(
parse(value, sel, parse_log)) {
729 dest.push_back(std::move(value));
736 static inline auto extract(
const program_arg& arg) noexcept {
740 static inline auto to_string(
const program_arg& arg) {
741 return arg.get_string();
744 static inline auto operator<<(std::ostream& out,
const program_arg& arg)
746 return out << arg.get();
780 return _cmp(l._a, r._a) == 0;
785 return _cmp(l._a, r._a) != 0;
790 return _cmp(l._a, r._a) < 0;
795 return _cmp(l._a, r._a) <= 0;
800 return _cmp(l._a, r._a) > 0;
805 return _cmp(l._a, r._a) >= 0;
811 return _cmp(l._a, r._a);
855 result._a._argi += dist;
862 result._a._argi -= dist;
879 EAGINE_ASSERT(l._argv == r._argv);
880 return l._argi - r._argi;
886 class program_parameters {
888 struct _intf : interface<_intf> {
889 virtual auto parse(program_arg&, std::ostream&) ->
bool = 0;
891 virtual auto has_valid_value() const ->
bool = 0;
892 virtual auto validate(std::ostream&) const ->
bool = 0;
896 virtual auto description() const ->
string_view = 0;
897 virtual auto placeholder() const ->
string_view = 0;
900 template <typename T>
901 struct _impl : _intf {
902 program_parameter<T>* _pparam;
905 auto _param() noexcept -> auto& {
906 EAGINE_ASSERT(_pparam !=
nullptr);
910 auto _param() const noexcept -> auto& {
911 EAGINE_ASSERT(_pparam !=
nullptr);
915 template <
typename X>
916 static auto _plchldr_name(type_identity<X>) noexcept ->
string_view {
917 if(std::is_same_v<X, bool>) {
920 if(std::is_same_v<X, string_view>) {
923 if(std::is_integral_v<X>) {
926 if(std::is_floating_point_v<X>) {
933 template <
typename X,
typename P,
typename L>
934 static auto _plchldr_name(type_identity<valid_if<X, P, L>>) noexcept {
935 return _plchldr_name(type_identity<X>());
938 template <
typename X,
typename A>
939 static auto _plchldr_name(type_identity<std::vector<X, A>>) noexcept {
940 return _plchldr_name(type_identity<X>());
943 _impl(program_parameter<T>& param) noexcept
945 , _plchldr{_plchldr_name(type_identity<T>())} {}
947 auto parse(program_arg& arg, std::ostream& log) ->
bool override {
948 return arg.parse_param(_param(), log);
951 auto has_valid_value() const ->
bool override {
952 return _param().has_valid_value();
955 auto validate(std::ostream& log)
const ->
bool override {
956 return _param().validate(log);
960 return _param().short_tag();
964 return _param().long_tag();
968 return _param().description();
976 std::vector<std::unique_ptr<_intf>> _params;
978 static auto _insert(std::vector<std::unique_ptr<_intf>>& dest) noexcept
983 template <
typename... Intf>
985 std::vector<std::unique_ptr<_intf>>& dest,
986 std::unique_ptr<_intf>&& param,
987 std::unique_ptr<Intf>&&... params) noexcept ->
auto& {
988 EAGINE_ASSERT(param !=
nullptr);
989 dest.push_back(std::move(param));
990 return _insert(dest, std::move(params)...);
993 template <
typename... Intf>
994 static auto _make(std::unique_ptr<Intf>&&... params) {
995 std::vector<std::unique_ptr<_intf>> result;
996 result.reserve(
sizeof...(params));
997 return std::move(_insert(result, std::move(params)...));
1001 template <
typename... T>
1002 program_parameters(program_parameter<T>&... params)
1003 : _params(_make(std::unique_ptr<_intf>(new _impl<T>(params))...)) {}
1009 auto parse(program_arg& arg, std::ostream& log) ->
bool {
1010 for(
auto& param : _params) {
1011 EAGINE_ASSERT(param !=
nullptr);
1012 if(param->parse(arg, log)) {
1019 auto validate(std::ostream& log)
const ->
bool {
1021 for(
const auto& param : _params) {
1022 EAGINE_ASSERT(param !=
nullptr);
1023 all_ok &= param->validate(log);
1028 auto print_usage(std::ostream& out,
string_view command) -> std::ostream& {
1029 out <<
"Usage: " << command;
1034 for(
const auto& param : _params) {
1035 EAGINE_ASSERT(param !=
nullptr);
1039 bool mandatory = !param->has_valid_value();
1041 out << (mandatory ?
'<' :
'[');
1043 out << param->short_tag() <<
"|" << param->long_tag();
1044 out <<
" " << param->placeholder();
1046 out << (mandatory ?
'>' :
']');
1048 if(stag_maxl < param->short_tag().size()) {
1049 stag_maxl = param->short_tag().size();
1052 if(ltag_maxl < param->long_tag().size()) {
1053 ltag_maxl = param->long_tag().size();
1057 out <<
" Options:" << std::endl;
1061 for(
const auto& param : _params) {
1062 padl = 4 + stag_maxl - param->short_tag().size();
1066 out << param->short_tag() <<
"|";
1068 out << param->long_tag();
1069 padl = ltag_maxl - param->long_tag().size();
1073 out <<
": " << param->description() << std::endl;
1091 , _argv(
const_cast<const char**
>(args)) {}
1111 auto argc() const noexcept ->
int {
1116 auto argv() const noexcept -> const
char** {
1126 auto none() const noexcept ->
bool {
1131 auto size() const noexcept ->
int {
1137 return pos.is_valid(*
this) && (_argv !=
nullptr) &&
1138 (_argv[pos.value_or(-1, *
this)] !=
nullptr);
1144 EAGINE_ASSERT(is_valid(pos));
1145 return value_type(_argv[pos.value_anyway(*
this)]);
1178 if((_argv !=
nullptr) && (_argv[i] !=
nullptr)) {
1185 return {i, _argc, _argv};
1189 template <
typename T>
1193 if(a.parse_param(param, errlog)) {
1202 const char** _argv{
nullptr};
1207 #endif // EAGINE_PROGRAM_ARGS_HPP
value_type
Value tree value element data type enumeration.
Definition: interface.hpp:27
auto operator+(difference_type dist) noexcept -> this_class
Difference addition.
Definition: program_args.hpp:853
auto ends_with(string_view str) const noexcept
Indicates if this argument value ends with the specified string.
Definition: program_args.hpp:337
std::ptrdiff_t span_size_t
Signed span size type used by eagine.
Definition: types.hpp:36
static constexpr auto ends_with(basic_span< T1, P1, S1 > spn, basic_span< T2, P2, S2 > with) -> bool
Indicates if span spn ends with the content of with.
Definition: span_algo.hpp:187
basic_string_span< const char > string_view
Alias for const string views.
Definition: string_span.hpp:116
static constexpr auto as_bytes(basic_span< T, P, S > spn) noexcept -> basic_block< std::is_const_v< T >>
Converts a span into a basic_block.
Definition: block.hpp:39
static constexpr auto span_size(T v) noexcept
Converts argument to span size type.
Definition: types.hpp:59
auto is_tag(string_view tag) const noexcept
Indicates if this argument value is equal to the specified string.
Definition: program_args.hpp:342
auto is_help_arg() const noexcept
Indicates if this argument is a "show help" argument (like "--help").
Definition: program_args.hpp:357
auto consume_next(T &dest, span< const string_view > symbols, span< const R > translations, std::ostream &errorlog) -> bool
Tries to parse values into starting from the following argument.
Definition: program_args.hpp:589
Class template for pre-declared program parameter.
Definition: program_args.hpp:85
program_parameter(string_view short_tag, string_view long_tag, T initial) noexcept
Construction from short and long tag strings and the initial value.
Definition: program_args.hpp:92
auto operator[](const valid_index &pos) const noexcept -> value_type
Returns the command line argument value at the specified position.
Definition: program_args.hpp:1150
auto ref() noexcept -> auto &
Returns a reference to the value in the aliased program parameter.
Definition: program_args.hpp:240
Common code is placed in this namespace.
Definition: eagine.hpp:21
auto first() const noexcept -> program_arg
Returns first argument.
Definition: program_args.hpp:1160
program_args(span_size_t argn, char **args) noexcept
Construction from the length and pointer to the argument list.
Definition: program_args.hpp:1089
auto ref() noexcept -> T &
Returns a reference to the parameter value.
Definition: program_args.hpp:100
static constexpr auto extract(api_result_value< Result, api_result_validity::never > &) noexcept -> Result &
Overload of extract for api_result_value.
Definition: c_api_wrap.hpp:270
auto is_tag(string_view short_tag, string_view long_tag) const noexcept
Indicates if this argument value is one of the two specified strings.
Definition: program_args.hpp:347
basic_block< true > const_block
Alias for const byte memory span.
Definition: block.hpp:32
Primary template for conditionally valid values.
Definition: decl.hpp:49
auto empty() const noexcept -> bool
Indicates if the argument list is completely empty.
Definition: program_args.hpp:1121
auto argc() const noexcept -> int
Returns the number of arguments.
Definition: program_args.hpp:1111
auto block() const noexcept -> memory::const_block
Returns the value of this argument as a const memory block.
Definition: program_args.hpp:314
auto position() const noexcept
Returns the index of this argument.
Definition: program_args.hpp:291
auto find(string_view what) const noexcept -> program_arg
Finds and returns the argument with the specified value.
Definition: program_args.hpp:1175
auto begin() const noexcept -> iterator
Returns an iterator to the first argument (not the command name).
Definition: program_args.hpp:1165
auto parse(T &dest, selector< V > sel, std::ostream &parse_log) const -> bool
Tries to parse this argument's value into dest.
Definition: program_args.hpp:376
program_parameter_alias(string_view short_tag, string_view long_tag, program_parameter< T > &that) noexcept
Construction from alternative short and long tags and parameter reference.
Definition: program_args.hpp:232
auto get(const valid_index &pos) const noexcept -> value_type
Returns the command line argument value at the specified position.
Definition: program_args.hpp:1143
auto parse_param(program_parameter< T > ¶m, std::ostream &errlog) const -> bool
Parses the specified parameter, using errlog for error output.
Definition: program_args.hpp:1190
friend auto operator!=(const this_class &l, const this_class &r) noexcept
Nonequality comparison.
Definition: program_args.hpp:784
auto validate(std::ostream &log) const -> bool
Validate the current value, print potential error messages to log.
Definition: program_args.hpp:117
Alias (alternative tags) for another declared program parameter.
Definition: program_args.hpp:223
Template used to construct tag-types used mostly in tag-dispatching.
Definition: selector.hpp:21
auto operator*() noexcept -> reference
Dereference operator.
Definition: program_args.hpp:867
auto operator==(const value_type &v) const noexcept
Indicates if this argument's value is equal to the specified string.
Definition: program_args.hpp:661
int size_type
Alias for the element count type.
Definition: program_args.hpp:1102
constexpr auto description(string_view help_str) noexcept -> auto &
Specifies a human-readable description for this program parameter.
Definition: program_args.hpp:59
program_parameter(string_view short_tag, string_view long_tag) noexcept
Construction from short and long tag strings.
Definition: program_args.hpp:88
auto parse_next(T &dest, selector< V > sel, std::ostream &parse_log) const
Tries to parse the following argument's value into dest.
Definition: program_args.hpp:398
Class representing a single main function (command-line) argument.
Definition: program_args.hpp:265
auto operator++(int) noexcept -> this_class
Post-increment operator.
Definition: program_args.hpp:827
auto parse(T &dest, std::ostream &parse_log) const
Tries to parse this argument's value into dest.
Definition: program_args.hpp:391
auto value() const -> auto &
Returns the current parameter value.
Definition: program_args.hpp:126
std::random_access_iterator_tag iterator_category
Alias for iterator category.
Definition: program_args.hpp:776
auto get() const noexcept -> value_type
Returns the value of this argument if valid, an empty string view otherwise.
Definition: program_args.hpp:306
auto operator--(int) noexcept -> this_class
Post-decrement operator.
Definition: program_args.hpp:834
program_parameter(string_view short_tag, string_view long_tag) noexcept
Construction from the short and long tag strings.
Definition: program_args.hpp:190
auto parse_next(T &dest, std::ostream &parse_log) const
Tries to parse the following argument's value into dest.
Definition: program_args.hpp:405
friend auto operator>=(const this_class &l, const this_class &r) noexcept
Greater-equal comparison.
Definition: program_args.hpp:804
program_args(span_size_t argn, const char **args) noexcept
Construction from the length and const pointer to the argument list.
Definition: program_args.hpp:1094
auto operator++() noexcept -> this_class &
Pre-increment operator.
Definition: program_args.hpp:815
constexpr program_arg() noexcept=default
Default constructor.
auto operator*() const noexcept -> const_reference
Const dereference operator.
Definition: program_args.hpp:872
auto value() const noexcept -> auto &
Returns the value in the aliased program parameter.
Definition: program_args.hpp:245
friend auto operator==(const this_class &l, const this_class &r) noexcept
Equality comparison.
Definition: program_args.hpp:779
auto operator--() noexcept -> this_class &
Pre-decrement operator.
Definition: program_args.hpp:821
string_view value_type
Alias for the argument value type.
Definition: program_args.hpp:276
friend auto operator<(const this_class &l, const this_class &r) noexcept
Less-than comparison.
Definition: program_args.hpp:789
auto parse_param(program_parameter< T > ¶m, std::ostream &errorlog) -> bool
Tries to parse the specified parameter starting from this argument.
Definition: program_args.hpp:479
auto operator-=(difference_type dist) noexcept -> this_class &
Decrement operator.
Definition: program_args.hpp:847
Class wrapping the main function arguments, providing a convenient API.
Definition: program_args.hpp:1082
auto starts_with(string_view str) const noexcept
Indicates if this argument value starts with the specified string.
Definition: program_args.hpp:331
Base class for pre-declared program parameter.
Definition: program_args.hpp:41
int difference_type
Alias for difference type.
Definition: program_args.hpp:761
constexpr auto short_tag() const noexcept -> string_view
Get the short tag string for this parameter.
Definition: program_args.hpp:44
auto has_valid_value() const noexcept -> bool
Indicates if the current value is valid.
Definition: program_args.hpp:106
auto is_tag_param(const basic_program_parameter ¶m) const
Indicates if this argument value is equal to the one declared in param.
Definition: program_args.hpp:352
auto end() const noexcept -> iterator
Returns an iterator past the last argument.
Definition: program_args.hpp:1170
auto is_last() const noexcept -> bool
Indicates if this is the last command-line argument.
Definition: program_args.hpp:301
auto operator!=(const value_type &v) const noexcept
Indicates if this argument's value is different than the specified string.
Definition: program_args.hpp:666
friend auto operator<=(const this_class &l, const this_class &r) noexcept
Less-equal comparison.
Definition: program_args.hpp:794
friend auto operator-(const this_class &l, const this_class &r) noexcept -> difference_type
Difference.
Definition: program_args.hpp:809
auto consume_next(T &dest, std::ostream &errorlog) -> bool
Tries to parse the following argument's value into dest.
Definition: program_args.hpp:447
auto operator-(difference_type dist) noexcept -> this_class
Difference subtraction.
Definition: program_args.hpp:860
integer_range(B, E) -> integer_range< std::common_type_t< B, E >>
Deduction guide for integer_range.
auto is_valid(const valid_index &pos) const noexcept -> bool
Tests if the specified index references a command line argument.
Definition: program_args.hpp:1136
auto argv() const noexcept -> const char **
Returns a pointer to tha list of argument C-strings.
Definition: program_args.hpp:1116
auto none() const noexcept -> bool
Indicates if the argument list does not contain any arguments.
Definition: program_args.hpp:1126
auto command() const noexcept -> value_type
Returns the command name.
Definition: program_args.hpp:1155
static constexpr auto starts_with(basic_span< T1, P1, S1 > spn, basic_span< T2, P2, S2 > with) -> bool
Indicates if span spn starts with the content of with.
Definition: span_algo.hpp:170
auto next() const noexcept -> program_arg
Returns the argument following this one.
Definition: program_args.hpp:363
auto is_valid() const noexcept -> bool
Indicates if the arguments is valid.
Definition: program_args.hpp:279
constexpr auto long_tag() const noexcept -> string_view
Get the long tag string for this parameter.
Definition: program_args.hpp:49
auto is_first() const noexcept -> bool
Indicates if this is the first command-line argument.
Definition: program_args.hpp:296
friend auto operator>(const this_class &l, const this_class &r) noexcept
Greater-than comparison.
Definition: program_args.hpp:799
static auto operator<<(std::ostream &out, const identifier_name< M > &n) -> std::ostream &
Operator for writing identifier_name into output streams.
Definition: identifier.hpp:159
auto get_string() const -> std::string
Returns the value of this argument as a standard string.
Definition: program_args.hpp:319
constexpr auto description() const noexcept -> string_view
Returns a human-readable description for this program parameter.
Definition: program_args.hpp:54
auto prev() const noexcept -> program_arg
Returns the argument preceding this one.
Definition: program_args.hpp:369
Iterator type over program_arg instances.
Definition: program_args.hpp:750
Basic template for conditionally-valid values.
Definition: base.hpp:86
auto size() const noexcept -> int
Returns the count of arguments (counting in the command name)
Definition: program_args.hpp:1131
auto operator+=(difference_type dist) noexcept -> this_class &
Increment operator.
Definition: program_args.hpp:841