ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/truck/Common/sqlite3.cpp
(Generate patch)

Comparing:
Common/common.hpp (file contents), Revision 3 by douglas, 2007-04-26T01:51:35-07:00 vs.
Common/sqlite3.cpp (file contents), Revision 45 by douglas, 2008-03-06T18:12:54-08:00

# Line 4 | Line 4
4   //
5   // $Id$
6  
7 < #ifndef _common_hpp_
8 < #define _common_hpp_
7 > #include "sqlite3.hpp"
8  
9 < #define _B(s) std::string(s, sizeof (s) - 1)
9 > namespace SQLite3
10 > {
11  
12 < #endif//_common_hpp_
12 > Connection::Connection(const std::string &db)
13 > {
14 >        CheckError(::sqlite3_open(db.c_str(), &connection), connection);
15 > }
16 >
17 > Connection::~Connection()
18 > {
19 >        CheckError(::sqlite3_close(connection), connection);
20 > }
21 >
22 > Statement::Statement(Connection &connection, const std::string &statement) : connection(connection)
23 > {
24 >        CheckError(::sqlite3_prepare_v2(connection.GetHandle(), statement.data(), statement.size(), &this->statement, NULL), connection.GetHandle());
25 > }
26 >
27 > Statement::~Statement()
28 > {
29 >        ::sqlite3_finalize(statement);
30 > }
31 >
32 > void Statement::Set(unsigned index, double value)
33 > {
34 >        CheckError(::sqlite3_bind_double(statement, index, value), connection.GetHandle());
35 > }
36 >
37 > void Statement::Set(unsigned index, int value)
38 > {
39 >        CheckError(::sqlite3_bind_int(statement, index, value), connection.GetHandle());
40 > }
41 >
42 > void Statement::Set(unsigned index, int64_t value)
43 > {
44 >        CheckError(::sqlite3_bind_int64(statement, index, value), connection.GetHandle());
45 > }
46 >
47 > void Statement::Set(unsigned index, const Null &value)
48 > {
49 >        CheckError(::sqlite3_bind_null(statement, index), connection.GetHandle());
50 > }
51 >
52 > void Statement::Set(unsigned index, const std::string &value)
53 > {
54 >        CheckError(::sqlite3_bind_text(statement, index, value.data(), value.size(), SQLITE_TRANSIENT), connection.GetHandle());
55 > }
56 >
57 > }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines