Wrapper checking argument iterator access for validityOutput ParseCommandInfo instance. More...
#include <senf/Utils/Console/Parse.hh>
Public Member Functions | |
CheckedArgumentIteratorWrapper (ParseCommandInfo::ArgumentsRange const &range, std::string const &msg="invalid number of arguments") | |
Make wrapper from ArgumentsRange. More... | |
CheckedArgumentIteratorWrapper (ParseCommandInfo::TokensRange const &range, std::string const &msg="invalid number of arguments") | |
Make wrapper from TokensRange. More... | |
~CheckedArgumentIteratorWrapper () noexcept(false) | |
Check, if all arguments are parsed. More... | |
operator ParseCommandInfo::ArgumentIterator () | |
Use wrapper as ParseCommandInfo::ArgumentIterator. More... | |
bool | boolean_test () const |
true , if more arguments are available More... | |
bool | done () const |
true , if all arguments are parsed More... | |
void | clear () |
Set range empty. More... | |
bool | operator== (ParseCommandInfo::ArgumentIterator const &other) const |
Compare wrapper against ArgumentIterator. More... | |
bool | operator!= (ParseCommandInfo::ArgumentIterator const &other) const |
Compare wrapper against ArgumentIterator. More... | |
ParseCommandInfo::ArgumentIterator | operator++ (int) |
Public Member Functions inherited from senf::comparable_safe_bool< class > | |
operator bool_type () const | |
bool | operator! () const |
Additional Inherited Members | |
Protected Types inherited from senf::safe_bool_base | |
typedef void(safe_bool_base::* | bool_type) () const |
Protected Member Functions inherited from senf::comparable_safe_bool< class > | |
~comparable_safe_bool () | |
Protected Member Functions inherited from senf::safe_bool_base | |
void | this_type_does_not_support_comparisons () const |
safe_bool_base () | |
safe_bool_base (const safe_bool_base &) | |
safe_bool_base & | operator= (const safe_bool_base &) |
~safe_bool_base () | |
Wrapper checking argument iterator access for validityOutput ParseCommandInfo instance.
CheckedArgumentIteratorWrapper is a wrapper around a range of arguments parsed using the ParseCommandInfo::ArgumentIterator. It is used to parse arguments either in a command (registered with manual argument parsing) or when defining a custom parser.
To use the wrapper, you must ensure that: \li You increment the iterator \e past all arguments you parse. The iterator must point to the end of the range when parsing is complete. \li The iterator wrapper is destroyed after parsing but before executing the command itself begins. Accessing a non-existent argument or failing to parse all arguments will raise a senf::console::SyntaxErrorException. \see \ref console_args_custom "Example customer parser"
|
explicit |
Make wrapper from ArgumentsRange.
This constructs a wrapper from a ParseCommandInfo::ArgumentsRange.
[in] | range | Range of arguments to parse |
[in] | msg | Error message |
|
explicit |
Make wrapper from TokensRange.
This constructs a wrapper from a ParseCommandInfo::TokensRange. The TokensRange is first converted into an ParseCommandInfo::ArgumentsRange which is then wrapped.
[in] | range | Range of tokens to parse |
[in] | msg | Error message |
|
noexcept |
Check, if all arguments are parsed.
The destructor validates, that all arguments are parsed correctly when leaving the scope, in which the wrapper is instantiated normally (not by an exception).
bool senf::console::CheckedArgumentIteratorWrapper::boolean_test | ( | ) | const |
true
, if more arguments are available
void senf::console::CheckedArgumentIteratorWrapper::clear | ( | ) |
Set range empty.
This call will point the current iterator to the end of the tokens range.
true
; bool senf::console::CheckedArgumentIteratorWrapper::done | ( | ) | const |
true
, if all arguments are parsed
senf::console::CheckedArgumentIteratorWrapper::operator ParseCommandInfo::ArgumentIterator | ( | ) |
Use wrapper as ParseCommandInfo::ArgumentIterator.
bool senf::console::CheckedArgumentIteratorWrapper::operator!= | ( | ParseCommandInfo::ArgumentIterator const & | other | ) | const |
Compare wrapper against ArgumentIterator.
ParseCommandInfo::ArgumentIterator senf::console::CheckedArgumentIteratorWrapper::operator++ | ( | int | ) |
bool senf::console::CheckedArgumentIteratorWrapper::operator== | ( | ParseCommandInfo::ArgumentIterator const & | other | ) | const |
Compare wrapper against ArgumentIterator.