libzypp 17.37.17
userrequest.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
9#include "userrequest.h"
10#include <string>
11#include <utility>
12
13namespace zyppng
14{
18
21
23 {
24 return _userData;
25 }
26
28 {
29 return _userData;
30 }
31
32 ZYPP_IMPL_PRIVATE_CONSTR_ARGS(ShowMessageRequest, std::string message, MType mType, UserData data )
33 : UserRequest( std::move(data) )
34 , _type( mType )
35 , _message( std::move(message) )
36 { }
37
42
47
48 const std::string &ShowMessageRequest::message() const
49 {
50 return _message;
51 }
52
53 ZYPP_IMPL_PRIVATE_CONSTR_ARGS(ListChoiceRequest, std::string label, std::vector<Choice> answers, index_type defaultAnswer, UserData userData )
54 : UserRequest( std::move(userData) )
55 , _label( std::move(label) )
56 , _answers( std::move(answers) )
57 , _answer( std::move(defaultAnswer) )
58 , _default( std::move(defaultAnswer) )
59 { }
60
65
66 const std::string &ListChoiceRequest::label() const
67 {
68 return _label;
69 }
70
72 {
73 if ( sel >= _answers.size() )
74 ZYPP_THROW( std::logic_error("Selection index is out of range") );
75 _answer = sel;
76 }
77
82
87
88 const std::vector<ListChoiceRequest::Choice> &ListChoiceRequest::answers() const
89 {
90 return _answers;
91 }
92
93 ZYPP_IMPL_PRIVATE_CONSTR_ARGS(BooleanChoiceRequest, std::string label, const bool defaultAnswer, UserData userData )
94 : UserRequest( std::move(userData) )
95 , _label( std::move(label) )
96 , _answer( defaultAnswer )
97 { }
98
103
104 const std::string &BooleanChoiceRequest::label() const
105 {
106 return _label;
107 }
108
110 {
111 _answer = sel;
112 }
113
115 {
116 return _answer;
117 }
118
119}
UserRequestType type() const override
void setChoice(const bool sel)
const std::string & label() const
std::vector< Choice >::size_type index_type
index_type choice() const
void setChoice(const index_type sel)
std::vector< Choice > _answers
const std::string & label() const
UserRequestType type() const override
index_type defaultAnswer() const
const std::vector< Choice > & answers() const
const std::string & message() const
UserRequestType type() const override
const UserData & userData() const
UserRequest(UserData userData={})
~UserRequest() override
Definition Arch.h:364
UserRequestType
Definition userrequest.h:34
zypp::callback::UserData UserData
Definition userrequest.h:18
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition Exception.h:459
#define ZYPP_IMPL_PRIVATE_CONSTR_ARGS(Class,...)
Definition zyppglobal.h:224