10#ifndef BACKUP_TYPE_HPP
11#define BACKUP_TYPE_HPP
51 Debug(misc, 0,
"{}:{}: Backed-up value was not restored!", this->
location.file_name(), this->location.line());
85 this->original = new_value;
190 static void *
operator new(std::size_t) =
delete;
191 static void *
operator new[](std::size_t) =
delete;
Functions related to debugging.
#define Debug(category, level, format_string,...)
Output a line of debugging information.
const T & GetOriginalValue() const
Returns the backupped value.
~AutoRestoreBackup()
Restore the variable upon object destruction.
T original_value
The value at the moment of making a backup.
AutoRestoreBackup(T &original, T new_value)
Backup variable and switch to new value.
T & original
Reference to the value we are backing up.
void Revert()
Revert the variable to its original value, but do not mark it as restored.
bool IsValid() const
Checks whether the variable was already restored.
Backup(T &original, const std::source_location location=std::source_location::current())
Backup variable.
void Trash()
Trash the backup.
~Backup()
Check whether the variable was restored on object destruction.
bool Verify() const
Check whether the variable is currently equals the backup.
T original_value
The value at the moment of making a backup.
void Change(const U &new_value)
Change the value of the variable.
bool valid
Whether the original value has been restored.
T & original
Reference to the value we are backing up.
void Update()
Update the backup.
const T & GetOriginalValue() const
Returns the backupped value.
Backup(T &original, const U &new_value, const std::source_location location=std::source_location::current())
Backup variable and switch to new value.
void Restore()
Restore the variable.
const std::source_location location
Call location where the backup was created.