| Disk ARchive 2.7.18 Full featured and portable backup and archiving tool

Loading...
Searching...
No Matches
user_interaction_callback.hpp
Go to the documentation of this file.
1/*********************************************************************/
2// dar - disk archive - a backup/restoration program
3// Copyright (C) 2002-2025 Denis Corbin
4//
5// This program is free software; you can redistribute it and/or
6// modify it under the terms of the GNU General Public License
7// as published by the Free Software Foundation; either version 2
8// of the License, or (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18//
19// to contact the author, see the AUTHOR file
20/*********************************************************************/
21
33
34
35#ifndef USER_INTERACTION_CALLBACK_HPP
36#define USER_INTERACTION_CALLBACK_HPP
37
38#include "../my_config.h"
39
40#include <string>
41#include "user_interaction.hpp"
42#include "secu_string.hpp"
43
44 namespace libdar
45{
46
49
50
52
56
57 class user_interaction_callback : public user_interaction
58 {
59 public:
60
61 using message_callback = void (*)(const std::string &x, void *context);
62 using pause_callback = bool (*)(const std::string &x, void *context);
63 using get_string_callback = std::string (*)(const std::string &x, bool echo, void *context);
64 using get_secu_string_callback = secu_string (*)(const std::string &x, bool echo, void *context);
65
67
78 user_interaction_callback(message_callback x_message_callback,
79 pause_callback x_answer_callback,
80 get_string_callback x_string_callback,
81 get_secu_string_callback x_secu_string_callback,
82 void *context_value);
83 user_interaction_callback(const user_interaction_callback & ref) = default;
84 user_interaction_callback(user_interaction_callback && ref) noexcept = default;
85 user_interaction_callback & operator = (const user_interaction_callback & ref) = default;
86 user_interaction_callback & operator = (user_interaction_callback && ref) noexcept = default;
87 ~user_interaction_callback() = default;
88
90
92
94
96
98
99 protected:
100
102 virtual void inherited_message(const std::string & message) override;
103
105 virtual bool inherited_pause(const std::string & message) override;
106
108 virtual std::string inherited_get_string(const std::string & message, bool echo) override;
109
111 virtual secu_string inherited_get_secu_string(const std::string & message, bool echo) override;
112
114 void change_context_value(void *new_value) { context_val = new_value; };
115
116 private:
117 message_callback message_cb;
118 pause_callback pause_cb;
119 get_string_callback get_string_cb;
120 get_secu_string_callback get_secu_string_cb;
121 void *context_val;
122 };
123
125
126} // end of namespace
127
128#endif
libdar::secu_string
class secu_string
Definition secu_string.hpp:54
libdar::user_interaction_callback
full implemented class for user_interaction based on callback functions.
Definition user_interaction_callback.hpp:58
libdar::user_interaction_callback::inherited_get_secu_string
virtual secu_string inherited_get_secu_string(const std::string &message, bool echo) override
overwritting method from parent class.
libdar::user_interaction_callback::inherited_pause
virtual bool inherited_pause(const std::string &message) override
overwritting method from parent class.
libdar::user_interaction_callback::inherited_get_string
virtual std::string inherited_get_string(const std::string &message, bool echo) override
overwritting method from parent class.
libdar::user_interaction_callback::user_interaction_callback
user_interaction_callback(message_callback x_message_callback, pause_callback x_answer_callback, get_string_callback x_string_callback, get_secu_string_callback x_secu_string_callback, void *context_value)
constructor which receive the callback functions.
libdar::user_interaction_callback::inherited_message
virtual void inherited_message(const std::string &message) override
listing callback can be now passed directly to archive::get_children_of()
libdar::user_interaction_callback::change_context_value
void change_context_value(void *new_value)
change the context value of the object that will be given to callback functions
Definition user_interaction_callback.hpp:114
libdar::user_interaction
This is a pure virtual class that is used by libdar when interaction with the user is required.
Definition user_interaction.hpp:47
my_config.h
include macro defined by the configure script and some specific additional ones
libdar
libdar namespace encapsulate all libdar symbols
Definition archive.hpp:47
secu_string.hpp
this file contains the definition of secu_string class, a std::string like class but allocated in sec...
user_interaction.hpp
defines the interaction interface between libdar and users.