libfossil
fsl::Db::Transaction Class Reference

A utility to simplify db transaction lifetimes. More...

#include "fossil.hpp"

Public Member Functions

 Transaction (Db &db)
 Calls db.begin(). More...
 
 ~Transaction () throw ()
 If neither commit() nor rollback() have been called, this calls rollback(), otherwise it does nothing. More...
 
void commit ()
 Commits the transaction started by the ctor. More...
 
int level () const throw ()
 Returns the current transaction level for the underlying db. More...
 
void rollback () throw ()
 Rolls back the transaction started by the ctor. More...
 

Detailed Description

A utility to simplify db transaction lifetimes.

Sample usage:

Db::Transaction tr(db);
...lots of stuff which might throw...
tr.commit();

If commit() is not called, the transaction will be rolled back then the Transaction instance destructs.

Definition at line 1058 of file fossil.hpp.

Constructor & Destructor Documentation

fsl::Db::Transaction::Transaction ( Db db)

Calls db.begin().

fsl::Db::Transaction::~Transaction ( )
throw (
)

If neither commit() nor rollback() have been called, this calls rollback(), otherwise it does nothing.

Member Function Documentation

void fsl::Db::Transaction::commit ( )

Commits the transaction started by the ctor.

int fsl::Db::Transaction::level ( ) const
throw (
)

Returns the current transaction level for the underlying db.

void fsl::Db::Transaction::rollback ( )
throw (
)

Rolls back the transaction started by the ctor.


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