21#ifndef G_OPTION_VALUE_H
22#define G_OPTION_VALUE_H
55 bool isOn()
const noexcept ;
58 bool isOff()
const noexcept ;
61 std::string
value()
const ;
64 std::string_view
valueref()
const noexcept ;
67 bool operator==( std::string_view )
const noexcept ;
73 unsigned int number(
unsigned int default_ = 0U )
const ;
77 size_t count()
const noexcept ;
84 bool m_on_off {
false} ;
85 std::size_t m_count {1U} ;
92 m_value(
G::
Str::positive())
144 return s == m_value ;
A simple structure encapsulating the value of a command-line option.
OptionValue()
Default constructor for a valueless value.
std::string_view valueref() const noexcept
Exposes the value as a string view.
static OptionValue on()
A factory function for an unvalued option-enabled option.
bool isOff() const noexcept
Returns true if off().
size_t count() const noexcept
Returns an instance count that is one by default.
static OptionValue off()
A factory function for an unvalued option-disabled option.
bool numeric() const noexcept
Returns true if value() is an unsigned integer.
bool isOn() const noexcept
Returns true if on().
std::string value() const
Returns the value as a string.
unsigned int number(unsigned int default_=0U) const
Returns value() as an unsigned integer.
void increment() noexcept
Increments the instance count().
bool operator==(std::string_view) const noexcept
Returns true if the given string matches value().
A static class which provides string helper functions.
static bool isUInt(std::string_view s) noexcept
Returns true if the string can be converted into an unsigned integer without throwing an exception.
static bool isPositive(std::string_view) noexcept
Returns true if the string has a positive meaning, such as "1", "true", "yes".
static std::string negative()
Returns a default negative string. See isNegative().
static unsigned int toUInt(std::string_view s)
Converts string 's' to an unsigned int.
static bool isNegative(std::string_view) noexcept
Returns true if the string has a negative meaning, such as "0", "false", "no".