sqlitexx: connection.hpp Source File

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
27#include "prepared_statement.hpp"
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
41 namespace sqlite3xx {
42
43class prepared_stmt;
44class result;
45
46 class SQLITEXX_LIBEXPORT connection {
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:
59 connection( );
60 connection( string filename );
61 connection( const connection& c );
62 ~connection( );
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 */
sqlite3xx::connection
Definition connection.hpp:46
sqlite3xx::connection::~connection
~connection()
sqlite3xx::connection::prepare_param_declare
void prepare_param_declare(const string &stmt, const string &sqltype, prepare::param_treatment &treatment)
sqlite3xx::connection::prepare_setparam
void prepare_setparam(const string &name, const int pos, const long value)
sqlite3xx::connection::prepare_setparam
void prepare_setparam(const string &name, const int pos, const unsigned int value)
sqlite3xx::connection::operator<<
SQLITEXX_LIBEXPORT friend ostream & operator<<(ostream &o, const connection &c)
sqlite3xx::connection::prepare_setparam
void prepare_setparam(const string &name, const int pos, const uintmax_t value)
sqlite3xx::connection::prepare_setparam
void prepare_setparam(const string &name, const int pos, const double value)
sqlite3xx::connection::prepare
prepare::declaration prepare(const string &name, string sql)
sqlite3xx::connection::trace
void trace(bool __trace)
sqlite3xx::connection::prepare_setparam
void prepare_setparam(const string &name, const int pos, const char *value)
sqlite3xx::connection::prepared_reset
void prepared_reset(const string &name)
sqlite3xx::connection::trace
bool trace()
Definition connection.hpp:65
sqlite3xx::connection::exec
result exec(string sql)
sqlite3xx::connection::prepared_exec
result prepared_exec(const string &name)
sqlite3xx::connection::dbname
const char * dbname()
Definition connection.hpp:84
sqlite3xx::connection::connection
connection(const connection &c)
sqlite3xx::connection::connection
connection()
sqlite3xx::connection::unprepare
void unprepare(string name)
sqlite3xx::connection::connection
connection(string filename)
sqlite3xx::connection::prepare_setparam
void prepare_setparam(const string &name, const int pos, const int value)
sqlite3xx::prepare::declaration
Definition prepared_statement.hpp:51
sqlite3xx::prepared_stmt
Definition prepared_statement.hpp:90
sqlite3xx::result
Definition result.hpp:42
dllexport.h
SQLITEXX_LIBEXPORT
#define SQLITEXX_LIBEXPORT
Definition dllexport.h:35
SQLITEXX_PRIVATE
#define SQLITEXX_PRIVATE
Definition dllexport.h:36
sqlite3xx::prepare::param_treatment
param_treatment
Definition prepared_statement.hpp:46
sqlite3xx
Definition connection.hpp:41
prepared_statement.hpp
result.hpp
stdint.h