TDocument provides a number of functions that you can use to help protect your data:
- TDocument::IsDirty() first checks to see whether the document itself is dirty (modified but not updated) by checking the state of the data member DirtyFlag. It then checks whether any child documents are dirty, then whether any views are dirty. IsDirty returns true if any children or views are dirty.
- TDocument::IsOpen() checks to see whether the document is held open or has any streams in its stream list. If the document is not open, IsOpen returns false. Otherwise, IsOpen returns .
- TDocument::Commit() commits to storage any changes to your data. Once you have called Commit, you cannot back out any changes made. The TDocument version of this function checks any child documents and commits their changes. If any child document returns false, the commit is aborted and Commit returns false. All child documents must return true before Commit commits its own data. After all child documents have returned true, Commit flushes all the views for operations that might have taken place since the document last checked the views. Data in the document is updated according to the changes in the views and then saved. Commit then returns true.
- TDocument::Revert() performs the opposite function from Commit. Instead of updating changes and saving the data, Revert clears any changes that have been made since the last time the data was committed. Revert also polls any child documents and aborts if any of the children return false. If all operations are successful, Revert returns true.
See Also