MySQL 8.0.39
Source Code Documentation
|
Automatic cleanup on scope exit utility class. More...
#include <auto_cleaner.h>
Public Member Functions | |
void | add_file_delete (const std::string &file) |
void | add_directory_delete (const std::string &d, bool recursive=false) |
void | add_file_revert (const std::string &file) |
void | add_file_revert (const std::string &file, const std::string &backup_file) |
void | add_cleanup_callback (std::function< void()> callback) noexcept |
void | clear_cleanup_callbacks () noexcept |
void | remove (const std::string &file) noexcept |
void | clear () |
AutoCleaner ()=default | |
~AutoCleaner () | |
AutoCleaner (AutoCleaner &&other) noexcept=default | |
AutoCleaner & | operator= (AutoCleaner &&other)=default |
AutoCleaner (const AutoCleaner &)=delete | |
AutoCleaner & | operator= (const AutoCleaner &)=delete |
Private Types | |
enum | Type { Directory , DirectoryRecursive , File , FileBackup } |
Private Attributes | |
std::vector< std::pair< std::string, std::pair< Type, std::string > > > | files_ |
std::vector< std::function< void()> > | callbacks_ |
Automatic cleanup on scope exit utility class.
Automatic cleanup takes place on AutoCleaner object destruction. It allows to:
AutoCleaner allows to clear its state so that no action will be taken on scope exit (auto generated backup files will be cleaned up in such case).
Adding an action (cleanup, revert) is done once per file. It is not possible to add a second action for the same file (such add call will fail, initial action will not be affected). Adding a revert file action may fail if initial or backup files could not be opened.
|
private |
|
default |
mysqlrouter::AutoCleaner::~AutoCleaner | ( | ) |
|
defaultnoexcept |
|
delete |
|
noexcept |
void mysqlrouter::AutoCleaner::add_directory_delete | ( | const std::string & | d, |
bool | recursive = false |
||
) |
void mysqlrouter::AutoCleaner::add_file_delete | ( | const std::string & | file | ) |
void mysqlrouter::AutoCleaner::add_file_revert | ( | const std::string & | file | ) |
void mysqlrouter::AutoCleaner::add_file_revert | ( | const std::string & | file, |
const std::string & | backup_file | ||
) |
void mysqlrouter::AutoCleaner::clear | ( | ) |
|
noexcept |
|
default |
|
delete |
|
noexcept |
|
private |
|
private |