1 #ifndef OOKII_COMMAND_LINE_SWITCH_H_
4 #define OOKII_COMMAND_LINE_SWITCH_H_
23 template<
typename CharType,
typename Traits,
typename Alloc>
29 static std::optional<bool>
from_string(std::basic_string_view<CharType, Traits> value,
const std::locale & = {})
31 constexpr
auto true_value = literal_cast<CharType>(
"true");
32 constexpr
auto true_alt_value = literal_cast<CharType>(
"1");
33 constexpr
auto false_value = literal_cast<CharType>(
"false");
34 constexpr
auto false_alt_value = literal_cast<CharType>(
"0");
36 if (string_equal_case_insensitive<CharType, Traits>(value, true_value.data()) ||
37 value == true_alt_value.data())
41 else if (string_equal_case_insensitive<CharType, Traits>(value, false_value.data()) ||
42 value == false_alt_value.data())
56 struct is_switch :
public std::false_type {};
59 struct is_switch<bool> :
public std::true_type {};
62 struct is_switch<std::optional<bool>> :
public std::true_type {};
Namespace containing the core Ookii.CommandLine.Cpp types.
Definition: command_line_argument.h:16
static std::optional< bool > from_string(std::basic_string_view< CharType, Traits > value, const std::locale &={})
Convert a string to the specified type.
Definition: command_line_switch.h:29
Template class used to convert strings to strongly typed argument values.
Definition: string_helper.h:212
Provides a template used to determine the default value description for a type.