How to use sqlite for undo / redo functions?

I am writing a C ++ vector drawing application and am considering using sqlite to support my undo / redo function.

Has anyone used sqlite for undo / redo functions? How does it work for you?

Clarification:

I knew about the stack method, I even implemented one application with this approach. The problem I encountered was that after a while it becomes difficult to maintain.

What I meant when using sqlite is that I will bind my entire in-memory data structure to the sqlite database and let sqlite make the difference and revision for me. Speed โ€‹โ€‹should not be a problem if I create a database in memory.

It was an idea, and I was wondering if this could work.

+4
source share
3 answers

It makes sense to use SQLite to undo undo / redo when the SQLite database is an application data file. See the SQLite website for an explanation of how to do this with SQLite triggers.

+10
source

In principle, the undo / redo function can be implemented using the stack: when the user performs an operation, you push an object on the stack that represents the delta between the state before and after the operation, and when you cancel, you โ€œexpandโ€ the delta. Since each operation that the user creates creates a new delta object on the stack, this may be because sqlite is not your choice of technology, because it may be too slow. I would recommend considering just storing the undo / redo information in memory and linearizing it on disk only if you want to save the undo / redo history.

+2
source

Take a look at the Memento Design Pattern .

0
source

All Articles