Provides the result, success or error, of a command line argument parsing operation.
More...
#include <ookii/parse_result.h>
|
using | string_type = std::basic_string< CharType, Traits, Alloc > |
| The concrete string type used by this structure.
|
|
template<typename CharType, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
struct ookii::parse_result< CharType, Traits, Alloc >
Provides the result, success or error, of a command line argument parsing operation.
This type is returned from the various basic_command_line_parser::parse() overloads to indicate success or failure. Inspect the value to see if parsing was successful.
- Warning
- Command line argument parsing is not atomic; if a value indicating failure is returned, some of the arguments could have already been successfully parsed and their variables set to the supplied values.
- Template Parameters
-
CharType | The character type used for argument names and error strings. |
Traits | The character traits to use for strings. Defaults to std::char_traits<CharType> . |
Alloc | The allocator to use for strings. Defaults to std::allocator<CharType> . |
◆ parse_result()
template<typename CharType , typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
Initializes a new instance of the parse_result structure.
- Parameters
-
error | The type of error that occurred, or parse_error::none to indicate no error. |
error_arg_name | The name of the argument that caused the error, or a blank string if there was no error or the error doesn't relate to a specific argument. |
◆ get_error_message()
template<typename CharType , typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
Gets a default, English language error message for the current error.
If appropriate, the message will include the name of the argument that caused the error.
- Parameters
-
loc | The locale to use to format the error message. |
- Returns
- The error message, or a blank string for parse_error::none and parse_error::parsing_cancelled.
◆ operator bool()
template<typename CharType , typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
Checks if the result was successful.
- Returns
true
only if the error is parse_error::none; otherwise, false
.
The documentation for this struct was generated from the following file:
- /mnt/d/Sven/Documents/Code/Ookii.CommandLine.Cpp/include/ookii/parse_result.h