Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
terminal::toggle Struct Reference

A simple yes/no toggle that parses from a string. More...

#include <terminal.hpp>

Public Member Functions

 operator bool () const
 Implicit conversion to bool.
 
 toggle (bool value_)
 
 toggle (std::string_view str, bool default_value=true)
 Construct from a string (e.g.
 

Public Attributes

bool value
 

Detailed Description

A simple yes/no toggle that parses from a string.

Accepts "yes", "true", "1" (case-insensitive) as true, and "no", "false", "0" as false. An empty string or unregognised value returns the default_value, which itself defaults to true.

Constructor & Destructor Documentation

◆ toggle() [1/2]

terminal::toggle::toggle ( bool  value_)
inline

◆ toggle() [2/2]

terminal::toggle::toggle ( std::string_view  str,
bool  default_value = true 
)
inline

Construct from a string (e.g.

from an env var).

Parameters
strThe string to interpret.
default_valueUsed if the string is empty or not recognized.

Member Function Documentation

◆ operator bool()

terminal::toggle::operator bool ( ) const
inline

Implicit conversion to bool.

Member Data Documentation

◆ value

bool terminal::toggle::value

The documentation for this struct was generated from the following file: