|
cli20 0.1.2
A C++20 typed-schema command-line parser
|
The result type produced and consumed at each step of an action pipeline. More...
#include <action.hh>
Public Types | |
| enum class | State : std::uint8_t { ok , error , ignore } |
| using | value_type = T |
Public Member Functions | |
| constexpr | operator bool () const noexcept |
| Returns true when the result represents success. | |
| constexpr auto | have_value () const noexcept -> bool |
| Returns true when the result represents success. | |
| constexpr auto | has_value () const noexcept -> bool |
| Returns true when the result represents success. | |
| constexpr auto | has_error () const noexcept -> bool |
| Returns true when the result represents failure. | |
| constexpr auto | is_ignored () const noexcept -> bool |
| Returns true when the result represents an ignored step. | |
Static Public Member Functions | |
| template<class U> | |
| static constexpr auto | ok (U &&v) -> ActionResult |
| Creates a success result holding value. | |
| static constexpr auto | fail (ParseError e) -> ActionResult |
| Creates a failure result carrying error. | |
| static constexpr auto | ignore () -> ActionResult |
| Creates an ignore result. | |
Public Attributes | |
| State | state {State::ok} |
| ParseError | error {} |
| T | value {} |
The result type produced and consumed at each step of an action pipeline.
An ActionResult<T> is a 3-state type: ok (carrying a value of type T), error (carrying a ParseError), or ignore (silent skip). The operator bool(), have_value(), has_value(), has_error(), and is_ignored() methods make it easy to check the state inline.
Factory methods:
| T | The value type held on success. |
| using cli::ActionResult< T >::value_type = T |
|
strong |
|
inlinestaticnodiscardconstexpr |
Creates a failure result carrying error.
| e | The error to store. |
|
inlinenodiscardconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
|
inlinestaticnodiscardconstexpr |
Creates an ignore result.
|
inlinenodiscardconstexprnoexcept |
|
inlinestaticnodiscardconstexpr |
Creates a success result holding value.
| U | Type of the value (deduced). |
| v | The value to store. |
|
inlineexplicitnodiscardconstexprnoexcept |
| ParseError cli::ActionResult< T >::error {} |
| State cli::ActionResult< T >::state {State::ok} |
| T cli::ActionResult< T >::value {} |