1 #ifndef OOKII_PARSE_RESULT_H_
4 #define OOKII_PARSE_RESULT_H_
14 template<
typename CharType>
17 static constexpr
auto invalid_value = literal_cast<CharType>(
"The value provided for the argument '{}' was invalid.");
18 static constexpr
auto unknown_argument = literal_cast<CharType>(
"Unknown argument name '{}'.");
19 static constexpr
auto missing_value = literal_cast<CharType>(
"No value was supplied for the argument '{}'.");
20 static constexpr
auto duplicate_argument = literal_cast<CharType>(
"The argument '{}' was supplied more than once.");
21 static constexpr
auto too_many_arguments = literal_cast<CharType>(
"Too many arguments were supplied.");
23 static constexpr
auto unknown = literal_cast<CharType>(
"An unknown error has occurred.");
72 template<
typename CharType,
typename Traits = std::
char_traits<CharType>,
typename Alloc = std::allocator<CharType>>
76 using string_type = std::basic_string<CharType, Traits, Alloc>;
86 error_arg_name{error_arg_name}
99 operator bool() const noexcept
120 return OOKII_FMT_NS format(loc, details::error_formats<CharType>::invalid_value.data(), error_arg_name);
123 return OOKII_FMT_NS format(loc, details::error_formats<CharType>::unknown_argument.data(), error_arg_name);
126 return OOKII_FMT_NS format(loc, details::error_formats<CharType>::missing_value.data(), error_arg_name);
129 return OOKII_FMT_NS format(loc, details::error_formats<CharType>::duplicate_argument.data(), error_arg_name);
132 return OOKII_FMT_NS format(loc, details::error_formats<CharType>::too_many_arguments.data(), error_arg_name);
135 return OOKII_FMT_NS format(loc, details::error_formats<CharType>::missing_required_argument.data(), error_arg_name);
138 return OOKII_FMT_NS format(loc, details::error_formats<CharType>::unknown.data(), error_arg_name);
Namespace containing the core Ookii.CommandLine.Cpp types.
Definition: command_line_argument.h:16
parse_error
The type of error that occurred while parsing the command line.
Definition: parse_result.h:29
@ invalid_value
A supplied value could not be converted to the argument's type.
@ parsing_cancelled
Parsing was cancelled by an argument using basic_parser_builder::argument_builder::cancel_parsing(),...
@ unknown_argument
An argument name was supplied that doesn't exist.
@ missing_required_argument
One of the required arguments was not supplied.
@ duplicate_argument
An argument, other than a multi-value argument, was supplied more than once, and basic_parser_builder...
@ missing_value
A named argument, other than a switch argument, was supplied without a value.
@ too_many_arguments
More positional arguments were supplied than were defined.
Provides the result, success or error, of a command line argument parsing operation.
Definition: parse_result.h:74
string_type get_error_message(const std::locale &loc={}) const
Gets a default, English language error message for the current error.
Definition: parse_result.h:111
parse_error error
The type of error that occurred, or parse_error::none to indicate no error.
Definition: parse_result.h:91
string_type error_arg_name
The name of the argument that caused the error, or a blank string if there was no error or the error ...
Definition: parse_result.h:95
parse_result(parse_error error=parse_error::none, string_type error_arg_name={})
Initializes a new instance of the parse_result structure.
Definition: parse_result.h:84
std::basic_string< CharType, Traits, Alloc > string_type
The concrete string type used by this structure.
Definition: parse_result.h:76