summaryrefslogtreecommitdiff
path: root/binaryninjaapi.h
diff options
context:
space:
mode:
authorGlenn Smith <glenn@vector35.com>2023-05-30 19:53:03 -0400
committerGlenn Smith <glenn@vector35.com>2023-06-08 17:18:30 -0400
commit1509435163893916647427200437885127141494 (patch)
tree769f54599dcaa07f8088f7b4a191d6c8f7196ffe /binaryninjaapi.h
parent0882343191078862361937493035030128230878 (diff)
Undo transactions / context manager
Diffstat (limited to 'binaryninjaapi.h')
-rw-r--r--binaryninjaapi.h26
1 files changed, 24 insertions, 2 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index d81c6320..5f4f6d16 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -2148,11 +2148,22 @@ namespace BinaryNinja {
bool CreateSnapshotedView(BinaryView* data, const std::string& viewName,
const std::function<bool(size_t progress, size_t total)>& progressCallback);
+ /*! Run a function in a context in which any changes made to analysis will be added to an undo state.
+ If the function returns false or throws an exception, any changes made within will be reverted.
+
+ \param func Function to run in undo context
+ \return Return status of function
+ \throws std::exception If the called function throws an exception
+ */
+ bool RunUndoableTransaction(std::function<bool()> func);
+
/*! Start recording actions taken so they can be undone at some point
+ \param anonymousAllowed Legacy interop: prevent empty calls to CommitUndoActions from affecting this
+ undo state. Specifically for RunUndoableTransaction.
\return Id of UndoEntry created, for passing to either CommitUndoActions or RevertUndoActions
*/
- [[nodiscard]] std::string BeginUndoActions();
+ [[nodiscard]] std::string BeginUndoActions(bool anonymousAllowed = true);
/*! Commit the actions taken since a call to BeginUndoActions.
@@ -3558,11 +3569,22 @@ namespace BinaryNinja {
bool SaveAutoSnapshot(const std::function<bool(size_t progress, size_t total)>& progressCallback,
Ref<SaveSettings> settings = new SaveSettings());
+ /*! Run a function in a context in which any changes made to analysis will be added to an undo state.
+ If the function returns false or throws an exception, any changes made within will be reverted.
+
+ \param func Function to run in undo context
+ \return Return status of function
+ \throws std::exception If the called function throws an exception
+ */
+ bool RunUndoableTransaction(std::function<bool()> func);
+
/*! Start recording actions taken so they can be undone at some point
+ \param anonymousAllowed Legacy interop: prevent empty calls to CommitUndoActions from affecting this
+ undo state. Specifically for RunUndoableTransaction.
\return Id of UndoEntry created, for passing to either CommitUndoActions or RevertUndoActions
*/
- [[nodiscard]] std::string BeginUndoActions();
+ [[nodiscard]] std::string BeginUndoActions(bool anonymousAllowed = true);
/*! Commit the actions taken since a call to BeginUndoActions.