HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_AutoSqlTransaction Class Reference

#include <UT_SQL.h>

Public Types

using commit_callback_t = UT_Function< bool()>
 

Public Member Functions

 UT_AutoSqlTransaction (UT_SqlDatabase &conn, commit_callback_t &&commit_callback, bool savepoint=true, bool durable=false)
 
 ~UT_AutoSqlTransaction ()
 
 UT_NON_COPYABLE (UT_AutoSqlTransaction)
 
 operator bool () const
 
void commit ()
 
void rollback ()
 
void fail ()
 
const UT_ErrorCodeentryFailure ()
 

Detailed Description

Helper object to optionally create/commit/rollback savepoints and transactions. The user passes a commit callback function which informs the object if the transaction was a success or failure. This callback is called only once on this objects dtor. If it returns true it means the transaction was a success and the transaction/savepoint should be committed. There are helper functions on the object to early commit or rollback when necessary. Generally speaking the user should leave that logic to the dtor and the commit callback.

Definition at line 1536 of file UT_SQL.h.

Member Typedef Documentation

Definition at line 1539 of file UT_SQL.h.

Constructor & Destructor Documentation

UT_AutoSqlTransaction::UT_AutoSqlTransaction ( UT_SqlDatabase conn,
commit_callback_t &&  commit_callback,
bool  savepoint = true,
bool  durable = false 
)
UT_AutoSqlTransaction::~UT_AutoSqlTransaction ( )

Member Function Documentation

void UT_AutoSqlTransaction::commit ( )

Used to early commit the transaction. Generally this should not be used as the transaction exit scope should be used to commit/rollback transactions.

const UT_ErrorCode& UT_AutoSqlTransaction::entryFailure ( )
inline

Definition at line 1566 of file UT_SQL.h.

void UT_AutoSqlTransaction::fail ( )
inline

Flag this transaction as failed. Once the transaction object dtor is called it will rollback the transaction.

Definition at line 1564 of file UT_SQL.h.

UT_AutoSqlTransaction::operator bool ( ) const
inlineexplicit

Definition at line 1549 of file UT_SQL.h.

void UT_AutoSqlTransaction::rollback ( )

Used to early rollback the transaction. Generally this should not be used as the transaction exit scope should be used to commit/rollback transactions.

UT_AutoSqlTransaction::UT_NON_COPYABLE ( UT_AutoSqlTransaction  )

The documentation for this class was generated from the following file: