<!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_command.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 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 List</span></a></li> </ul> </div> <h1>sqlite3x_command.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"> Copyright (C) 2006 stephan beal</span> <a name="l00004"></a>00004 <span class="comment"></span> <a name="l00005"></a>00005 <span class="comment"> This software is provided 'as-is', without any express or implied</span> <a name="l00006"></a>00006 <span class="comment"> warranty. In no event will the authors be held liable for any damages</span> <a name="l00007"></a>00007 <span class="comment"> arising from the use of this software.</span> <a name="l00008"></a>00008 <span class="comment"></span> <a name="l00009"></a>00009 <span class="comment"> Permission is granted to anyone to use this software for any purpose,</span> <a name="l00010"></a>00010 <span class="comment"> including commercial applications, and to alter it and redistribute it</span> <a name="l00011"></a>00011 <span class="comment"> freely, subject to the following restrictions:</span> <a name="l00012"></a>00012 <span class="comment"></span> <a name="l00013"></a>00013 <span class="comment"> 1. The origin of this software must not be misrepresented; you must not</span> <a name="l00014"></a>00014 <span class="comment"> claim that you wrote the original software. If you use this software</span> <a name="l00015"></a>00015 <span class="comment"> in a product, an acknowledgment in the product documentation would be</span> <a name="l00016"></a>00016 <span class="comment"> appreciated but is not required.</span> <a name="l00017"></a>00017 <span class="comment"> 2. Altered source versions must be plainly marked as such, and must not be</span> <a name="l00018"></a>00018 <span class="comment"> misrepresented as being the original software.</span> <a name="l00019"></a>00019 <span class="comment"> 3. This notice may not be removed or altered from any source distribution.</span> <a name="l00020"></a>00020 <span class="comment"> </span> <a name="l00021"></a>00021 <span class="comment">*/</span> <a name="l00022"></a>00022 <a name="l00023"></a>00023 <span class="preprocessor">#include <sqlite3.h></span> <a name="l00024"></a>00024 <span class="preprocessor">#include "sqlite3x.hpp"</span> <a name="l00025"></a>00025 <span class="preprocessor">#include <cstring></span> <span class="comment">// strlen()</span> <a name="l00026"></a>00026 <span class="preprocessor">#include <iostream></span> <span class="comment">// only for debuggin</span> <a name="l00027"></a>00027 <span class="keyword">namespace </span>sqlite3x { <a name="l00028"></a>00028 <a name="l00029"></a><a class="code" href="classsqlite3x_1_1sqlite3__command.html#01e1952fbc8fac84e49de2cc33abe3ae">00029</a> sqlite3_command::sqlite3_command(<a class="code" href="classsqlite3x_1_1sqlite3__connection.html" title="Represents a connection to an sqlite3 database.">sqlite3_connection</a> &con) <a name="l00030"></a>00030 : con(con),stmt(0),refs(0),argc(0) <a name="l00031"></a>00031 { <a name="l00032"></a>00032 } <a name="l00033"></a>00033 <a name="l00034"></a>00034 <a name="l00035"></a><a class="code" href="classsqlite3x_1_1sqlite3__command.html#569cb965693fd2f2a6ebcf5910252528">00035</a> sqlite3_command::sqlite3_command(<a class="code" href="classsqlite3x_1_1sqlite3__connection.html" title="Represents a connection to an sqlite3 database.">sqlite3_connection</a> &con, <span class="keyword">const</span> std::string &sql) <a name="l00036"></a>00036 : con(con),stmt(0),refs(0),argc(0) <a name="l00037"></a>00037 { <a name="l00038"></a>00038 this-><a class="code" href="classsqlite3x_1_1sqlite3__command.html#6cb5c7c51fb3b47796a09466bfb9594f" title="Prepares this statement or throws on error.">prepare</a>( sql ); <a name="l00039"></a>00039 } <a name="l00040"></a>00040 <a name="l00041"></a><a class="code" href="classsqlite3x_1_1sqlite3__command.html#16c2fe50bea3bd18d7471a9f7f717d5f">00041</a> sqlite3_command::sqlite3_command(<a class="code" href="classsqlite3x_1_1sqlite3__connection.html" title="Represents a connection to an sqlite3 database.">sqlite3_connection</a> &con, <span class="keywordtype">char</span> <span class="keyword">const</span> * sql, <span class="keywordtype">size_t</span> len ) <a name="l00042"></a>00042 : con(con),stmt(0),refs(0),argc(0) <a name="l00043"></a>00043 { <a name="l00044"></a>00044 this-><a class="code" href="classsqlite3x_1_1sqlite3__command.html#6cb5c7c51fb3b47796a09466bfb9594f" title="Prepares this statement or throws on error.">prepare</a>( sql, static_cast<int>( len ) ); <a name="l00045"></a>00045 } <a name="l00046"></a>00046 <a name="l00047"></a>00047 <span class="preprocessor">#if SQLITE3X_USE_WCHAR</span> <a name="l00048"></a>00048 <span class="preprocessor"></span> sqlite3_command::sqlite3_command(<a class="code" href="classsqlite3x_1_1sqlite3__connection.html" title="Represents a connection to an sqlite3 database.">sqlite3_connection</a> &con, <span class="keyword">const</span> std::wstring &sql) : con(con),stmt(0),refs(0),argc(0) { <a name="l00049"></a>00049 <span class="keyword">const</span> <span class="keywordtype">void</span> *tail=NULL; <a name="l00050"></a>00050 <span class="keywordtype">int</span> rc = <a name="l00051"></a>00051 <span class="preprocessor">#if (SQLITE_VERSION_NUMBER >= 3003009)</span> <a name="l00052"></a>00052 <span class="preprocessor"></span> sqlite3_prepare16_v2 <a name="l00053"></a>00053 <span class="preprocessor">#else</span> <a name="l00054"></a>00054 <span class="preprocessor"></span> sqlite3_prepare16 <a name="l00055"></a>00055 <span class="preprocessor">#endif</span> <a name="l00056"></a>00056 <span class="preprocessor"></span> (con.<a class="code" href="classsqlite3x_1_1sqlite3__connection.html#53f4dc160f2ecdd115216241cb21fa23" title="Returns a handle to the underlying sqlite3 database.">db</a>(), sql.data(), (int)sql.length()*2, &this->stmt, &tail); <a name="l00057"></a>00057 <span class="keywordflow">if</span>( SQLITE_OK != rc ) <a name="l00058"></a>00058 { <a name="l00059"></a>00059 <span class="keywordflow">throw</span> <a class="code" href="classsqlite3x_1_1database__error.html" title="Exception type used by the sqlite3x classes.">database_error</a>(<span class="stringliteral">"sqlite3_command::prepare failed. Reason=[%s]"</span>, <a name="l00060"></a>00060 sqlite3_errmsg( this->con.<a class="code" href="classsqlite3x_1_1sqlite3__connection.html#53f4dc160f2ecdd115216241cb21fa23" title="Returns a handle to the underlying sqlite3 database.">db</a>() ) ); <a name="l00061"></a>00061 } <a name="l00062"></a>00062 this->argc=sqlite3_column_count(this->stmt); <a name="l00063"></a>00063 } <a name="l00064"></a>00064 <span class="preprocessor">#endif</span> <a name="l00065"></a>00065 <span class="preprocessor"></span> <a name="l00066"></a><a class="code" href="classsqlite3x_1_1sqlite3__command.html#6cb5c7c51fb3b47796a09466bfb9594f">00066</a> <span class="keywordtype">void</span> <a class="code" href="classsqlite3x_1_1sqlite3__command.html#6cb5c7c51fb3b47796a09466bfb9594f" title="Prepares this statement or throws on error.">sqlite3_command::prepare</a>( <span class="keywordtype">char</span> <span class="keyword">const</span> * sql, <span class="keywordtype">int</span> len ) <a name="l00067"></a>00067 { <a name="l00068"></a>00068 <span class="keywordflow">if</span>( this->stmt ) this-><a class="code" href="classsqlite3x_1_1sqlite3__command.html#72a99a3a5b4036a1410fd375ff6b79da" title="Finalizes this statement.">finalize</a>(); <a name="l00069"></a>00069 <span class="keyword">const</span> <span class="keywordtype">char</span> *tail=NULL; <a name="l00070"></a>00070 <span class="keywordtype">int</span> rc = <a name="l00071"></a>00071 <span class="preprocessor">#if (SQLITE_VERSION_NUMBER >= 3003009)</span> <a name="l00072"></a>00072 <span class="preprocessor"></span> sqlite3_prepare_v2 <a name="l00073"></a>00073 <span class="preprocessor">#else</span> <a name="l00074"></a>00074 <span class="preprocessor"></span> sqlite3_prepare <a name="l00075"></a>00075 <span class="preprocessor">#endif</span> <a name="l00076"></a>00076 <span class="preprocessor"></span> ( this->con.<a class="code" href="classsqlite3x_1_1sqlite3__connection.html#53f4dc160f2ecdd115216241cb21fa23" title="Returns a handle to the underlying sqlite3 database.">db</a>(), sql, len, &(this->stmt), &tail ); <a name="l00077"></a>00077 <span class="keywordflow">if</span>( SQLITE_OK != rc ) <a name="l00078"></a>00078 { <a name="l00079"></a>00079 <span class="keywordflow">throw</span> <a class="code" href="classsqlite3x_1_1database__error.html" title="Exception type used by the sqlite3x classes.">database_error</a>(<span class="stringliteral">"sqlite3_command::prepare([%s]) failed. Reason=[%s]"</span>, <a name="l00080"></a>00080 sql, sqlite3_errmsg( this->con.<a class="code" href="classsqlite3x_1_1sqlite3__connection.html#53f4dc160f2ecdd115216241cb21fa23" title="Returns a handle to the underlying sqlite3 database.">db</a>() ) ); <a name="l00081"></a>00081 } <a name="l00082"></a>00082 this->argc=sqlite3_column_count(this->stmt); <a name="l00083"></a>00083 } <a name="l00084"></a>00084 <a name="l00085"></a><a class="code" href="classsqlite3x_1_1sqlite3__command.html#2542bf4c6ebcf06ddd91b2ca8cf2fad0">00085</a> <span class="keywordtype">void</span> <a class="code" href="classsqlite3x_1_1sqlite3__command.html#6cb5c7c51fb3b47796a09466bfb9594f" title="Prepares this statement or throws on error.">sqlite3_command::prepare</a>( std::string <span class="keyword">const</span> & sql ) <a name="l00086"></a>00086 { <a name="l00087"></a>00087 this-><a class="code" href="classsqlite3x_1_1sqlite3__command.html#6cb5c7c51fb3b47796a09466bfb9594f" title="Prepares this statement or throws on error.">prepare</a>( sql.c_str(), <span class="keyword">static_cast<</span><span class="keywordtype">int</span><span class="keyword">></span>( sql.size()) ); <a name="l00088"></a>00088 } <a name="l00089"></a>00089 <a name="l00090"></a>00090 <a name="l00091"></a><a class="code" href="classsqlite3x_1_1sqlite3__command.html#101793d34e59d89869106f644b285698">00091</a> <a class="code" href="classsqlite3x_1_1sqlite3__command.html#101793d34e59d89869106f644b285698" title="Cleans up any resources in use by this object.">sqlite3_command::~sqlite3_command</a>() { <a name="l00092"></a>00092 <span class="keywordflow">try</span> <a name="l00093"></a>00093 { <a name="l00094"></a>00094 this-><a class="code" href="classsqlite3x_1_1sqlite3__command.html#72a99a3a5b4036a1410fd375ff6b79da" title="Finalizes this statement.">finalize</a>(); <a name="l00095"></a>00095 } <a name="l00096"></a>00096 <span class="keywordflow">catch</span>(...) <a name="l00097"></a>00097 { <a name="l00098"></a>00098 <span class="comment">// std::cout << "sqlite3_command::~sqlite3_command() ignoring an exception!\n";</span> <a name="l00099"></a>00099 <span class="comment">// silently ignore</span> <a name="l00100"></a>00100 } <a name="l00101"></a>00101 } <a name="l00102"></a>00102 <a name="l00103"></a><a class="code" href="classsqlite3x_1_1sqlite3__command.html#72a99a3a5b4036a1410fd375ff6b79da">00103</a> <span class="keywordtype">void</span> <a class="code" href="classsqlite3x_1_1sqlite3__command.html#72a99a3a5b4036a1410fd375ff6b79da" title="Finalizes this statement.">sqlite3_command::finalize</a>() <a name="l00104"></a>00104 { <a name="l00105"></a>00105 <span class="keywordflow">if</span>( this->stmt ) <a name="l00106"></a>00106 { <a name="l00107"></a>00107 <span class="keywordflow">if</span>(sqlite3_finalize(this->stmt)!=SQLITE_OK) <a name="l00108"></a>00108 <span class="keywordflow">throw</span> <a class="code" href="classsqlite3x_1_1database__error.html" title="Exception type used by the sqlite3x classes.">database_error</a>(this->con); <a name="l00109"></a>00109 this->stmt = 0; <a name="l00110"></a>00110 } <a name="l00111"></a>00111 } <a name="l00112"></a>00112 <a name="l00113"></a><a class="code" href="classsqlite3x_1_1sqlite3__command.html#eb06bdb6c852a5059e85eb0cf5b151fd">00113</a> <span class="keywordtype">void</span> <a class="code" href="classsqlite3x_1_1sqlite3__command.html#eb06bdb6c852a5059e85eb0cf5b151fd" title="Binds NULL to the given index.">sqlite3_command::bind</a>(<span class="keywordtype">int</span> index) { <a name="l00114"></a>00114 <span class="keywordflow">if</span>(sqlite3_bind_null(this->stmt, index)!=SQLITE_OK) <a name="l00115"></a>00115 <span class="keywordflow">throw</span> <a class="code" href="classsqlite3x_1_1database__error.html" title="Exception type used by the sqlite3x classes.">database_error</a>(this->con); <a name="l00116"></a>00116 } <a name="l00117"></a>00117 <a name="l00118"></a><a class="code" href="classsqlite3x_1_1sqlite3__command.html#76139e36eb706860d78c8e766cfd2abf">00118</a> <span class="keywordtype">void</span> <a class="code" href="classsqlite3x_1_1sqlite3__command.html#eb06bdb6c852a5059e85eb0cf5b151fd" title="Binds NULL to the given index.">sqlite3_command::bind</a>(<span class="keywordtype">int</span> index, <span class="keywordtype">int</span> data) { <a name="l00119"></a>00119 <span class="keywordflow">if</span>(sqlite3_bind_int(this->stmt, index, data)!=SQLITE_OK) <a name="l00120"></a>00120 <span class="keywordflow">throw</span> <a class="code" href="classsqlite3x_1_1database__error.html" title="Exception type used by the sqlite3x classes.">database_error</a>(this->con); <a name="l00121"></a>00121 } <a name="l00122"></a>00122 <a name="l00123"></a><a class="code" href="classsqlite3x_1_1sqlite3__command.html#c7662e62f0a2ee3c1123b1227fc0ee21">00123</a> <span class="keywordtype">void</span> <a class="code" href="classsqlite3x_1_1sqlite3__command.html#eb06bdb6c852a5059e85eb0cf5b151fd" title="Binds NULL to the given index.">sqlite3_command::bind</a>(<span class="keywordtype">int</span> index, <a class="code" href="namespacesqlite3x.html#006a0e90d7b40685893f6f6f766d9b48" title="64-bit integer type used by this code.">int64_t</a> data) { <a name="l00124"></a>00124 <span class="keywordflow">if</span>(sqlite3_bind_int64(this->stmt, index, data)!=SQLITE_OK) <a name="l00125"></a>00125 <span class="keywordflow">throw</span> <a class="code" href="classsqlite3x_1_1database__error.html" title="Exception type used by the sqlite3x classes.">database_error</a>(this->con); <a name="l00126"></a>00126 } <a name="l00127"></a>00127 <a name="l00128"></a><a class="code" href="classsqlite3x_1_1sqlite3__command.html#6ab01cd42337ec41c9ddbf2fcaaf499d">00128</a> <span class="keywordtype">void</span> <a class="code" href="classsqlite3x_1_1sqlite3__command.html#eb06bdb6c852a5059e85eb0cf5b151fd" title="Binds NULL to the given index.">sqlite3_command::bind</a>(<span class="keywordtype">int</span> index, <span class="keywordtype">double</span> data) { <a name="l00129"></a>00129 <span class="keywordflow">if</span>(sqlite3_bind_double(this->stmt, index, data)!=SQLITE_OK) <a name="l00130"></a>00130 <span class="keywordflow">throw</span> <a class="code" href="classsqlite3x_1_1database__error.html" title="Exception type used by the sqlite3x classes.">database_error</a>(this->con); <a name="l00131"></a>00131 } <a name="l00132"></a>00132 <a name="l00133"></a><a class="code" href="classsqlite3x_1_1sqlite3__command.html#04d9c8fa647c448d8dcafe88b70c55ec">00133</a> <span class="keywordtype">void</span> <a class="code" href="classsqlite3x_1_1sqlite3__command.html#eb06bdb6c852a5059e85eb0cf5b151fd" title="Binds NULL to the given index.">sqlite3_command::bind</a>(<span class="keywordtype">int</span> index, <span class="keyword">const</span> <span class="keywordtype">char</span> *data, <span class="keywordtype">int</span> datalen) { <a name="l00134"></a>00134 <span class="keywordflow">if</span>(sqlite3_bind_text(this->stmt, index, data, <a name="l00135"></a>00135 static_cast<int>( <a name="l00136"></a>00136 ((-1==datalen) <a name="l00137"></a>00137 ? std::strlen(data) <a name="l00138"></a>00138 : datalen) <a name="l00139"></a>00139 ), <a name="l00140"></a>00140 SQLITE_TRANSIENT)!=SQLITE_OK) <a name="l00141"></a>00141 <span class="keywordflow">throw</span> <a class="code" href="classsqlite3x_1_1database__error.html" title="Exception type used by the sqlite3x classes.">database_error</a>(this->con); <a name="l00142"></a>00142 } <a name="l00143"></a>00143 <a name="l00144"></a>00144 <span class="preprocessor">#if SQLITE3X_USE_WCHAR</span> <a name="l00145"></a>00145 <span class="preprocessor"></span> <span class="keywordtype">void</span> <a class="code" href="classsqlite3x_1_1sqlite3__command.html#eb06bdb6c852a5059e85eb0cf5b151fd" title="Binds NULL to the given index.">sqlite3_command::bind</a>(<span class="keywordtype">int</span> index, <span class="keyword">const</span> <span class="keywordtype">wchar_t</span> *data, <span class="keywordtype">int</span> datalen) { <a name="l00146"></a>00146 <span class="keywordflow">if</span>(sqlite3_bind_text16(this->stmt, index, data, datalen, SQLITE_TRANSIENT)!=SQLITE_OK) <a name="l00147"></a>00147 <span class="keywordflow">throw</span> <a class="code" href="classsqlite3x_1_1database__error.html" title="Exception type used by the sqlite3x classes.">database_error</a>(this->con); <a name="l00148"></a>00148 } <a name="l00149"></a>00149 <span class="preprocessor">#endif</span> <a name="l00150"></a>00150 <span class="preprocessor"></span> <a name="l00151"></a><a class="code" href="classsqlite3x_1_1sqlite3__command.html#f591a4949f5e14e26dbdede59769f346">00151</a> <span class="keywordtype">void</span> <a class="code" href="classsqlite3x_1_1sqlite3__command.html#eb06bdb6c852a5059e85eb0cf5b151fd" title="Binds NULL to the given index.">sqlite3_command::bind</a>(<span class="keywordtype">int</span> index, <span class="keyword">const</span> <span class="keywordtype">void</span> *data, <span class="keywordtype">int</span> datalen) { <a name="l00152"></a>00152 <span class="keywordflow">if</span>(sqlite3_bind_blob(this->stmt, index, data, datalen, SQLITE_TRANSIENT)!=SQLITE_OK) <a name="l00153"></a>00153 <span class="keywordflow">throw</span> <a class="code" href="classsqlite3x_1_1database__error.html" title="Exception type used by the sqlite3x classes.">database_error</a>(this->con); <a name="l00154"></a>00154 } <a name="l00155"></a>00155 <a name="l00156"></a><a class="code" href="classsqlite3x_1_1sqlite3__command.html#850fad99944754690462200650d44a60">00156</a> <span class="keywordtype">void</span> <a class="code" href="classsqlite3x_1_1sqlite3__command.html#eb06bdb6c852a5059e85eb0cf5b151fd" title="Binds NULL to the given index.">sqlite3_command::bind</a>(<span class="keywordtype">int</span> index, <span class="keyword">const</span> std::string &data) { <a name="l00157"></a>00157 <span class="keywordflow">if</span>(sqlite3_bind_text(this->stmt, index, data.data(), (int)data.length(), SQLITE_TRANSIENT)!=SQLITE_OK) <a name="l00158"></a>00158 <span class="keywordflow">throw</span> <a class="code" href="classsqlite3x_1_1database__error.html" title="Exception type used by the sqlite3x classes.">database_error</a>(this->con); <a name="l00159"></a>00159 } <a name="l00160"></a>00160 <a name="l00161"></a>00161 <span class="preprocessor">#if SQLITE3X_USE_WCHAR</span> <a name="l00162"></a>00162 <span class="preprocessor"></span> <span class="keywordtype">void</span> <a class="code" href="classsqlite3x_1_1sqlite3__command.html#eb06bdb6c852a5059e85eb0cf5b151fd" title="Binds NULL to the given index.">sqlite3_command::bind</a>(<span class="keywordtype">int</span> index, <span class="keyword">const</span> std::wstring &data) { <a name="l00163"></a>00163 <span class="keywordflow">if</span>(sqlite3_bind_text16(this->stmt, index, data.data(), (int)data.length()*2, SQLITE_TRANSIENT)!=SQLITE_OK) <a name="l00164"></a>00164 <span class="keywordflow">throw</span> <a class="code" href="classsqlite3x_1_1database__error.html" title="Exception type used by the sqlite3x classes.">database_error</a>(this->con); <a name="l00165"></a>00165 } <a name="l00166"></a>00166 <span class="preprocessor">#endif</span> <a name="l00167"></a>00167 <span class="preprocessor"></span> <a name="l00168"></a><a class="code" href="classsqlite3x_1_1sqlite3__command.html#aa821db4faab5a3577f3cf55ed4f6906">00168</a> <a class="code" href="classsqlite3x_1_1sqlite3__cursor.html" title="A type for reading results from an sqlite3_command.">sqlite3_cursor</a> <a class="code" href="classsqlite3x_1_1sqlite3__command.html#aa821db4faab5a3577f3cf55ed4f6906" title="Executes the query and returns a cursor object which can be used to iterate over...">sqlite3_command::executecursor</a>() { <a name="l00169"></a>00169 <span class="keywordflow">return</span> <a class="code" href="classsqlite3x_1_1sqlite3__cursor.html" title="A type for reading results from an sqlite3_command.">sqlite3_cursor</a>(*<span class="keyword">this</span>); <a name="l00170"></a>00170 } <a name="l00171"></a>00171 <a name="l00172"></a><a class="code" href="classsqlite3x_1_1sqlite3__command.html#1ff0b4402b67b71ba2964ab30675b618">00172</a> <span class="keywordtype">void</span> <a class="code" href="classsqlite3x_1_1sqlite3__command.html#1ff0b4402b67b71ba2964ab30675b618" title="Executes the query and provides no way to get the results.">sqlite3_command::executenonquery</a>() { <a name="l00173"></a>00173 this-><a class="code" href="classsqlite3x_1_1sqlite3__command.html#aa821db4faab5a3577f3cf55ed4f6906" title="Executes the query and returns a cursor object which can be used to iterate over...">executecursor</a>().<a class="code" href="classsqlite3x_1_1sqlite3__cursor.html#b2c806b7049f1715b8e6f4106aa6af4b" title="Steps one step through the sql result set and returns true on SQLITE_ROW, false on...">step</a>(); <a name="l00174"></a>00174 } <a name="l00175"></a>00175 <a name="l00176"></a><a class="code" href="classsqlite3x_1_1sqlite3__command.html#0320a1c57316eb9c368e4ea6730653cd">00176</a> <span class="keywordtype">int</span> <a class="code" href="classsqlite3x_1_1sqlite3__command.html#0320a1c57316eb9c368e4ea6730653cd" title="Executes the query, which is expected to have an integer field as the first result...">sqlite3_command::executeint</a>() { <a name="l00177"></a>00177 <a class="code" href="classsqlite3x_1_1sqlite3__cursor.html" title="A type for reading results from an sqlite3_command.">sqlite3_cursor</a> reader=this-><a class="code" href="classsqlite3x_1_1sqlite3__command.html#aa821db4faab5a3577f3cf55ed4f6906" title="Executes the query and returns a cursor object which can be used to iterate over...">executecursor</a>(); <a name="l00178"></a>00178 <span class="keywordflow">if</span>(!reader.<a class="code" href="classsqlite3x_1_1sqlite3__cursor.html#b2c806b7049f1715b8e6f4106aa6af4b" title="Steps one step through the sql result set and returns true on SQLITE_ROW, false on...">step</a>()) <span class="keywordflow">throw</span> <a class="code" href="classsqlite3x_1_1database__error.html" title="Exception type used by the sqlite3x classes.">database_error</a>(<span class="stringliteral">"nothing to read"</span>); <a name="l00179"></a>00179 <span class="keywordflow">return</span> reader.<a class="code" href="classsqlite3x_1_1sqlite3__cursor.html#0c8263dc2db4054e38f4479a70a8dec8" title="Gets the integer value at the given field number.">getint</a>(0); <a name="l00180"></a>00180 } <a name="l00181"></a>00181 <a name="l00182"></a><a class="code" href="classsqlite3x_1_1sqlite3__command.html#d2854f1b3f8c25d36018fab98d2ac064">00182</a> <a class="code" href="namespacesqlite3x.html#006a0e90d7b40685893f6f6f766d9b48" title="64-bit integer type used by this code.">int64_t</a> <a class="code" href="classsqlite3x_1_1sqlite3__command.html#d2854f1b3f8c25d36018fab98d2ac064" title="Executes the query, which is expected to have a (int64_t) field as the first result...">sqlite3_command::executeint64</a>() { <a name="l00183"></a>00183 <a class="code" href="classsqlite3x_1_1sqlite3__cursor.html" title="A type for reading results from an sqlite3_command.">sqlite3_cursor</a> reader=this-><a class="code" href="classsqlite3x_1_1sqlite3__command.html#aa821db4faab5a3577f3cf55ed4f6906" title="Executes the query and returns a cursor object which can be used to iterate over...">executecursor</a>(); <a name="l00184"></a>00184 <span class="keywordflow">if</span>(!reader.<a class="code" href="classsqlite3x_1_1sqlite3__cursor.html#b2c806b7049f1715b8e6f4106aa6af4b" title="Steps one step through the sql result set and returns true on SQLITE_ROW, false on...">step</a>()) <span class="keywordflow">throw</span> <a class="code" href="classsqlite3x_1_1database__error.html" title="Exception type used by the sqlite3x classes.">database_error</a>(<span class="stringliteral">"nothing to read"</span>); <a name="l00185"></a>00185 <span class="keywordflow">return</span> reader.<a class="code" href="classsqlite3x_1_1sqlite3__cursor.html#1f78949a7d2dd96b8677964368b2dc71" title="Gets the (int64_t) value at the given field number.">getint64</a>(0); <a name="l00186"></a>00186 } <a name="l00187"></a>00187 <a name="l00188"></a><a class="code" href="classsqlite3x_1_1sqlite3__command.html#c564797747b5d5a4d40ed34f2903fc50">00188</a> <span class="keywordtype">double</span> <a class="code" href="classsqlite3x_1_1sqlite3__command.html#c564797747b5d5a4d40ed34f2903fc50" title="Executes the query, which is expected to have a double field as the first result...">sqlite3_command::executedouble</a>() { <a name="l00189"></a>00189 <a class="code" href="classsqlite3x_1_1sqlite3__cursor.html" title="A type for reading results from an sqlite3_command.">sqlite3_cursor</a> reader=this-><a class="code" href="classsqlite3x_1_1sqlite3__command.html#aa821db4faab5a3577f3cf55ed4f6906" title="Executes the query and returns a cursor object which can be used to iterate over...">executecursor</a>(); <a name="l00190"></a>00190 <span class="keywordflow">if</span>(!reader.<a class="code" href="classsqlite3x_1_1sqlite3__cursor.html#b2c806b7049f1715b8e6f4106aa6af4b" title="Steps one step through the sql result set and returns true on SQLITE_ROW, false on...">step</a>()) <span class="keywordflow">throw</span> <a class="code" href="classsqlite3x_1_1database__error.html" title="Exception type used by the sqlite3x classes.">database_error</a>(<span class="stringliteral">"nothing to read"</span>); <a name="l00191"></a>00191 <span class="keywordflow">return</span> reader.<a class="code" href="classsqlite3x_1_1sqlite3__cursor.html#c6a6487bb07c7a7a864e9c971f4c773f" title="Gets the double value at the given field number.">getdouble</a>(0); <a name="l00192"></a>00192 } <a name="l00193"></a>00193 <a name="l00194"></a><a class="code" href="classsqlite3x_1_1sqlite3__command.html#b61e9e71f8c83341eb500b640cae0284">00194</a> <span class="keywordtype">char</span> <span class="keyword">const</span> * <a class="code" href="classsqlite3x_1_1sqlite3__command.html#cf1b4853a7de426d9fa81332b1081d80" title="Executes the query, which is expected to have a string or blob field as the first...">sqlite3_command::executestring</a>( <span class="keywordtype">int</span> & size ) { <a name="l00195"></a>00195 <a class="code" href="classsqlite3x_1_1sqlite3__cursor.html" title="A type for reading results from an sqlite3_command.">sqlite3_cursor</a> reader=this-><a class="code" href="classsqlite3x_1_1sqlite3__command.html#aa821db4faab5a3577f3cf55ed4f6906" title="Executes the query and returns a cursor object which can be used to iterate over...">executecursor</a>(); <a name="l00196"></a>00196 <span class="keywordflow">if</span>(!reader.<a class="code" href="classsqlite3x_1_1sqlite3__cursor.html#b2c806b7049f1715b8e6f4106aa6af4b" title="Steps one step through the sql result set and returns true on SQLITE_ROW, false on...">step</a>()) <span class="keywordflow">throw</span> <a class="code" href="classsqlite3x_1_1database__error.html" title="Exception type used by the sqlite3x classes.">database_error</a>(<span class="stringliteral">"nothing to read"</span>); <a name="l00197"></a>00197 <span class="keywordflow">return</span> reader.<a class="code" href="classsqlite3x_1_1sqlite3__cursor.html#2d323375d5cf1a0c3efc915179558db3" title="Gets the string value at the given field number.">getstring</a>( 0, size ); <a name="l00198"></a>00198 } <a name="l00199"></a>00199 <a name="l00200"></a><a class="code" href="classsqlite3x_1_1sqlite3__command.html#cf1b4853a7de426d9fa81332b1081d80">00200</a> std::string <a class="code" href="classsqlite3x_1_1sqlite3__command.html#cf1b4853a7de426d9fa81332b1081d80" title="Executes the query, which is expected to have a string or blob field as the first...">sqlite3_command::executestring</a>() { <a name="l00201"></a>00201 <a class="code" href="classsqlite3x_1_1sqlite3__cursor.html" title="A type for reading results from an sqlite3_command.">sqlite3_cursor</a> reader=this-><a class="code" href="classsqlite3x_1_1sqlite3__command.html#aa821db4faab5a3577f3cf55ed4f6906" title="Executes the query and returns a cursor object which can be used to iterate over...">executecursor</a>(); <a name="l00202"></a>00202 <span class="keywordflow">if</span>(!reader.<a class="code" href="classsqlite3x_1_1sqlite3__cursor.html#b2c806b7049f1715b8e6f4106aa6af4b" title="Steps one step through the sql result set and returns true on SQLITE_ROW, false on...">step</a>()) <span class="keywordflow">throw</span> <a class="code" href="classsqlite3x_1_1database__error.html" title="Exception type used by the sqlite3x classes.">database_error</a>(<span class="stringliteral">"nothing to read"</span>); <a name="l00203"></a>00203 <span class="keywordflow">return</span> reader.<a class="code" href="classsqlite3x_1_1sqlite3__cursor.html#2d323375d5cf1a0c3efc915179558db3" title="Gets the string value at the given field number.">getstring</a>(0); <a name="l00204"></a>00204 } <a name="l00205"></a>00205 <a name="l00206"></a>00206 <span class="preprocessor">#if SQLITE3X_USE_WCHAR</span> <a name="l00207"></a>00207 <span class="preprocessor"></span> std::wstring sqlite3_command::executestring16() { <a name="l00208"></a>00208 <a class="code" href="classsqlite3x_1_1sqlite3__cursor.html" title="A type for reading results from an sqlite3_command.">sqlite3_cursor</a> reader=this-><a class="code" href="classsqlite3x_1_1sqlite3__command.html#aa821db4faab5a3577f3cf55ed4f6906" title="Executes the query and returns a cursor object which can be used to iterate over...">executecursor</a>(); <a name="l00209"></a>00209 <span class="keywordflow">if</span>(!reader.<a class="code" href="classsqlite3x_1_1sqlite3__cursor.html#b2c806b7049f1715b8e6f4106aa6af4b" title="Steps one step through the sql result set and returns true on SQLITE_ROW, false on...">step</a>()) <span class="keywordflow">throw</span> <a class="code" href="classsqlite3x_1_1database__error.html" title="Exception type used by the sqlite3x classes.">database_error</a>(<span class="stringliteral">"nothing to read"</span>); <a name="l00210"></a>00210 <span class="keywordflow">return</span> reader.getstring16(0); <a name="l00211"></a>00211 } <a name="l00212"></a>00212 <span class="preprocessor">#endif</span> <a name="l00213"></a>00213 <span class="preprocessor"></span> <a name="l00214"></a><a class="code" href="classsqlite3x_1_1sqlite3__command.html#4bd14df714cf375a4855bae80b0a2292">00214</a> std::string <a class="code" href="classsqlite3x_1_1sqlite3__command.html#4bd14df714cf375a4855bae80b0a2292" title="Executes the query, which is expected to have a string or blob field as the first...">sqlite3_command::executeblob</a>() { <a name="l00215"></a>00215 <a class="code" href="classsqlite3x_1_1sqlite3__cursor.html" title="A type for reading results from an sqlite3_command.">sqlite3_cursor</a> reader=this-><a class="code" href="classsqlite3x_1_1sqlite3__command.html#aa821db4faab5a3577f3cf55ed4f6906" title="Executes the query and returns a cursor object which can be used to iterate over...">executecursor</a>(); <a name="l00216"></a>00216 <span class="keywordflow">if</span>(!reader.<a class="code" href="classsqlite3x_1_1sqlite3__cursor.html#b2c806b7049f1715b8e6f4106aa6af4b" title="Steps one step through the sql result set and returns true on SQLITE_ROW, false on...">step</a>()) <span class="keywordflow">throw</span> <a class="code" href="classsqlite3x_1_1database__error.html" title="Exception type used by the sqlite3x classes.">database_error</a>(<span class="stringliteral">"nothing to read"</span>); <a name="l00217"></a>00217 <span class="keywordflow">return</span> reader.<a class="code" href="classsqlite3x_1_1sqlite3__cursor.html#c645e030d1bbdfa13e88af4a61ed810e" title="Gets the blob value at the given field number.">getblob</a>(0); <a name="l00218"></a>00218 } <a name="l00219"></a>00219 <a name="l00220"></a><a class="code" href="classsqlite3x_1_1sqlite3__command.html#25ad41fab138dd4814925abd43f0f22d">00220</a> <span class="keywordtype">void</span> <span class="keyword">const</span> * <a class="code" href="classsqlite3x_1_1sqlite3__command.html#4bd14df714cf375a4855bae80b0a2292" title="Executes the query, which is expected to have a string or blob field as the first...">sqlite3_command::executeblob</a>( <span class="keywordtype">int</span> & size ) { <a name="l00221"></a>00221 <a class="code" href="classsqlite3x_1_1sqlite3__cursor.html" title="A type for reading results from an sqlite3_command.">sqlite3_cursor</a> reader=this-><a class="code" href="classsqlite3x_1_1sqlite3__command.html#aa821db4faab5a3577f3cf55ed4f6906" title="Executes the query and returns a cursor object which can be used to iterate over...">executecursor</a>(); <a name="l00222"></a>00222 <span class="keywordflow">if</span>(!reader.<a class="code" href="classsqlite3x_1_1sqlite3__cursor.html#b2c806b7049f1715b8e6f4106aa6af4b" title="Steps one step through the sql result set and returns true on SQLITE_ROW, false on...">step</a>()) <span class="keywordflow">throw</span> <a class="code" href="classsqlite3x_1_1database__error.html" title="Exception type used by the sqlite3x classes.">database_error</a>(<span class="stringliteral">"nothing to read"</span>); <a name="l00223"></a>00223 <span class="keywordflow">return</span> reader.<a class="code" href="classsqlite3x_1_1sqlite3__cursor.html#c645e030d1bbdfa13e88af4a61ed810e" title="Gets the blob value at the given field number.">getblob</a>(0, size); <a name="l00224"></a>00224 } <a name="l00225"></a>00225 <a name="l00226"></a><a class="code" href="classsqlite3x_1_1sqlite3__command.html#a9540e9132b3927cd44abb0de53f398e">00226</a> <span class="keywordtype">int</span> <a class="code" href="classsqlite3x_1_1sqlite3__command.html#a9540e9132b3927cd44abb0de53f398e" title="Returns the column count of this object&#39;s query, or throws on error.">sqlite3_command::colcount</a>() <a name="l00227"></a>00227 { <a name="l00228"></a>00228 <span class="keywordflow">if</span>( ! this->stmt ) <a name="l00229"></a>00229 { <a name="l00230"></a>00230 <span class="keywordflow">throw</span> <a class="code" href="classsqlite3x_1_1database__error.html" title="Exception type used by the sqlite3x classes.">database_error</a>(<span class="stringliteral">"sqlite3_command::colcount(): statement has not been prepared"</span>); <a name="l00231"></a>00231 } <a name="l00232"></a>00232 <span class="keywordflow">return</span> sqlite3_column_count( this->stmt ); <a name="l00233"></a>00233 } <a name="l00234"></a>00234 <a name="l00235"></a>00235 <a name="l00236"></a><a class="code" href="classsqlite3x_1_1sqlite3__command.html#1a2076c8b07432561a30e266569454ae">00236</a> <span class="keywordtype">bool</span> <a class="code" href="classsqlite3x_1_1sqlite3__command.html#1a2076c8b07432561a30e266569454ae" title="Resets this statement using sqlite3_reset().">sqlite3_command::reset</a>() <a name="l00237"></a>00237 { <a name="l00238"></a>00238 <span class="keywordtype">int</span> rc = SQLITE_OK; <a name="l00239"></a>00239 <span class="keywordflow">if</span>( this->stmt ) <a name="l00240"></a>00240 { <a name="l00241"></a>00241 rc = sqlite3_reset( this->stmt ); <a name="l00242"></a>00242 } <a name="l00243"></a>00243 <span class="keywordflow">return</span> rc == SQLITE_OK; <a name="l00244"></a>00244 } <a name="l00245"></a>00245 <a name="l00246"></a><a class="code" href="classsqlite3x_1_1sqlite3__command.html#dfc169aaf1ef9fa10cf741a776dcdb67">00246</a> sqlite3_stmt * <a class="code" href="classsqlite3x_1_1sqlite3__command.html#dfc169aaf1ef9fa10cf741a776dcdb67" title="Returns the underlying statement handle.">sqlite3_command::handle</a>() <a name="l00247"></a>00247 { <a name="l00248"></a>00248 <span class="keywordflow">return</span> this->stmt; <a name="l00249"></a>00249 } <a name="l00250"></a>00250 <a name="l00251"></a>00251 <a name="l00252"></a>00252 } </pre></div></div> <hr size="1"><address style="text-align: right;"><small>Generated on Sun Jul 26 18:20:37 2009 for libsqlite3x by <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>