Disk ARchive  2.5.12
Full featured and portable backup and archiving tool
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules
Public Member Functions | Protected Member Functions | List of all members
libdar::user_interaction Class Referenceabstract

This is a pure virtual class that is used by libdar when interaction with the user is required. More...

#include <user_interaction.hpp>

Inherits libdar::on_pool.

Inherited by libdar::user_interaction_blind, and libdar::user_interaction_callback.

Public Member Functions

 user_interaction ()
 class constructor.
 
virtual void pause (const std::string &message)
 method used to ask a boolean question to the user. More...
 
virtual bool pause2 (const std::string &message)
 alternative method to the pause() method More...
 
void warning (const std::string &message)
 method used to display a warning or a message to the user. More...
 
virtual std::string get_string (const std::string &message, bool echo)=0
 method used to ask a question that needs an arbitrary answer. More...
 
virtual secu_string get_secu_string (const std::string &message, bool echo)=0
 same a get_string() but uses secu_string instead More...
 
virtual void listing (const std::string &flag, const std::string &perm, const std::string &uid, const std::string &gid, const std::string &size, const std::string &date, const std::string &filename, bool is_dir, bool has_children)
 
virtual void dar_manager_show_files (const std::string &filename, bool data_change, bool ea_change)
 
virtual void dar_manager_contents (U_I number, const std::string &chemin, const std::string &archive_name)
 
virtual void dar_manager_statistics (U_I number, const infinint &data_count, const infinint &total_data, const infinint &ea_count, const infinint &total_ea)
 
virtual void dar_manager_show_version (U_I number, const std::string &data_date, const std::string &data_presence, const std::string &ea_date, const std::string &ea_presence)
 
void printf (const char *format,...)
 libdar uses this call to format output before send to warning() method. More...
 
bool get_use_listing () const
 this is not a virtual method, it has not to be overwritten in inherited classes. More...
 
bool get_use_dar_manager_show_files () const
 this is not a virtual method, it has not to be overwritten in inherited classes.
 
bool get_use_dar_manager_contents () const
 this is not a virtual method, it has not to be overwritten in inherited classes.
 
bool get_use_dar_manager_statistics () const
 this is not a virtual method, it has not to be overwritten in inherited classes.
 
bool get_use_dar_manager_show_version () const
 this is not a virtual method, it has not to be overwritten in inherited classes.
 
virtual user_interactionclone () const =0
 make a newly allocated object which has the same properties as "this". More...
 
void warning_with_more (U_I num)
 make a pause each N line of output when calling the warning method More...
 
- Public Member Functions inherited from libdar::on_pool
void * operator new (size_t n_byte)
 
void * operator new (size_t n_byte, const std::nothrow_t &nothrow_value)
 
void * operator new[] (size_t n_byte)
 
void * operator new[] (size_t n_byte, const std::nothrow_t &nothrow_value)
 
void * operator new (size_t n_byte, memory_pool *p)
 
void * operator new[] (size_t n_byte, memory_pool *p)
 
void operator delete (void *ptr, memory_pool *p)
 this operator is called by the compiler if an exception is throw from the constructor of the allocated object
 
void operator delete[] (void *ptr, memory_pool *p)
 this operator is called by the compiler if an exception is throw from the constructor of the allocated objects
 
void operator delete (void *ptr)
 this is the usual delete operator, modified to handle allocated objects allocated on a memory pool or not
 
void operator delete[] (void *ptr)
 this is the usual delete[] operator, modified to handle allocated objects allocated on a memory pool or not
 

Protected Member Functions

void set_use_listing (bool val)
 method to be called with true as argument if you have defined a listing() method. More...
 
void set_use_dar_manager_show_files (bool val)
 method to be called with true as argument if you have defined a dar_manager_show_files() method.
 
void set_use_dar_manager_contents (bool val)
 method to be called with true as argument if you have defined a dar_manager_contents() method.
 
void set_use_dar_manager_statistics (bool val)
 method to be called with true as argument if you have defined a dar_manager_statistics() method.
 
void set_use_dar_manager_show_version (bool val)
 method to be called with true as argument if you have defined a dar_manager_show_version() method.
 
virtual void inherited_warning (const std::string &message)=0
 need to be overwritten in place of the warning() method since API 3.1.x More...
 
- Protected Member Functions inherited from libdar::on_pool
memory_pool * get_pool () const
 
template<class T >
void meta_new (T *&ptr, size_t num)
 
template<class T >
void meta_delete (T *ptr)
 

Detailed Description

This is a pure virtual class that is used by libdar when interaction with the user is required.

You can base your own class on it using C++ inheritance or use the class user_interaction_callback which implements the interaction based on callback functions. The user_interaction class is used by libdar in the following circumpstances:

the printf() method is built over the warning() methods to display a formated message it has not to be redefined in any inherited class. If you want to define you own class as inherited class of user_interaction you need to overwrite:

WARNING ! if your own class has specific fields, you will probably need to redefine the copy constructor as well as operator = if you don't understand this and why, don't play trying making your own class, and/or read good C++ book about canonical form of a C++ class, as well as how to properly make an inherited class. And don't, complain if libdar segfault or core dumps. Libdar needs to make local copies of these objects, if the copy constructor is not properly defined in your inherited class this will crash the application.

Definition at line 98 of file user_interaction.hpp.

Member Function Documentation

virtual user_interaction* libdar::user_interaction::clone ( ) const
pure virtual

make a newly allocated object which has the same properties as "this".

This is a virtual method, it must be overwritten in any inherited class copy constructor and = operator may have to be overwritten too if necessary Warning ! clone() must throw exception if necessary (Ememory), but never return a nullptr pointer !

Implemented in libdar::user_interaction_blind, and libdar::user_interaction_callback.

virtual void libdar::user_interaction::dar_manager_contents ( U_I  number,
const std::string &  chemin,
const std::string &  archive_name 
)
virtual

optional method to use if you want dar_manager database archive listing split in several fields if you want to use this feature, you have then to supply an implementation for this method in your inherited class, method that will be called by libdar in place of the warning method. You will also have to call the set_use_dar_manager_contents() protected method with true as argument from the constructor of your inherited class to tell libdar to use the dar_manager_contents() method in place of the warning() method.

Parameters
[in]numberis the number of the archive in the database
[in]cheminrecorded path where to find this archive
[in]archive_namebasename of this archive
Note
this method can be set for database::show_contents() to call it

Reimplemented in libdar::user_interaction_callback.

virtual void libdar::user_interaction::dar_manager_show_files ( const std::string &  filename,
bool  data_change,
bool  ea_change 
)
virtual

optional method to use if you want dar_manager database contents listing split in several fields. if you want to use this feature, you have then to supply an implementation for this method in your inherited class, method that will be called by libdar in place of the warning method. You will also have to call the set_use_dar_manager_show_files() protected method with true as argument from the constructor of your inherited class to tell libdar to use the dar_manager_show_files() method in place of the warning() method.

Parameters
[in]filenamename of the file
[in]data_changewhether the backup owns the most recent data for the file
[in]ea_changewhether the backup owns the most recent Extended Attributes for the file
Note
this method can be set for database::show_files() method to call it

Reimplemented in libdar::user_interaction_callback.

virtual void libdar::user_interaction::dar_manager_show_version ( U_I  number,
const std::string &  data_date,
const std::string &  data_presence,
const std::string &  ea_date,
const std::string &  ea_presence 
)
virtual

optional method to use if you want dar_manager statistics listing split in several fields if you want to use this feature, you have then to supply an implementation for this method in your inherited class, method that will be called by libdar in place of the warning method. You will also have to call the set_use_dar_manager_show_version() protected method with true as argument from the constructor of your inherited class to tell libdar to use the dar_manager_show_version() method in place of the warning() method.

Parameters
[in]numberarchive number
[in]data_dateis the last modification date of the requested file in thie archive whose number is "number"
[in]data_presenceis the nature of this modification, true if the data was saved, false if it was deleted
[in]ea_dateis the date of the EA for the requested file in the archive whose number is "number"
[in]ea_presenceis the nature of this modification, true if the EAs were saved, false if they were deleted
Note
this method can be set for database::show_version() method to call it

Reimplemented in libdar::user_interaction_callback.

virtual void libdar::user_interaction::dar_manager_statistics ( U_I  number,
const infinint data_count,
const infinint total_data,
const infinint ea_count,
const infinint total_ea 
)
virtual

optional method to use if you want dar_manager statistics listing split in several fields if you want to use this feature, you have then to supply an implementation for this method in your inherited class, method that will be called by libdar in place of the warning method. You will also have to call the set_use_dar_manager_statistics() protected method with true as argument from the constructor of your inherited class to tell libdar to use the dar_manager_statistics() method in place of the warning() method.

Parameters
[in]numberarchive number
[in]data_countamount of file which last version is located in this archive
[in]total_datatotal number of file covered in this database
[in]ea_countamount of EA which last version is located in this archive
[in]total_eatotal number of file that have EA covered by this database
Note
this method can be set for database::show_most_recent_stats() method to call it

Reimplemented in libdar::user_interaction_callback.

virtual secu_string libdar::user_interaction::get_secu_string ( const std::string &  message,
bool  echo 
)
pure virtual

same a get_string() but uses secu_string instead

Parameters
[in]messageis the question to display to the user.
[in]echois set to false is the answer must not be shown while the user answers.
Returns
the user's answer.

Implemented in libdar::user_interaction_blind, and libdar::user_interaction_callback.

virtual std::string libdar::user_interaction::get_string ( const std::string &  message,
bool  echo 
)
pure virtual

method used to ask a question that needs an arbitrary answer.

Parameters
[in]messageis the question to display to the user.
[in]echois set to false is the answer must not be shown while the user answers.
Returns
the user's answer.

Implemented in libdar::user_interaction_blind, and libdar::user_interaction_callback.

bool libdar::user_interaction::get_use_listing ( ) const
inline

this is not a virtual method, it has not to be overwritten in inherited classes.

for libdar to know if it is interesting to use listing(), dar_manager_show_files(), dar_manager_contents(), dar_manager_statistics() or to keep reporting listing thanks to the warning() method,

Definition at line 266 of file user_interaction.hpp.

virtual void libdar::user_interaction::inherited_warning ( const std::string &  message)
protectedpure virtual

need to be overwritten in place of the warning() method since API 3.1.x

Parameters
[in]messagemessage to display

Implemented in libdar::user_interaction_blind, and libdar::user_interaction_callback.

virtual void libdar::user_interaction::listing ( const std::string &  flag,
const std::string &  perm,
const std::string &  uid,
const std::string &  gid,
const std::string &  size,
const std::string &  date,
const std::string &  filename,
bool  is_dir,
bool  has_children 
)
virtual

optional method to use if you want file listing splitted in several fields. If you need to use this feature, you have then to supply an implementation for this method, in your inherited class which will be called by libdar in place of the warning method You then also have to call the set_use_listing() method with true as parameter from the constructor of your inherited class (for example) to tell libdar that the listing() method is to be used in place of the warning() method for archive listing.

Parameters
[in]flagis the given information about the EA, compression, presence of saved data.
[in]permis the access permission of the file.
[in]uidUser ID of the file.
[in]gidGroup ID of the file.
[in]sizefile size.
[in]datefile modification date.
[in]filenamefile name.
[in]is_dirtrue if file is a directory.
[in]has_childrentrue if file is a directory which is not empty.
Note
This is not a pure virtual method, this is normal, so your inherited class is not obliged to overwrite it.

Reimplemented in libdar::user_interaction_callback.

virtual void libdar::user_interaction::pause ( const std::string &  message)
inlinevirtual

method used to ask a boolean question to the user.

Parameters
[in]messageis the message to be displayed, that is the question.
Exceptions
Euser_abortIf the user answer "false" or "no" to the question the method must throw an exception of type "Euser_abort".

Reimplemented in libdar::user_interaction_callback.

Definition at line 111 of file user_interaction.hpp.

References pause2().

virtual bool libdar::user_interaction::pause2 ( const std::string &  message)
inlinevirtual

alternative method to the pause() method

Parameters
[in]messageThe boolean question to ask to the user
Returns
the answer of the user (true/yes or no/false)
Note
either pause2() or pause() must be overwritten, but not both. libdar always calls pause() which default implementation relies on pause2() where it converts negative return from pause2() by throwing the appropriated exception. As soon as you overwrite pause(), pause2() is no more used.

Reimplemented in libdar::user_interaction_blind.

Definition at line 125 of file user_interaction.hpp.

Referenced by pause().

void libdar::user_interaction::printf ( const char *  format,
  ... 
)

libdar uses this call to format output before send to warning() method.

This is not a virtual method, it has not to be overwritten, it is just a sublayer over warning() Supported masks for the format string are:

  • %s %c %d %% (normal behavior)
  • %i (matches infinint *)
  • %S (matches std::string *)
void libdar::user_interaction::set_use_listing ( bool  val)
inlineprotected

method to be called with true as argument if you have defined a listing() method.

in the constructor of any inherited class that define a listing() method it is advisable to call set_use_listing() with true as argument for libdar knows that the listing() call has to be used in place of the warning() call for file listing.

Definition at line 302 of file user_interaction.hpp.

Referenced by libdar::user_interaction_callback::set_listing_callback().

void libdar::user_interaction::warning ( const std::string &  message)

method used to display a warning or a message to the user.

Parameters
[in]messageis the message to display.
Note
since API 3.1.x this method must no more be ovewritten, instead the protected method inherited_warning() must be used.
void libdar::user_interaction::warning_with_more ( U_I  num)
inline

make a pause each N line of output when calling the warning method

Parameters
[in]numis the number of line to display at once, zero for unlimited display
Note
. Since API 3.1, the warning method is no more a pure virtual function you need to call the parent warning method in your method for this warning_with_more method works as expected.

Definition at line 292 of file user_interaction.hpp.


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