Sophie

Sophie

distrib > Fedora > 13 > i386 > media > os > by-pkgid > a062ff4001da3fb37abf8a162b979587 > files > 45

libsqlite3x-devel-20071018-8.fc12.i686.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>libsqlite3x: sqlite3x_transaction.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.9 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
    </ul>
  </div>
<h1>sqlite3x_transaction.cpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment">    Copyright (C) 2004-2005 Cory Nelson</span>
<a name="l00003"></a>00003 <span class="comment"></span>
<a name="l00004"></a>00004 <span class="comment">    This software is provided 'as-is', without any express or implied</span>
<a name="l00005"></a>00005 <span class="comment">    warranty.  In no event will the authors be held liable for any damages</span>
<a name="l00006"></a>00006 <span class="comment">    arising from the use of this software.</span>
<a name="l00007"></a>00007 <span class="comment"></span>
<a name="l00008"></a>00008 <span class="comment">    Permission is granted to anyone to use this software for any purpose,</span>
<a name="l00009"></a>00009 <span class="comment">    including commercial applications, and to alter it and redistribute it</span>
<a name="l00010"></a>00010 <span class="comment">    freely, subject to the following restrictions:</span>
<a name="l00011"></a>00011 <span class="comment"></span>
<a name="l00012"></a>00012 <span class="comment">    1. The origin of this software must not be misrepresented; you must not</span>
<a name="l00013"></a>00013 <span class="comment">        claim that you wrote the original software. If you use this software</span>
<a name="l00014"></a>00014 <span class="comment">        in a product, an acknowledgment in the product documentation would be</span>
<a name="l00015"></a>00015 <span class="comment">        appreciated but is not required.</span>
<a name="l00016"></a>00016 <span class="comment">    2. Altered source versions must be plainly marked as such, and must not be</span>
<a name="l00017"></a>00017 <span class="comment">        misrepresented as being the original software.</span>
<a name="l00018"></a>00018 <span class="comment">    3. This notice may not be removed or altered from any source distribution.</span>
<a name="l00019"></a>00019 <span class="comment">    </span>
<a name="l00020"></a>00020 <span class="comment">    CVS Info :</span>
<a name="l00021"></a>00021 <span class="comment">        $Author: sgbeal $</span>
<a name="l00022"></a>00022 <span class="comment">        $Date: 2007/02/25 23:59:06 $</span>
<a name="l00023"></a>00023 <span class="comment">        $Revision: 1.4 $</span>
<a name="l00024"></a>00024 <span class="comment">*/</span>
<a name="l00025"></a>00025 
<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;sqlite3.h&gt;</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include "sqlite3x.hpp"</span>
<a name="l00028"></a>00028 
<a name="l00029"></a>00029 <span class="keyword">namespace </span>sqlite3x {
<a name="l00030"></a>00030 
<a name="l00031"></a><a class="code" href="classsqlite3x_1_1sqlite3__transaction.html#1bd2d79754adc9413d6ef2f5ba5128e5">00031</a> sqlite3_transaction::sqlite3_transaction(<a class="code" href="classsqlite3x_1_1sqlite3__connection.html" title="Represents a connection to an sqlite3 database.">sqlite3_connection</a> &amp;con, <span class="keywordtype">bool</span> start) : con(con),intrans(false) {
<a name="l00032"></a>00032     <span class="keywordflow">if</span>(start) <a class="code" href="classsqlite3x_1_1sqlite3__transaction.html#a868bbf014de04652d492b7c7d25897f" title="Starts a transaction.">begin</a>();
<a name="l00033"></a>00033 }
<a name="l00034"></a>00034 
<a name="l00035"></a><a class="code" href="classsqlite3x_1_1sqlite3__transaction.html#72bc230cab9552a808ceb9ccabacf6b6">00035</a> <a class="code" href="classsqlite3x_1_1sqlite3__transaction.html#72bc230cab9552a808ceb9ccabacf6b6" title="If destructed before commit() is called, rollback() is called.">sqlite3_transaction::~sqlite3_transaction</a>() {
<a name="l00036"></a>00036     <span class="keywordflow">if</span>(intrans) {
<a name="l00037"></a>00037         <span class="keywordflow">try</span> {
<a name="l00038"></a>00038             <a class="code" href="classsqlite3x_1_1sqlite3__transaction.html#bdcc751fd1132b9ba7d5e461100e52c1" title="Rolls back a transaction with a commit.">rollback</a>();
<a name="l00039"></a>00039         }
<a name="l00040"></a>00040         <span class="keywordflow">catch</span>(...) {
<a name="l00041"></a>00041             <span class="keywordflow">return</span>;
<a name="l00042"></a>00042         }
<a name="l00043"></a>00043     }
<a name="l00044"></a>00044 }
<a name="l00045"></a>00045 
<a name="l00046"></a><a class="code" href="classsqlite3x_1_1sqlite3__transaction.html#a868bbf014de04652d492b7c7d25897f">00046</a> <span class="keywordtype">void</span> <a class="code" href="classsqlite3x_1_1sqlite3__transaction.html#a868bbf014de04652d492b7c7d25897f" title="Starts a transaction.">sqlite3_transaction::begin</a>() {
<a name="l00047"></a>00047     con.<a class="code" href="classsqlite3x_1_1sqlite3__connection.html#3672c874ffecf6f4384bb0f5db34ad97" title="Executes a command which is assumed to have a single step and a void result.">executenonquery</a>(<span class="stringliteral">"begin"</span>);
<a name="l00048"></a>00048     intrans=<span class="keyword">true</span>;
<a name="l00049"></a>00049 }
<a name="l00050"></a>00050 
<a name="l00051"></a><a class="code" href="classsqlite3x_1_1sqlite3__transaction.html#b0bb2c1e3e35a9e5f83d86876163cc02">00051</a> <span class="keywordtype">void</span> <a class="code" href="classsqlite3x_1_1sqlite3__transaction.html#b0bb2c1e3e35a9e5f83d86876163cc02" title="Commits a transaction.">sqlite3_transaction::commit</a>() {
<a name="l00052"></a>00052     con.<a class="code" href="classsqlite3x_1_1sqlite3__connection.html#3672c874ffecf6f4384bb0f5db34ad97" title="Executes a command which is assumed to have a single step and a void result.">executenonquery</a>(<span class="stringliteral">"commit"</span>);
<a name="l00053"></a>00053     intrans=<span class="keyword">false</span>;
<a name="l00054"></a>00054 }
<a name="l00055"></a>00055 
<a name="l00056"></a><a class="code" href="classsqlite3x_1_1sqlite3__transaction.html#bdcc751fd1132b9ba7d5e461100e52c1">00056</a> <span class="keywordtype">void</span> <a class="code" href="classsqlite3x_1_1sqlite3__transaction.html#bdcc751fd1132b9ba7d5e461100e52c1" title="Rolls back a transaction with a commit.">sqlite3_transaction::rollback</a>() {
<a name="l00057"></a>00057     con.<a class="code" href="classsqlite3x_1_1sqlite3__connection.html#3672c874ffecf6f4384bb0f5db34ad97" title="Executes a command which is assumed to have a single step and a void result.">executenonquery</a>(<span class="stringliteral">"rollback"</span>);
<a name="l00058"></a>00058     intrans=<span class="keyword">false</span>;
<a name="l00059"></a>00059 }
<a name="l00060"></a>00060 
<a name="l00061"></a>00061 }
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Sun Jul 26 18:20:37 2009 for libsqlite3x by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address>
</body>
</html>