libzypp: ztui::PromptOptions Class Reference

libzypp 17.38.11

ztui::PromptOptions Class Reference

Example: `PromptOptions popts; popts.setOptions(_("y/n/p"), 0 / * default reply * /); popts.setOptionHelp(0, _("Help for option 'y'")); popts.setOptionHelp(1, _("Help for option 'n'")); ... zypper.out().prompt(PROMPT_YN_INST_REMOVE_CONTINUE, prompt_text, popts); unsigned reply = get_prompt_reply(zypper, PROMPT_YN_INST_REMOVE_CONTINUE, popts);` . More...

`#include <zypp-tui/output/promptoptions.h>`

## Public Types
using | StrVector = std::vector<std::string>

## Public Member Functions
| PromptOptions ()
| Default c-tor.
| PromptOptions (StrVector options_r, unsigned defaultOpt_r)
| Ctor taking the option values as vector.
| PromptOptions (const std::string &optionstr_r, unsigned defaultOpt_r)
| Constructor.
| ~PromptOptions ()
| D-tor.
const StrVector & | options () const
void | setOptions (StrVector options_r, unsigned defaultOpt_r)
void | setOptions (const std::string &optionstr_r, unsigned defaultOpt_r)
unsigned | defaultOpt () const
ColorString | optionString () const
| Option string (may have embedded color codes).
bool | empty () const
bool | isYesNoPrompt () const
const std::string & | optionHelp (unsigned opt) const
void | setOptionHelp (unsigned opt, const std::string &help_str)
bool | helpEmpty () const
bool | isEnabled (unsigned opt) const
bool | isDisabled (unsigned opt) const
void | disable (unsigned opt)
void | enable (unsigned opt)
void | enableAll ()
unsigned | shownCount () const
void | setShownCount (unsigned count)
std::vector< int > | getReplyMatches (const std::string &reply_r) const
| Return the indices of option string matches (lowercase/prefix or #NUM).
std::string | replyMatchesStr (const std::vector< int > &matches_r) const
| The returned reply matches as '(,)' list.

## Private Attributes
StrVector | _options
| option strings
unsigned | _default = 0
| index of the default option
StrVector | _opt_help
| help strings corresponding to options
std::set< unsigned > | _disabled
| set of options to ignore
int | _shown_count = -1
| Number of options to show (the rest will still be available and visible through '?

## Detailed Description

Example: `PromptOptions popts; popts.setOptions(_("y/n/p"), 0 / * default reply * /); popts.setOptionHelp(0, _("Help for option 'y'")); popts.setOptionHelp(1, _("Help for option 'n'")); ... zypper.out().prompt(PROMPT_YN_INST_REMOVE_CONTINUE, prompt_text, popts); unsigned reply = get_prompt_reply(zypper, PROMPT_YN_INST_REMOVE_CONTINUE, popts);` .

Definition at line 38 of file promptoptions.h.

## Member Typedef Documentation

## ◆ StrVector

using ztui::PromptOptions::StrVector = std::vector<std::string>

Definition at line 41 of file promptoptions.h.

## Constructor & Destructor Documentation

## ◆ PromptOptions() [1/3]

ztui::PromptOptions::PromptOptions | ( |  | ) |
| inline

Default c-tor.

Definition at line 46 of file promptoptions.h.

## ◆ PromptOptions() [2/3]

ztui::PromptOptions::PromptOptions | ( | StrVector | options_r,
|  | unsigned | defaultOpt_r )

Ctor taking the option values as vector.

Definition at line 20 of file promptoptions.cc.

## ◆ PromptOptions() [3/3]

ztui::PromptOptions::PromptOptions | ( | const std::string & | optionstr_r,
|  | unsigned | defaultOpt_r )

Constructor.

Parameters

  optionstr_r | translated option string containing one or more options separated by slash '/' character e.g. "yes/no/?" or "1/s/r/c"
  defaultOpt_r | index of the default answer within the option_str

Definition at line 23 of file promptoptions.cc.

## ◆ ~PromptOptions()

ztui::PromptOptions::~PromptOptions | ( |  | ) |

D-tor.

Definition at line 28 of file promptoptions.cc.

## Member Function Documentation

## ◆ options()

const StrVector & ztui::PromptOptions::options | ( |  | ) | const
| inline

Definition at line 64 of file promptoptions.h.

## ◆ setOptions() [1/2]

void ztui::PromptOptions::setOptions | ( | StrVector | options_r,
|  | unsigned | defaultOpt_r )

Definition at line 33 of file promptoptions.cc.

## ◆ setOptions() [2/2]

void ztui::PromptOptions::setOptions | ( | const std::string & | optionstr_r,
|  | unsigned | defaultOpt_r )

Definition at line 45 of file promptoptions.cc.

## ◆ defaultOpt()

unsigned ztui::PromptOptions::defaultOpt | ( |  | ) | const
| inline

Definition at line 68 of file promptoptions.h.

## ◆ optionString()

ColorString ztui::PromptOptions::optionString | ( |  | ) | const

Option string (may have embedded color codes).

Definition at line 52 of file promptoptions.cc.

## ◆ empty()

bool ztui::PromptOptions::empty | ( |  | ) | const
| inline

Definition at line 71 of file promptoptions.h.

## ◆ isYesNoPrompt()

bool ztui::PromptOptions::isYesNoPrompt | ( |  | ) | const

Definition at line 193 of file promptoptions.cc.

## ◆ optionHelp()

const std::string & ztui::PromptOptions::optionHelp | ( | unsigned | opt | ) | const
| inline

Definition at line 74 of file promptoptions.h.

## ◆ setOptionHelp()

void ztui::PromptOptions::setOptionHelp | ( | unsigned | opt,
|  | const std::string & | help_str )

Definition at line 97 of file promptoptions.cc.

## ◆ helpEmpty()

bool ztui::PromptOptions::helpEmpty | ( |  | ) | const
| inline

Definition at line 78 of file promptoptions.h.

## ◆ isEnabled()

bool ztui::PromptOptions::isEnabled | ( | unsigned | opt | ) | const
| inline

Definition at line 80 of file promptoptions.h.

## ◆ isDisabled()

bool ztui::PromptOptions::isDisabled | ( | unsigned | opt | ) | const
| inline

Definition at line 82 of file promptoptions.h.

## ◆ disable()

void ztui::PromptOptions::disable | ( | unsigned | opt | ) |
| inline

Definition at line 84 of file promptoptions.h.

## ◆ enable()

void ztui::PromptOptions::enable | ( | unsigned | opt | ) |
| inline

Definition at line 86 of file promptoptions.h.

## ◆ enableAll()

void ztui::PromptOptions::enableAll | ( |  | ) |
| inline

Definition at line 88 of file promptoptions.h.

## ◆ shownCount()

unsigned ztui::PromptOptions::shownCount | ( |  | ) | const
| inline

Definition at line 91 of file promptoptions.h.

## ◆ setShownCount()

void ztui::PromptOptions::setShownCount | ( | unsigned | count | ) |
| inline

Definition at line 93 of file promptoptions.h.

## ◆ getReplyMatches()

std::vector< int > ztui::PromptOptions::getReplyMatches | ( | const std::string & | reply_r | ) | const

Return the indices of option string matches (lowercase/prefix or #NUM).

Definition at line 117 of file promptoptions.cc.

## ◆ replyMatchesStr()

std::string ztui::PromptOptions::replyMatchesStr | ( | const std::vector< int > & | matches_r | ) | const

The returned reply matches as '(,)' list.

Definition at line 181 of file promptoptions.cc.

## Member Data Documentation

## ◆ _options

StrVector ztui::PromptOptions::_options
| private

option strings

Definition at line 103 of file promptoptions.h.

## ◆ _default

unsigned ztui::PromptOptions::_default = 0
| private

index of the default option

Definition at line 105 of file promptoptions.h.

## ◆ _opt_help

StrVector ztui::PromptOptions::_opt_help
| private

help strings corresponding to options

Definition at line 107 of file promptoptions.h.

## ◆ _disabled

std::set<unsigned> ztui::PromptOptions::_disabled
| private

set of options to ignore

Definition at line 109 of file promptoptions.h.

## ◆ _shown_count

int ztui::PromptOptions::_shown_count = -1
| private

Number of options to show (the rest will still be available and visible through '?

' help). If negative, all options will be shown. Zero is allowed.

Definition at line 114 of file promptoptions.h.

The documentation for this class was generated from the following files:

- zypp-tui/output/promptoptions.h
- zypp-tui/output/promptoptions.cc