sqlite3x_transaction.cpp

Go to the documentation of this file.
00001 /*
00002         Copyright (C) 2004-2005 Cory Nelson
00003 
00004         This software is provided 'as-is', without any express or implied
00005         warranty.  In no event will the authors be held liable for any damages
00006         arising from the use of this software.
00007 
00008         Permission is granted to anyone to use this software for any purpose,
00009         including commercial applications, and to alter it and redistribute it
00010         freely, subject to the following restrictions:
00011 
00012         1. The origin of this software must not be misrepresented; you must not
00013                 claim that you wrote the original software. If you use this software
00014                 in a product, an acknowledgment in the product documentation would be
00015                 appreciated but is not required.
00016         2. Altered source versions must be plainly marked as such, and must not be
00017                 misrepresented as being the original software.
00018         3. This notice may not be removed or altered from any source distribution.
00019 
00020         CVS Info :
00021                 $Author: phrostbyte $
00022                 $Date: 2005/06/16 20:46:40 $
00023                 $Revision: 1.1 $
00024 */
00025 
00026 #include <sqlite3.h>
00027 #include "sqlite3x.hpp"
00028 
00029 namespace sqlite3x
00030 {
00031 
00032 sqlite3_transaction::sqlite3_transaction(sqlite3_connection &con, bool start) : con(con),intrans(false)
00033 {
00034   if (start) begin();
00035 }
00036 
00037 sqlite3_transaction::~sqlite3_transaction()
00038 {
00039   if (intrans)
00040   {
00041     try
00042     {
00043       rollback();
00044     }
00045     catch (...)
00046     {
00047       return;
00048     }
00049   }
00050 }
00051 
00052 void sqlite3_transaction::begin()
00053 {
00054   con.executenonquery("begin;");
00055   intrans=true;
00056 }
00057 
00058 void sqlite3_transaction::commit()
00059 {
00060   con.executenonquery("commit;");
00061   intrans=false;
00062 }
00063 
00064 void sqlite3_transaction::rollback()
00065 {
00066   con.executenonquery("rollback;");
00067   intrans=false;
00068 }
00069 
00070 }

Generated on Tue Sep 25 19:23:00 2007 for libzypp by  doxygen 1.5.3