Phasor 3.3.0
Stack VM based Programming Language
Loading...
Searching...
No Matches
userconsent.h File Reference
#include <print>
#include <string>
#include <format>
#include <unordered_map>
#include <cstdlib>
#include <enum_array>
#include <unistd.h>
Include dependency graph for userconsent.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum class  EConsentVolition {
  Might , WouldLike , Wants , Needs ,
  HasTo , Must
}
 Priority level for the prompt_consent permission request. More...

Functions

template<size_t N1, size_t N2, size_t N3>
bool prompt_consent (const char(&subsystem)[N1], EConsentVolition volition, const char(&verb)[N2], const char(&noun)[N3], bool default_val=false)
 Prompt the user for consent.

Variables

static constexpr enum_array< EConsentVolition, std::string_view, 6 > AConsentVolition
 Array for the EConsentVolition enum.

Enumeration Type Documentation

◆ EConsentVolition

enum class EConsentVolition
strong

Priority level for the prompt_consent permission request.

Enumerator
Might 
WouldLike 
Wants 
Needs 
HasTo 
Must 

SHOULD ONLY BE USED IF IT WILL END THE PROGRAM ON FALSE.

Definition at line 25 of file userconsent.h.

Function Documentation

◆ prompt_consent()

template<size_t N1, size_t N2, size_t N3>
bool prompt_consent ( const char(&) subsystem[N1],
EConsentVolition volition,
const char(&) verb[N2],
const char(&) noun[N3],
bool default_val = false )
inline

Prompt the user for consent.

Parameters
subsystemThe string literal denoting the subsystem requesting consent
volitionThe priority level of the request
verbThe string literal denoting the action being requested
nounThe string literal denoting the object being acted upon
default_valThe default value if the user doesn't respond
Returns
true if the user consents, false otherwise

The function will check if a TTY is present, if not, GUI fallbacks (e.g. WindowsAPI, AppleCF, zenity/kdialog) will be attempted, returning false on failure.

Definition at line 56 of file userconsent.h.

Here is the caller graph for this function:

Variable Documentation

◆ AConsentVolition

enum_array<EConsentVolition, std::string_view, 6> AConsentVolition
staticconstexpr
Initial value:
= {{
"might",
"would like to",
"wants to",
"needs to",
"has to",
"must"
}}

Array for the EConsentVolition enum.

Definition at line 35 of file userconsent.h.