X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/e3d460c9de4426da6c630c3ae3f46173a99f82d8..7e6b461318c8a779d91381531435a68ee4e8b6ed:/OSX/libsecurity_utilities/lib/CSPDLTransaction.h diff --git a/OSX/libsecurity_utilities/lib/CSPDLTransaction.h b/OSX/libsecurity_utilities/lib/CSPDLTransaction.h index 2a5adce3..b93c8a87 100644 --- a/OSX/libsecurity_utilities/lib/CSPDLTransaction.h +++ b/OSX/libsecurity_utilities/lib/CSPDLTransaction.h @@ -24,19 +24,18 @@ #ifndef _H_CSPDLTRANSACTION #define _H_CSPDLTRANSACTION +#include + +#if TARGET_OS_OSX + #include // // This class performs a transaction on a CSPDL database. // -// It will commit when: -// -// 1) success() has been called -// 2) the object goes out of scope OR finalize() is called +// If commit() has not yet been called when the object goes out of scope, the transaction will roll back instead (exceptions will be swallowed). // -// if success() has not been called, the transaction will roll back instead. -// -// You can nest transaction objects, but I don't really suggest it... +// Nesting transactions will likely work, but isn't recommended. // class DLTransaction { public: @@ -45,18 +44,22 @@ public: ~DLTransaction(); // Everything has gone right; this transaction will commit. - // If you don't call this, the transaction will roll back. - void success(); - - // Commit or rollback as appropriate - void finalize(); + // If you don't call this, the transaction will roll back when the object goes out of scope. + // Might throw on error. + void commit(); protected: DLTransaction(); - // Actually toggle autocommit using the dldbh + // Note: disables autocommit using the dldbh void initialize(); + // Call rollback if necessary. Never throws. + void finalize(); + + // Rolls back database transactions. Might throw. + void rollback(); + CSSM_DL_DB_HANDLE mDldbh; bool mSuccess; @@ -74,4 +77,6 @@ private: Security::CssmClient::Db& mDb; }; +#endif //TARGET_OS_OSX + #endif // _H_CSPDLTRANSACTION