sqlitexx 0.0.1
connection.hpp
Go to the documentation of this file.
1/*
2 * sqlite3xx - sqlite3 C++ layer, following the ideas of libpqxx
3 * Copyright (C) 2009 Andreas Baumann
4 *
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions of
7 * the GNU Lesser General Public License, as published by the Free Software
8 * Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 * License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this distribution; if not, write to:
18 * Free Software Foundation, Inc.
19 * 51 Franklin Street, Fifth Floor
20 * Boston, MA 02110-1301 USA
21 *
22 */
23
24#ifndef SQLITE3XX_CONNECTION_H
25#define SQLITE3XX_CONNECTION_H
26
28#include "result.hpp"
29
30#include "sqlite3.h"
31
32#include <map>
33#include <iostream>
34
35#include <sqlite3xx/port/stdint.h> /* for uintmax_t */
36
37#include "port/dllexport.h"
38
39using namespace std;
40
41namespace sqlite3xx {
42
43class prepared_stmt;
44class result;
45
47 private:
48 typedef map<string, prepared_stmt *> PSMap;
49
50 unsigned int _internal_tno;
51 string _filename;
52 sqlite3 *db;
53 PSMap prepared_stmts;
54 bool _trace;
55
56 SQLITEXX_PRIVATE prepared_stmt* find_prepared( const string& name );
57
58 public:
60 connection( string filename );
63
64 void trace( bool __trace );
65 bool trace( ) { return _trace; }
66
67 result exec( string sql );
68 result prepared_exec( const string& name );
69
70 prepare::declaration prepare( const string& name, string sql );
71 void prepare_param_declare( const string& stmt, const string& sqltype, prepare::param_treatment& treatment );
72 void prepared_reset( const string& name );
73 void prepare_setparam( const string& name, const int pos, const int value );
74 void prepare_setparam( const string& name, const int pos, const unsigned int value );
75 void prepare_setparam( const string& name, const int pos, const char* value );
76 void prepare_setparam( const string& name, const int pos, const double value );
77 void prepare_setparam( const string& name, const int pos, const long value );
78 void prepare_setparam( const string& name, const int pos, const uintmax_t value );
79
80 void unprepare( string name );
81
82 SQLITEXX_LIBEXPORT friend ostream& operator<<( ostream& o, const connection& c );
83
84 const char *dbname( ) { return _filename.c_str( ); };
85};
86
87}
88
89#endif /* SQLITE3XX_CONNECTION_H */
void prepare_param_declare(const string &stmt, const string &sqltype, prepare::param_treatment &treatment)
void prepare_setparam(const string &name, const int pos, const long value)
void prepare_setparam(const string &name, const int pos, const unsigned int value)
SQLITEXX_LIBEXPORT friend ostream & operator<<(ostream &o, const connection &c)
void prepare_setparam(const string &name, const int pos, const uintmax_t value)
void prepare_setparam(const string &name, const int pos, const double value)
prepare::declaration prepare(const string &name, string sql)
void trace(bool __trace)
void prepare_setparam(const string &name, const int pos, const char *value)
void prepared_reset(const string &name)
bool trace()
Definition connection.hpp:65
result exec(string sql)
result prepared_exec(const string &name)
const char * dbname()
Definition connection.hpp:84
connection(const connection &c)
void unprepare(string name)
connection(string filename)
void prepare_setparam(const string &name, const int pos, const int value)
Definition prepared_statement.hpp:51
Definition prepared_statement.hpp:90
Definition result.hpp:42
#define SQLITEXX_LIBEXPORT
Definition dllexport.h:35
#define SQLITEXX_PRIVATE
Definition dllexport.h:36
param_treatment
Definition prepared_statement.hpp:46
Definition connection.hpp:41